| 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 | 250 |
| 251 if (!installDOMWindow()) { | 251 if (!installDOMWindow()) { |
| 252 disposeContext(DoNotDetachGlobal); | 252 disposeContext(DoNotDetachGlobal); |
| 253 return false; | 253 return false; |
| 254 } | 254 } |
| 255 | 255 |
| 256 SecurityOrigin* origin = 0; | 256 SecurityOrigin* origin = 0; |
| 257 if (m_world->isMainWorld()) { | 257 if (m_world->isMainWorld()) { |
| 258 // ActivityLogger for main world is updated within updateDocument(). | 258 // ActivityLogger for main world is updated within updateDocument(). |
| 259 updateDocument(); | 259 updateDocument(); |
| 260 origin = m_frame->securityContext()->securityOrigin(); | 260 origin = m_frame->securityContext()->getSecurityOrigin(); |
| 261 // FIXME: Can this be removed when CSP moves to browser? | 261 // FIXME: Can this be removed when CSP moves to browser? |
| 262 ContentSecurityPolicy* csp = m_frame->securityContext()->contentSecurity
Policy(); | 262 ContentSecurityPolicy* csp = m_frame->securityContext()->contentSecurity
Policy(); |
| 263 context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSecurit
yPolicy::SuppressReport)); | 263 context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSecurit
yPolicy::SuppressReport)); |
| 264 context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate,
csp->evalDisabledErrorMessage())); | 264 context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate,
csp->evalDisabledErrorMessage())); |
| 265 } else { | 265 } else { |
| 266 updateActivityLogger(); | 266 updateActivityLogger(); |
| 267 origin = m_world->isolatedWorldSecurityOrigin(); | 267 origin = m_world->isolatedWorldSecurityOrigin(); |
| 268 setSecurityToken(origin); | 268 setSecurityToken(origin); |
| 269 } | 269 } |
| 270 if (m_frame->isLocalFrame()) { | 270 if (m_frame->isLocalFrame()) { |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 v8::HandleScope handleScope(m_isolate); | 468 v8::HandleScope handleScope(m_isolate); |
| 469 v8::Local<v8::Context> context = m_scriptState->context(); | 469 v8::Local<v8::Context> context = m_scriptState->context(); |
| 470 if (token.isEmpty() || token == "null") { | 470 if (token.isEmpty() || token == "null") { |
| 471 context->UseDefaultSecurityToken(); | 471 context->UseDefaultSecurityToken(); |
| 472 return; | 472 return; |
| 473 } | 473 } |
| 474 | 474 |
| 475 if (m_world->isPrivateScriptIsolatedWorld()) { | 475 if (m_world->isPrivateScriptIsolatedWorld()) { |
| 476 token = "private-script://" + token; | 476 token = "private-script://" + token; |
| 477 } else if (m_world->isIsolatedWorld()) { | 477 } else if (m_world->isIsolatedWorld()) { |
| 478 SecurityOrigin* frameSecurityOrigin = m_frame->securityContext()->securi
tyOrigin(); | 478 SecurityOrigin* frameSecurityOrigin = m_frame->securityContext()->getSec
urityOrigin(); |
| 479 String frameSecurityToken = frameSecurityOrigin->toString(); | 479 String frameSecurityToken = frameSecurityOrigin->toString(); |
| 480 // We need to check the return value of domainWasSetInDOM() on the | 480 // We need to check the return value of domainWasSetInDOM() on the |
| 481 // frame's SecurityOrigin because, if that's the case, only | 481 // frame's SecurityOrigin because, if that's the case, only |
| 482 // SecurityOrigin::m_domain would have been modified. | 482 // SecurityOrigin::m_domain would have been modified. |
| 483 // m_domain is not used by SecurityOrigin::toString(), so we would end | 483 // m_domain is not used by SecurityOrigin::toString(), so we would end |
| 484 // up generating the same token that was already set. | 484 // up generating the same token that was already set. |
| 485 if (frameSecurityOrigin->domainWasSetInDOM() || frameSecurityToken.isEmp
ty() || frameSecurityToken == "null") { | 485 if (frameSecurityOrigin->domainWasSetInDOM() || frameSecurityToken.isEmp
ty() || frameSecurityToken == "null") { |
| 486 context->UseDefaultSecurityToken(); | 486 context->UseDefaultSecurityToken(); |
| 487 return; | 487 return; |
| 488 } | 488 } |
| 489 token = frameSecurityToken + token; | 489 token = frameSecurityToken + token; |
| 490 } | 490 } |
| 491 | 491 |
| 492 CString utf8Token = token.utf8(); | 492 CString utf8Token = token.utf8(); |
| 493 // NOTE: V8 does identity comparison in fast path, must use a symbol | 493 // NOTE: V8 does identity comparison in fast path, must use a symbol |
| 494 // as the security token. | 494 // as the security token. |
| 495 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To
ken.length())); | 495 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To
ken.length())); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void WindowProxy::updateDocument() | 498 void WindowProxy::updateDocument() |
| 499 { | 499 { |
| 500 ASSERT(m_world->isMainWorld()); | 500 ASSERT(m_world->isMainWorld()); |
| 501 if (!isGlobalInitialized()) | 501 if (!isGlobalInitialized()) |
| 502 return; | 502 return; |
| 503 if (!isContextInitialized()) | 503 if (!isContextInitialized()) |
| 504 return; | 504 return; |
| 505 updateActivityLogger(); | 505 updateActivityLogger(); |
| 506 updateDocumentProperty(); | 506 updateDocumentProperty(); |
| 507 updateSecurityOrigin(m_frame->securityContext()->securityOrigin()); | 507 updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin()); |
| 508 } | 508 } |
| 509 | 509 |
| 510 static v8::Local<v8::Value> getNamedProperty(HTMLDocument* htmlDocument, const A
tomicString& key, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) | 510 static v8::Local<v8::Value> getNamedProperty(HTMLDocument* htmlDocument, const A
tomicString& key, v8::Local<v8::Object> creationContext, v8::Isolate* isolate) |
| 511 { | 511 { |
| 512 if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key
)) | 512 if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key
)) |
| 513 return v8Undefined(); | 513 return v8Undefined(); |
| 514 | 514 |
| 515 RefPtrWillBeRawPtr<DocumentNameCollection> items = htmlDocument->documentNam
edItems(key); | 515 RefPtrWillBeRawPtr<DocumentNameCollection> items = htmlDocument->documentNam
edItems(key); |
| 516 if (items->isEmpty()) | 516 if (items->isEmpty()) |
| 517 return v8Undefined(); | 517 return v8Undefined(); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 } | 579 } |
| 580 | 580 |
| 581 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) | 581 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) |
| 582 { | 582 { |
| 583 if (!isContextInitialized()) | 583 if (!isContextInitialized()) |
| 584 return; | 584 return; |
| 585 setSecurityToken(origin); | 585 setSecurityToken(origin); |
| 586 } | 586 } |
| 587 | 587 |
| 588 } // namespace blink | 588 } // namespace blink |
| OLD | NEW |