2 * Copyright (C) 2000 Harri Porten (porten@kde.org)
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef JSDOMWindowBase_h
21 #define JSDOMWindowBase_h
23 #include "JSDOMBinding.h"
24 #include "JSDOMGlobalObject.h"
25 #include <wtf/Forward.h>
31 class DOMWrapperWorld;
33 class JSDOMWindowShell;
35 class JSDOMWindowBasePrivate;
37 class JSDOMWindowBase : public JSDOMGlobalObject {
38 typedef JSDOMGlobalObject Base;
40 JSDOMWindowBase(JSC::JSGlobalData&, JSC::Structure*, PassRefPtr<DOMWindow>, JSDOMWindowShell*);
41 void finishCreation(JSC::JSGlobalData&, JSDOMWindowShell*);
44 void updateDocument();
46 DOMWindow* impl() const { return m_impl.get(); }
47 virtual ScriptExecutionContext* scriptExecutionContext() const;
49 // Called just before removing this window from the JSDOMWindowShell.
50 void willRemoveFromWindowShell();
52 static const JSC::ClassInfo s_info;
54 static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
56 return JSC::Structure::create(globalData, 0, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);
59 virtual bool supportsProfiling() const;
60 virtual bool supportsRichSourceInfo() const;
61 virtual bool shouldInterruptScript() const;
63 bool allowsAccessFrom(JSC::ExecState*) const;
64 bool allowsAccessFromNoErrorMessage(JSC::ExecState*) const;
65 bool allowsAccessFrom(JSC::ExecState*, String& message) const;
66 void printErrorMessage(const String&) const;
68 // Don't call this version of allowsAccessFrom -- it's a slightly incorrect implementation used only by WebScriptObject
69 virtual bool allowsAccessFrom(const JSC::JSGlobalObject*) const;
71 virtual JSC::JSObject* toThisObject(JSC::ExecState*) const;
72 virtual JSC::JSValue toStrictThisObject(JSC::ExecState*) const;
73 JSDOMWindowShell* shell() const;
75 static JSC::JSGlobalData* commonJSGlobalData();
78 RefPtr<DOMWindow> m_impl;
79 JSDOMWindowShell* m_shell;
81 bool allowsAccessFromPrivate(const JSC::JSGlobalObject*) const;
82 String crossDomainAccessErrorMessage(const JSC::JSGlobalObject*) const;
85 // Returns a JSDOMWindow or jsNull()
86 // JSDOMGlobalObject* is ignored, accessing a window in any context will
87 // use that DOMWindow's prototype chain.
88 JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, DOMWindow*);
89 JSC::JSValue toJS(JSC::ExecState*, DOMWindow*);
91 // Returns JSDOMWindow or 0
92 JSDOMWindow* toJSDOMWindow(Frame*, DOMWrapperWorld*);
93 JSDOMWindow* toJSDOMWindow(JSC::JSValue);
95 } // namespace WebCore
97 #endif // JSDOMWindowBase_h