WebCore/bindings/js/JSDOMWindowBase.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     1 /*
       
     2  *  Copyright (C) 2000 Harri Porten (porten@kde.org)
       
     3  *  Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reseved.
       
     4  *
       
     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.
       
     9  *
       
    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.
       
    14  *
       
    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
       
    18  */
       
    19 
       
    20 #ifndef JSDOMWindowBase_h
       
    21 #define JSDOMWindowBase_h
       
    22 
       
    23 #include "PlatformString.h"
       
    24 #include "JSDOMBinding.h"
       
    25 #include <runtime/Protect.h>
       
    26 #include <wtf/HashMap.h>
       
    27 #include <wtf/OwnPtr.h>
       
    28 
       
    29 namespace WebCore {
       
    30 
       
    31     class AtomicString;
       
    32     class DOMWindow;
       
    33     class Event;
       
    34     class Frame;
       
    35     class DOMWrapperWorld;
       
    36     class JSDOMWindow;
       
    37     class JSDOMWindowShell;
       
    38     class JSLocation;
       
    39     class JSEventListener;
       
    40     class SecurityOrigin;
       
    41 
       
    42     class JSDOMWindowBasePrivate;
       
    43 
       
    44     class JSDOMWindowBase : public JSDOMGlobalObject {
       
    45         typedef JSDOMGlobalObject Base;
       
    46     protected:
       
    47         JSDOMWindowBase(NonNullPassRefPtr<JSC::Structure>, PassRefPtr<DOMWindow>, JSDOMWindowShell*);
       
    48 
       
    49     public:
       
    50         void updateDocument();
       
    51 
       
    52         DOMWindow* impl() const { return d()->impl.get(); }
       
    53         virtual ScriptExecutionContext* scriptExecutionContext() const;
       
    54 
       
    55         // Called just before removing this window from the JSDOMWindowShell.
       
    56         void willRemoveFromWindowShell();
       
    57 
       
    58         virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
       
    59         static const JSC::ClassInfo s_info;
       
    60 
       
    61         virtual JSC::ExecState* globalExec();
       
    62         virtual bool supportsProfiling() const;
       
    63         virtual bool shouldInterruptScript() const;
       
    64 
       
    65         bool allowsAccessFrom(JSC::ExecState*) const;
       
    66         bool allowsAccessFromNoErrorMessage(JSC::ExecState*) const;
       
    67         bool allowsAccessFrom(JSC::ExecState*, String& message) const;
       
    68         void printErrorMessage(const String&) const;
       
    69 
       
    70         // Don't call this version of allowsAccessFrom -- it's a slightly incorrect implementation used only by WebScriptObject
       
    71         virtual bool allowsAccessFrom(const JSC::JSGlobalObject*) const;
       
    72 
       
    73         virtual JSC::JSObject* toThisObject(JSC::ExecState*) const;
       
    74         JSDOMWindowShell* shell() const;
       
    75 
       
    76         static JSC::JSGlobalData* commonJSGlobalData();
       
    77 
       
    78     private:
       
    79         struct JSDOMWindowBaseData : public JSDOMGlobalObjectData {
       
    80             JSDOMWindowBaseData(PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell);
       
    81 
       
    82             RefPtr<DOMWindow> impl;
       
    83             JSDOMWindowShell* shell;
       
    84         };
       
    85 
       
    86         bool allowsAccessFromPrivate(const JSC::JSGlobalObject*) const;
       
    87         String crossDomainAccessErrorMessage(const JSC::JSGlobalObject*) const;
       
    88         
       
    89         static void destroyJSDOMWindowBaseData(void*);
       
    90 
       
    91         JSDOMWindowBaseData* d() const { return static_cast<JSDOMWindowBaseData*>(JSC::JSVariableObject::d); }
       
    92     };
       
    93 
       
    94     // Returns a JSDOMWindow or jsNull()
       
    95     // JSDOMGlobalObject* is ignored, accessing a window in any context will
       
    96     // use that DOMWindow's prototype chain.
       
    97     JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, DOMWindow*);
       
    98     JSC::JSValue toJS(JSC::ExecState*, DOMWindow*);
       
    99 
       
   100     // Returns JSDOMWindow or 0
       
   101     JSDOMWindow* toJSDOMWindow(Frame*, DOMWrapperWorld*);
       
   102     JSDOMWindow* toJSDOMWindow(JSC::JSValue);
       
   103 
       
   104 } // namespace WebCore
       
   105 
       
   106 #endif // JSDOMWindowBase_h