| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 v8::Local<v8::Context> context = m_scriptState->context(); | 126 v8::Local<v8::Context> context = m_scriptState->context(); |
| 127 if (m_globalProxy.isEmpty()) { | 127 if (m_globalProxy.isEmpty()) { |
| 128 m_globalProxy.set(isolate(), context->Global()); | 128 m_globalProxy.set(isolate(), context->Global()); |
| 129 CHECK(!m_globalProxy.isEmpty()); | 129 CHECK(!m_globalProxy.isEmpty()); |
| 130 } | 130 } |
| 131 | 131 |
| 132 setupWindowPrototypeChain(); | 132 setupWindowPrototypeChain(); |
| 133 | 133 |
| 134 SecurityOrigin* origin = 0; | 134 SecurityOrigin* origin = 0; |
| 135 if (m_world->isMainWorld()) { | 135 if (m_world->isMainWorld()) { |
| 136 // ActivityLogger for main world is updated within updateDocument(). | 136 // ActivityLogger for main world is updated within updateDocumentInternal(). |
| 137 updateDocument(); | 137 updateDocumentInternal(); |
| 138 origin = frame()->document()->getSecurityOrigin(); | 138 origin = frame()->document()->getSecurityOrigin(); |
| 139 // FIXME: Can this be removed when CSP moves to browser? | 139 // FIXME: Can this be removed when CSP moves to browser? |
| 140 ContentSecurityPolicy* csp = frame()->document()->contentSecurityPolicy(); | 140 ContentSecurityPolicy* csp = frame()->document()->contentSecurityPolicy(); |
| 141 context->AllowCodeGenerationFromStrings( | 141 context->AllowCodeGenerationFromStrings( |
| 142 csp->allowEval(0, SecurityViolationReportingPolicy::SuppressReporting)); | 142 csp->allowEval(0, SecurityViolationReportingPolicy::SuppressReporting)); |
| 143 context->SetErrorMessageForCodeGenerationFromStrings( | 143 context->SetErrorMessageForCodeGenerationFromStrings( |
| 144 v8String(isolate(), csp->evalDisabledErrorMessage())); | 144 v8String(isolate(), csp->evalDisabledErrorMessage())); |
| 145 } else { | 145 } else { |
| 146 updateActivityLogger(); | 146 updateActivityLogger(); |
| 147 origin = m_world->isolatedWorldSecurityOrigin(); | 147 origin = m_world->isolatedWorldSecurityOrigin(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // as the security token. | 309 // as the security token. |
| 310 context->SetSecurityToken(v8AtomicString(isolate(), token)); | 310 context->SetSecurityToken(v8AtomicString(isolate(), token)); |
| 311 } | 311 } |
| 312 | 312 |
| 313 void LocalWindowProxy::updateDocument() { | 313 void LocalWindowProxy::updateDocument() { |
| 314 DCHECK(m_world->isMainWorld()); | 314 DCHECK(m_world->isMainWorld()); |
| 315 // For an uninitialized main window proxy, there's nothing we need | 315 // For an uninitialized main window proxy, there's nothing we need |
| 316 // to update. The update is done when the window proxy gets initialized later. | 316 // to update. The update is done when the window proxy gets initialized later. |
| 317 if (m_lifecycle == Lifecycle::ContextUninitialized) | 317 if (m_lifecycle == Lifecycle::ContextUninitialized) |
| 318 return; | 318 return; |
| 319 // TODO(yukishiino): Is it okay to not update document when the context | 319 |
| 320 // is detached? It's not trivial to fix this because udpateDocumentProperty | 320 // If this WindowProxy was previously initialized, reinitialize it now to |
| 321 // requires a not-yet-detached context to instantiate a document wrapper. | 321 // preserve JS object identity. Otherwise, extant references to the |
| 322 if (m_lifecycle == Lifecycle::ContextDetached) | 322 // WindowProxy will be broken. |
| 323 if (m_lifecycle == Lifecycle::ContextDetached) { |
| 324 initialize(); |
| 325 DCHECK_EQ(Lifecycle::ContextInitialized, m_lifecycle); |
| 326 // Initialization internally updates the document properties, so just |
| 327 // return afterwards. |
| 323 return; | 328 return; |
| 329 } |
| 324 | 330 |
| 331 updateDocumentInternal(); |
| 332 } |
| 333 |
| 334 void LocalWindowProxy::updateDocumentInternal() { |
| 325 updateActivityLogger(); | 335 updateActivityLogger(); |
| 326 updateDocumentProperty(); | 336 updateDocumentProperty(); |
| 327 updateSecurityOrigin(frame()->document()->getSecurityOrigin()); | 337 updateSecurityOrigin(frame()->document()->getSecurityOrigin()); |
| 328 } | 338 } |
| 329 | 339 |
| 330 static v8::Local<v8::Value> getNamedProperty( | 340 static v8::Local<v8::Value> getNamedProperty( |
| 331 HTMLDocument* htmlDocument, | 341 HTMLDocument* htmlDocument, |
| 332 const AtomicString& key, | 342 const AtomicString& key, |
| 333 v8::Local<v8::Object> creationContext, | 343 v8::Local<v8::Object> creationContext, |
| 334 v8::Isolate* isolate) { | 344 v8::Isolate* isolate) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 | 438 |
| 429 setSecurityToken(origin); | 439 setSecurityToken(origin); |
| 430 } | 440 } |
| 431 | 441 |
| 432 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, | 442 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, |
| 433 LocalFrame& frame, | 443 LocalFrame& frame, |
| 434 RefPtr<DOMWrapperWorld> world) | 444 RefPtr<DOMWrapperWorld> world) |
| 435 : WindowProxy(isolate, frame, std::move(world)) {} | 445 : WindowProxy(isolate, frame, std::move(world)) {} |
| 436 | 446 |
| 437 } // namespace blink | 447 } // namespace blink |
| OLD | NEW |