OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 void WindowProxy::takeGlobalFrom(WindowProxy* windowProxy) | 149 void WindowProxy::takeGlobalFrom(WindowProxy* windowProxy) |
150 { | 150 { |
151 v8::HandleScope handleScope(m_isolate); | 151 v8::HandleScope handleScope(m_isolate); |
152 ASSERT(!windowProxy->isContextInitialized()); | 152 ASSERT(!windowProxy->isContextInitialized()); |
153 // If a ScriptState was created, the context was initialized at some point. | 153 // If a ScriptState was created, the context was initialized at some point. |
154 // Make sure the global object was detached from the proxy by calling clearF orNavigation(). | 154 // Make sure the global object was detached from the proxy by calling clearF orNavigation(). |
155 if (windowProxy->m_scriptState) | 155 if (windowProxy->m_scriptState) |
156 ASSERT(windowProxy->m_scriptState->isGlobalObjectDetached()); | 156 ASSERT(windowProxy->m_scriptState->isGlobalObjectDetached()); |
157 m_global.set(m_isolate, windowProxy->m_global.newLocal(m_isolate)); | 157 m_global.set(m_isolate, windowProxy->m_global.newLocal(m_isolate)); |
158 windowProxy->m_global.clear(); | 158 windowProxy->m_global.clear(); |
159 // Initialize the window proxy now, to re-establish the connection between | |
160 // the global object and the v8::Context. This is really only needed for a | |
161 // RemoteDOMWindow, since it has no scripting environment of its own. | |
162 // Without this, existing script references to a swapped in RemoteDOMWindow | |
163 // would be broken until that RemoteDOMWindow was vended again through an | |
164 // interface like window.frames. | |
165 initializeIfNeeded(); | |
haraken
2015/04/24 05:06:04
Just to confirm: This initializeIfNeeded() creates
| |
159 } | 166 } |
160 | 167 |
161 // Create a new environment and setup the global object. | 168 // Create a new environment and setup the global object. |
162 // | 169 // |
163 // The global object corresponds to a DOMWindow instance. However, to | 170 // The global object corresponds to a DOMWindow instance. However, to |
164 // allow properties of the JS DOMWindow instance to be shadowed, we | 171 // allow properties of the JS DOMWindow instance to be shadowed, we |
165 // use a shadow object as the global object and use the JS DOMWindow | 172 // use a shadow object as the global object and use the JS DOMWindow |
166 // instance as the prototype for that shadow object. The JS DOMWindow | 173 // instance as the prototype for that shadow object. The JS DOMWindow |
167 // instance is undetectable from JavaScript code because the __proto__ | 174 // instance is undetectable from JavaScript code because the __proto__ |
168 // accessors skip that object. | 175 // accessors skip that object. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 // If two tokens are equal, then the SecurityOrigins canAccess each other. | 397 // If two tokens are equal, then the SecurityOrigins canAccess each other. |
391 // If two tokens are not equal, then we have to call canAccess. | 398 // If two tokens are not equal, then we have to call canAccess. |
392 // Note: we can't use the HTTPOrigin if it was set from the DOM. | 399 // Note: we can't use the HTTPOrigin if it was set from the DOM. |
393 String token; | 400 String token; |
394 // There are several situations where v8 needs to do a full canAccess check, | 401 // There are several situations where v8 needs to do a full canAccess check, |
395 // so set an empty security token instead: | 402 // so set an empty security token instead: |
396 // - document.domain was modified | 403 // - document.domain was modified |
397 // - the frame is showing the initial empty document | 404 // - the frame is showing the initial empty document |
398 // - the frame is remote | 405 // - the frame is remote |
399 bool delaySet = m_world->isMainWorld() | 406 bool delaySet = m_world->isMainWorld() |
400 && (origin->domainWasSetInDOM() | 407 && (m_frame->isRemoteFrame() |
401 || m_frame->isRemoteFrame() | 408 || origin->domainWasSetInDOM() |
402 || toLocalFrame(m_frame)->loader().stateMachine()->isDisplayingIniti alEmptyDocument()); | 409 || toLocalFrame(m_frame)->loader().stateMachine()->isDisplayingIniti alEmptyDocument()); |
403 if (origin && !delaySet) | 410 if (origin && !delaySet) |
404 token = origin->toString(); | 411 token = origin->toString(); |
405 | 412 |
406 // An empty or "null" token means we always have to call | 413 // An empty or "null" token means we always have to call |
407 // canAccess. The toString method on securityOrigins returns the | 414 // canAccess. The toString method on securityOrigins returns the |
408 // string "null" for empty security origins and for security | 415 // string "null" for empty security origins and for security |
409 // origins that should only allow access to themselves. In this | 416 // origins that should only allow access to themselves. In this |
410 // case, we use the global object as the security token to avoid | 417 // case, we use the global object as the security token to avoid |
411 // calling canAccess when a script accesses its own objects. | 418 // calling canAccess when a script accesses its own objects. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 | 517 |
511 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) | 518 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) |
512 { | 519 { |
513 ASSERT(m_world->isMainWorld()); | 520 ASSERT(m_world->isMainWorld()); |
514 if (!isContextInitialized()) | 521 if (!isContextInitialized()) |
515 return; | 522 return; |
516 setSecurityToken(origin); | 523 setSecurityToken(origin); |
517 } | 524 } |
518 | 525 |
519 } // namespace blink | 526 } // namespace blink |
OLD | NEW |