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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 m_scriptState->perContextData()->setActivityLogger(V8DOMActivityLogger::acti vityLogger( | 420 m_scriptState->perContextData()->setActivityLogger(V8DOMActivityLogger::acti vityLogger( |
421 m_world->worldId(), m_frame->isLocalFrame() && toLocalFrame(m_frame)->do cument() ? toLocalFrame(m_frame)->document()->baseURI() : KURL())); | 421 m_world->worldId(), m_frame->isLocalFrame() && toLocalFrame(m_frame)->do cument() ? toLocalFrame(m_frame)->document()->baseURI() : KURL())); |
422 } | 422 } |
423 | 423 |
424 void WindowProxy::setSecurityToken(SecurityOrigin* origin) | 424 void WindowProxy::setSecurityToken(SecurityOrigin* origin) |
425 { | 425 { |
426 // If two tokens are equal, then the SecurityOrigins canAccess each other. | 426 // If two tokens are equal, then the SecurityOrigins canAccess each other. |
427 // If two tokens are not equal, then we have to call canAccess. | 427 // If two tokens are not equal, then we have to call canAccess. |
428 // Note: we can't use the HTTPOrigin if it was set from the DOM. | 428 // Note: we can't use the HTTPOrigin if it was set from the DOM. |
429 String token; | 429 String token; |
430 // There are several situations where v8 needs to do a full canAccess check, | 430 // There are two situations where v8 needs to do a full canAccess check, |
431 // so set an empty security token instead: | 431 // so set an empty security token instead: |
432 // - document.domain was modified | 432 // - document.domain was modified |
433 // - the frame is showing the initial empty document | |
434 // - the frame is remote | 433 // - the frame is remote |
435 bool delaySet = m_frame->isRemoteFrame() || (m_world->isMainWorld() && (orig in->domainWasSetInDOM() || toLocalFrame(m_frame)->loader().stateMachine()->isDis playingInitialEmptyDocument())); | 434 bool delaySet = m_frame->isRemoteFrame() || (m_world->isMainWorld() && origi n->domainWasSetInDOM()); |
dcheng
2016/08/18 00:45:12
Note: I'm not actually sure why the second part of
| |
436 if (origin && !delaySet) | 435 if (origin && !delaySet) |
437 token = origin->toString(); | 436 token = origin->toString(); |
438 | 437 |
439 // An empty or "null" token means we always have to call | 438 // An empty or "null" token means we always have to call |
440 // canAccess. The toString method on securityOrigins returns the | 439 // canAccess. The toString method on securityOrigins returns the |
441 // string "null" for empty security origins and for security | 440 // string "null" for empty security origins and for security |
442 // origins that should only allow access to themselves. In this | 441 // origins that should only allow access to themselves. In this |
443 // case, we use the global object as the security token to avoid | 442 // case, we use the global object as the security token to avoid |
444 // calling canAccess when a script accesses its own objects. | 443 // calling canAccess when a script accesses its own objects. |
445 v8::HandleScope handleScope(m_isolate); | 444 v8::HandleScope handleScope(m_isolate); |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 } | 553 } |
555 | 554 |
556 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) | 555 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) |
557 { | 556 { |
558 if (!isContextInitialized()) | 557 if (!isContextInitialized()) |
559 return; | 558 return; |
560 setSecurityToken(origin); | 559 setSecurityToken(origin); |
561 } | 560 } |
562 | 561 |
563 } // namespace blink | 562 } // namespace blink |
OLD | NEW |