Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: Source/bindings/core/v8/WindowProxy.cpp

Issue 1078983007: Revert of Initialize the new WindowProxy when handing off the global object. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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();
166 } 159 }
167 160
168 // Create a new environment and setup the global object. 161 // Create a new environment and setup the global object.
169 // 162 //
170 // The global object corresponds to a DOMWindow instance. However, to 163 // The global object corresponds to a DOMWindow instance. However, to
171 // allow properties of the JS DOMWindow instance to be shadowed, we 164 // allow properties of the JS DOMWindow instance to be shadowed, we
172 // use a shadow object as the global object and use the JS DOMWindow 165 // use a shadow object as the global object and use the JS DOMWindow
173 // instance as the prototype for that shadow object. The JS DOMWindow 166 // instance as the prototype for that shadow object. The JS DOMWindow
174 // instance is undetectable from JavaScript code because the __proto__ 167 // instance is undetectable from JavaScript code because the __proto__
175 // accessors skip that object. 168 // accessors skip that object.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 // If two tokens are equal, then the SecurityOrigins canAccess each other. 390 // If two tokens are equal, then the SecurityOrigins canAccess each other.
398 // If two tokens are not equal, then we have to call canAccess. 391 // If two tokens are not equal, then we have to call canAccess.
399 // Note: we can't use the HTTPOrigin if it was set from the DOM. 392 // Note: we can't use the HTTPOrigin if it was set from the DOM.
400 String token; 393 String token;
401 // There are several situations where v8 needs to do a full canAccess check, 394 // There are several situations where v8 needs to do a full canAccess check,
402 // so set an empty security token instead: 395 // so set an empty security token instead:
403 // - document.domain was modified 396 // - document.domain was modified
404 // - the frame is showing the initial empty document 397 // - the frame is showing the initial empty document
405 // - the frame is remote 398 // - the frame is remote
406 bool delaySet = m_world->isMainWorld() 399 bool delaySet = m_world->isMainWorld()
407 && (m_frame->isRemoteFrame() 400 && (origin->domainWasSetInDOM()
408 || origin->domainWasSetInDOM() 401 || m_frame->isRemoteFrame()
409 || toLocalFrame(m_frame)->loader().stateMachine()->isDisplayingIniti alEmptyDocument()); 402 || toLocalFrame(m_frame)->loader().stateMachine()->isDisplayingIniti alEmptyDocument());
410 if (origin && !delaySet) 403 if (origin && !delaySet)
411 token = origin->toString(); 404 token = origin->toString();
412 405
413 // An empty or "null" token means we always have to call 406 // An empty or "null" token means we always have to call
414 // canAccess. The toString method on securityOrigins returns the 407 // canAccess. The toString method on securityOrigins returns the
415 // string "null" for empty security origins and for security 408 // string "null" for empty security origins and for security
416 // origins that should only allow access to themselves. In this 409 // origins that should only allow access to themselves. In this
417 // case, we use the global object as the security token to avoid 410 // case, we use the global object as the security token to avoid
418 // calling canAccess when a script accesses its own objects. 411 // calling canAccess when a script accesses its own objects.
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 510
518 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) 511 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin)
519 { 512 {
520 ASSERT(m_world->isMainWorld()); 513 ASSERT(m_world->isMainWorld());
521 if (!isContextInitialized()) 514 if (!isContextInitialized())
522 return; 515 return;
523 setSecurityToken(origin); 516 setSecurityToken(origin);
524 } 517 }
525 518
526 } // namespace blink 519 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/web/tests/WebFrameTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698