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

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

Issue 1327263002: Modifies WindowProxy::setSecurityToken so that the frame's SecurityOrigin is taken into account whe… (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update Created 5 years, 3 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
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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 // origins that should only allow access to themselves. In this 447 // origins that should only allow access to themselves. In this
448 // case, we use the global object as the security token to avoid 448 // case, we use the global object as the security token to avoid
449 // calling canAccess when a script accesses its own objects. 449 // calling canAccess when a script accesses its own objects.
450 v8::HandleScope handleScope(m_isolate); 450 v8::HandleScope handleScope(m_isolate);
451 v8::Local<v8::Context> context = m_scriptState->context(); 451 v8::Local<v8::Context> context = m_scriptState->context();
452 if (token.isEmpty() || token == "null") { 452 if (token.isEmpty() || token == "null") {
453 context->UseDefaultSecurityToken(); 453 context->UseDefaultSecurityToken();
454 return; 454 return;
455 } 455 }
456 456
457 if (m_world->isPrivateScriptIsolatedWorld()) 457 if (m_world->isPrivateScriptIsolatedWorld()) {
458 token = "private-script://" + token; 458 token = "private-script://" + token;
459 } else if (m_world->isIsolatedWorld()) {
460 SecurityOrigin* frameSecurityOrigin = m_frame->securityContext()->securi tyOrigin();
461 String frameSecurityToken = frameSecurityOrigin->toString();
462 if (frameSecurityOrigin->domainWasSetInDOM() || frameSecurityToken.isEmp ty() || frameSecurityToken == "null") {
haraken 2015/09/14 15:29:00 Would you help me understand why we need the domai
epertoso 2015/09/14 15:59:37 Added a comment.
463 context->UseDefaultSecurityToken();
464 return;
465 }
466 token = frameSecurityToken + token;
467 }
459 468
460 CString utf8Token = token.utf8(); 469 CString utf8Token = token.utf8();
461 // NOTE: V8 does identity comparison in fast path, must use a symbol 470 // NOTE: V8 does identity comparison in fast path, must use a symbol
462 // as the security token. 471 // as the security token.
463 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To ken.length())); 472 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To ken.length()));
464 } 473 }
465 474
466 void WindowProxy::updateDocument() 475 void WindowProxy::updateDocument()
467 { 476 {
468 ASSERT(m_world->isMainWorld()); 477 ASSERT(m_world->isMainWorld());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 557
549 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) 558 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin)
550 { 559 {
551 ASSERT(m_world->isMainWorld()); 560 ASSERT(m_world->isMainWorld());
552 if (!isContextInitialized()) 561 if (!isContextInitialized())
553 return; 562 return;
554 setSecurityToken(origin); 563 setSecurityToken(origin);
555 } 564 }
556 565
557 } // namespace blink 566 } // namespace blink
OLDNEW
« Source/bindings/core/v8/ScriptController.cpp ('K') | « Source/bindings/core/v8/WindowProxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698