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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // ====== LocalWindowProxy vs RemoteWindowProxy ====== | 90 // ====== LocalWindowProxy vs RemoteWindowProxy ====== |
91 // WindowProxy has two concrete subclasses: | 91 // WindowProxy has two concrete subclasses: |
92 // - LocalWindowProxy: implements the split window model for a frame in the same | 92 // - LocalWindowProxy: implements the split window model for a frame in the same |
93 // process, i.e. a LocalFrame. | 93 // process, i.e. a LocalFrame. |
94 // - RemoteWindowProxy: implements the split window model for a frame in a | 94 // - RemoteWindowProxy: implements the split window model for a frame in a |
95 // different process, i.e. a RemoteFrame. | 95 // different process, i.e. a RemoteFrame. |
96 // | 96 // |
97 // While having a RemoteFrame implies the frame must be cross-origin, the | 97 // While having a RemoteFrame implies the frame must be cross-origin, the |
98 // opposite is not true: a LocalFrame can be same-origin or cross-origin. One | 98 // opposite is not true: a LocalFrame can be same-origin or cross-origin. One |
99 // additional complexity (which slightly violates the HTML standard): it is | 99 // additional complexity (which slightly violates the HTML standard): it is |
100 // possible to have SecurityOrigin::canAccess() return true for a RemoteFrame's | 100 // possible to have SecurityOrigin::CanAccess() return true for a RemoteFrame's |
101 // security origin; however, it is important to still deny access as if the | 101 // security origin; however, it is important to still deny access as if the |
102 // frame were cross-origin. This is due to complexities in the process | 102 // frame were cross-origin. This is due to complexities in the process |
103 // allocation model for renderer processes. See https://crbug.com/601629. | 103 // allocation model for renderer processes. See https://crbug.com/601629. |
104 // | 104 // |
105 // ====== LocalWindowProxy ====== | 105 // ====== LocalWindowProxy ====== |
106 // Since a LocalWindowProxy can represent a same-origin or cross-origin frame, | 106 // Since a LocalWindowProxy can represent a same-origin or cross-origin frame, |
107 // the entire prototype chain must be available: | 107 // the entire prototype chain must be available: |
108 // | 108 // |
109 // outer global proxy | 109 // outer global proxy |
110 // -- has prototype --> inner global object | 110 // -- has prototype --> inner global object |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 // TODO(dcheng): Temporarily exposed to avoid include cycles. Remove the need | 158 // TODO(dcheng): Temporarily exposed to avoid include cycles. Remove the need |
159 // for this and remove this getter. | 159 // for this and remove this getter. |
160 DOMWrapperWorld& World() { return *world_; } | 160 DOMWrapperWorld& World() { return *world_; } |
161 | 161 |
162 virtual bool IsLocal() const { return false; } | 162 virtual bool IsLocal() const { return false; } |
163 | 163 |
164 protected: | 164 protected: |
165 // Lifecycle represents the following four states. | 165 // Lifecycle represents the following four states. |
166 // | 166 // |
167 // * ContextIsUninitialized | 167 // * kContextIsUninitialized |
168 // We lazily initialize WindowProxies for performance reasons, and this state | 168 // We lazily initialize WindowProxies for performance reasons, and this state |
169 // is "to be initialized on demand". WindowProxy basically behaves the same as | 169 // is "to be initialized on demand". WindowProxy basically behaves the same as |
170 // |ContextIsInitialized| from a point of view of call sites. | 170 // |kContextIsInitialized| from a point of view of call sites. |
171 // - Possible next states: ContextIsInitialized | 171 // - Possible next states: kContextIsInitialized |
172 // It's possible to detach the context's frame from the DOM or navigate to a | 172 // It's possible to detach the context's frame from the DOM or navigate to a |
173 // new page without initializing the WindowProxy, however, there is no | 173 // new page without initializing the WindowProxy, however, there is no |
174 // transition to |FrameIsDetached| or |GlobalObjectIsDetached| | 174 // transition to |kFrameIsDetached| or |kGlobalObjectIsDetached| |
175 // because |disposeContext| does not change the state if the state is | 175 // because |DisposeContext| does not change the state if the state is |
176 // |ContextIsUninitialized|. In either case of a) the browsing context | 176 // |kContextIsUninitialized|. In either case of a) the browsing context |
177 // container is detached from the DOM or b) the page is navigated away, there | 177 // container is detached from the DOM or b) the page is navigated away, there |
178 // must be no way for author script to access the context of | 178 // must be no way for author script to access the context of |
179 // |ContextIsUninitialized| because |ContextIsUninitialized| means that author | 179 // |kContextIsUninitialized| because |kContextIsUninitialized| means that |
180 // script has never accessed the context, hence there must exist no reference | 180 // author script has never accessed the context, hence there must exist no |
181 // to the context. | 181 // reference to the context. |
182 // | 182 // |
183 // * ContextIsInitialized | 183 // * kContextIsInitialized |
184 // The context is initialized and its frame is still attached to the DOM. | 184 // The context is initialized and its frame is still attached to the DOM. |
185 // - Possible next states: FrameIsDetached, GlobalObjectIsDetached | 185 // - Possible next states: kFrameIsDetached, kGlobalObjectIsDetached |
186 // | 186 // |
187 // * GlobalObjectIsDetached | 187 // * kGlobalObjectIsDetached |
188 // The context is initialized and its frame is still attached to the DOM, but | 188 // The context is initialized and its frame is still attached to the DOM, but |
189 // the global object(inner global)'s Document is no longer the active Document | 189 // the global object(inner global)'s Document is no longer the active Document |
190 // of the frame (i.e. it is being navigated away). The global object (inner | 190 // of the frame (i.e. it is being navigated away). The global object (inner |
191 // global) is detached from the global proxy (outer global), but the | 191 // global) is detached from the global proxy (outer global), but the |
192 // (detached) global object and context are still alive, and author script may | 192 // (detached) global object and context are still alive, and author script may |
193 // have references to the context. | 193 // have references to the context. |
194 // The spec does not support full web features in this state. Blink supports | 194 // The spec does not support full web features in this state. Blink supports |
195 // less things than the spec. | 195 // less things than the spec. |
196 // This state is also used when swapping frames. See also |WebFrame::swap|. | 196 // This state is also used when swapping frames. See also |WebFrame::Swap|. |
197 // - Possible next states: ContextIsInitialized | 197 // - Possible next states: kContextIsInitialized |
198 // This state is in the middle of navigation. Once document loading is | 198 // This state is in the middle of navigation. Once document loading is |
199 // completed, the WindowProxy will always be reinitialized, as | 199 // completed, the WindowProxy will always be reinitialized, as |
200 // |DocumentLoader::installNewDocument| ends up calling to | 200 // |DocumentLoader::InstallNewDocument| ends up calling to |
201 // |WindowProxy::updateDocument|, which reinitializes the WindowProxy. | 201 // |WindowProxy::UpdateDocument|, which reinitializes the WindowProxy. |
202 // | 202 // |
203 // * FrameIsDetached | 203 // * kFrameIsDetached |
204 // The context was initialized, but its frame has been detached from the DOM. | 204 // The context was initialized, but its frame has been detached from the DOM. |
205 // Note that the context is still alive and author script may have references | 205 // Note that the context is still alive and author script may have references |
206 // to the context and hence author script may run in the context. | 206 // to the context and hence author script may run in the context. |
207 // The spec does not support some of web features such as setTimeout, etc. on | 207 // The spec does not support some of web features such as setTimeout, etc. on |
208 // a detached window. Blink supports less things than the spec. | 208 // a detached window. Blink supports less things than the spec. |
209 // V8PerContextData is cut off from the context. | 209 // V8PerContextData is cut off from the context. |
210 // - Possible next states: n/a | 210 // - Possible next states: n/a |
211 enum class Lifecycle { | 211 enum class Lifecycle { |
212 // v8::Context is not yet initialized. | 212 // v8::Context is not yet initialized. |
213 kContextIsUninitialized, | 213 kContextIsUninitialized, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 protected: | 250 protected: |
251 // TODO(dcheng): Consider making these private and using getters. | 251 // TODO(dcheng): Consider making these private and using getters. |
252 const RefPtr<DOMWrapperWorld> world_; | 252 const RefPtr<DOMWrapperWorld> world_; |
253 ScopedPersistent<v8::Object> global_proxy_; | 253 ScopedPersistent<v8::Object> global_proxy_; |
254 Lifecycle lifecycle_; | 254 Lifecycle lifecycle_; |
255 }; | 255 }; |
256 | 256 |
257 } // namespace blink | 257 } // namespace blink |
258 | 258 |
259 #endif // WindowProxy_h | 259 #endif // WindowProxy_h |
OLD | NEW |