OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 17 matching lines...) Expand all Loading... |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef V8WindowShell_h | 31 #ifndef V8WindowShell_h |
32 #define V8WindowShell_h | 32 #define V8WindowShell_h |
33 | 33 |
34 #include "bindings/v8/DOMWrapperWorld.h" | 34 #include "bindings/v8/DOMWrapperWorld.h" |
35 #include "bindings/v8/ScopedPersistent.h" | 35 #include "bindings/v8/ScopedPersistent.h" |
36 #include "bindings/v8/V8PerContextData.h" | 36 #include "bindings/v8/V8PerContextData.h" |
37 #include "bindings/v8/WrapperTypeInfo.h" | 37 #include "bindings/v8/WrapperTypeInfo.h" |
38 #include "gin/public/context_holder.h" | |
39 #include "platform/weborigin/SecurityOrigin.h" | 38 #include "platform/weborigin/SecurityOrigin.h" |
40 #include "wtf/Forward.h" | 39 #include "wtf/Forward.h" |
41 #include "wtf/HashMap.h" | 40 #include "wtf/HashMap.h" |
42 #include "wtf/PassRefPtr.h" | 41 #include "wtf/PassRefPtr.h" |
43 #include "wtf/RefCounted.h" | 42 #include "wtf/RefCounted.h" |
44 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
45 #include "wtf/text/AtomicString.h" | 44 #include "wtf/text/AtomicString.h" |
46 #include <v8.h> | 45 #include <v8.h> |
47 | 46 |
48 namespace WebCore { | 47 namespace WebCore { |
49 | 48 |
50 class DOMWindow; | 49 class DOMWindow; |
51 class LocalFrame; | 50 class LocalFrame; |
52 class HTMLDocument; | 51 class HTMLDocument; |
53 class SecurityOrigin; | 52 class SecurityOrigin; |
54 | 53 |
55 // V8WindowShell represents all the per-global object state for a LocalFrame tha
t | 54 // V8WindowShell represents all the per-global object state for a LocalFrame tha
t |
56 // persist between navigations. | 55 // persist between navigations. |
57 class V8WindowShell { | 56 class V8WindowShell { |
58 public: | 57 public: |
59 static PassOwnPtr<V8WindowShell> create(LocalFrame*, PassRefPtr<DOMWrapperWo
rld>, v8::Isolate*); | 58 static PassOwnPtr<V8WindowShell> create(LocalFrame*, PassRefPtr<DOMWrapperWo
rld>, v8::Isolate*); |
60 | 59 |
61 v8::Local<v8::Context> context() const { return m_contextHolder ? m_contextH
older->context() : v8::Local<v8::Context>(); } | 60 v8::Local<v8::Context> context() const { return m_perContextData ? m_perCont
extData->context() : v8::Local<v8::Context>(); } |
62 | 61 |
63 // Update document object of the frame. | 62 // Update document object of the frame. |
64 void updateDocument(); | 63 void updateDocument(); |
65 | 64 |
66 void namedItemAdded(HTMLDocument*, const AtomicString&); | 65 void namedItemAdded(HTMLDocument*, const AtomicString&); |
67 void namedItemRemoved(HTMLDocument*, const AtomicString&); | 66 void namedItemRemoved(HTMLDocument*, const AtomicString&); |
68 | 67 |
69 // Update the security origin of a document | 68 // Update the security origin of a document |
70 // (e.g., after setting docoument.domain). | 69 // (e.g., after setting docoument.domain). |
71 void updateSecurityOrigin(SecurityOrigin*); | 70 void updateSecurityOrigin(SecurityOrigin*); |
72 | 71 |
73 bool isContextInitialized() { return m_contextHolder; } | 72 bool isContextInitialized() { return m_perContextData; } |
74 bool isGlobalInitialized() { return !m_global.isEmpty(); } | 73 bool isGlobalInitialized() { return !m_global.isEmpty(); } |
75 | 74 |
76 bool initializeIfNeeded(); | 75 bool initializeIfNeeded(); |
77 void updateDocumentWrapper(v8::Handle<v8::Object> wrapper); | 76 void updateDocumentWrapper(v8::Handle<v8::Object> wrapper); |
78 | 77 |
79 void clearForNavigation(); | 78 void clearForNavigation(); |
80 void clearForClose(bool destroyGlobal); | 79 void clearForClose(bool destroyGlobal); |
81 | 80 |
82 DOMWrapperWorld* world() { return m_world.get(); } | 81 DOMWrapperWorld* world() { return m_world.get(); } |
83 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); | 82 static bool contextHasCorrectPrototype(v8::Handle<v8::Context>); |
(...skipping 18 matching lines...) Expand all Loading... |
102 void clearDocumentProperty(); | 101 void clearDocumentProperty(); |
103 | 102 |
104 void createContext(); | 103 void createContext(); |
105 bool installDOMWindow(); | 104 bool installDOMWindow(); |
106 | 105 |
107 static V8WindowShell* enteredIsolatedWorldContext(); | 106 static V8WindowShell* enteredIsolatedWorldContext(); |
108 | 107 |
109 LocalFrame* m_frame; | 108 LocalFrame* m_frame; |
110 RefPtr<DOMWrapperWorld> m_world; | 109 RefPtr<DOMWrapperWorld> m_world; |
111 v8::Isolate* m_isolate; | 110 v8::Isolate* m_isolate; |
112 | |
113 OwnPtr<V8PerContextData> m_perContextData; | 111 OwnPtr<V8PerContextData> m_perContextData; |
114 | |
115 OwnPtr<gin::ContextHolder> m_contextHolder; | |
116 ScopedPersistent<v8::Object> m_global; | 112 ScopedPersistent<v8::Object> m_global; |
117 ScopedPersistent<v8::Object> m_document; | 113 ScopedPersistent<v8::Object> m_document; |
118 }; | 114 }; |
119 | 115 |
120 } // namespace WebCore | 116 } // namespace WebCore |
121 | 117 |
122 #endif // V8WindowShell_h | 118 #endif // V8WindowShell_h |
OLD | NEW |