| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 v8::Local<v8::Context> context = m_scriptState->context(); | 94 v8::Local<v8::Context> context = m_scriptState->context(); |
| 95 if (m_globalProxy.isEmpty()) { | 95 if (m_globalProxy.isEmpty()) { |
| 96 m_globalProxy.set(isolate(), context->Global()); | 96 m_globalProxy.set(isolate(), context->Global()); |
| 97 CHECK(!m_globalProxy.isEmpty()); | 97 CHECK(!m_globalProxy.isEmpty()); |
| 98 } | 98 } |
| 99 | 99 |
| 100 setupWindowPrototypeChain(); | 100 setupWindowPrototypeChain(); |
| 101 | 101 |
| 102 SecurityOrigin* origin = 0; | 102 SecurityOrigin* origin = 0; |
| 103 if (m_world->isMainWorld()) { | 103 if (m_world->isMainWorld()) { |
| 104 // ActivityLogger for main world is updated within updateDocument(). | 104 // ActivityLogger for main world is updated within updateDocumentInternal(). |
| 105 updateDocument(); | 105 updateDocumentInternal(); |
| 106 origin = frame()->document()->getSecurityOrigin(); | 106 origin = frame()->document()->getSecurityOrigin(); |
| 107 // FIXME: Can this be removed when CSP moves to browser? | 107 // FIXME: Can this be removed when CSP moves to browser? |
| 108 ContentSecurityPolicy* csp = frame()->document()->contentSecurityPolicy(); | 108 ContentSecurityPolicy* csp = frame()->document()->contentSecurityPolicy(); |
| 109 context->AllowCodeGenerationFromStrings( | 109 context->AllowCodeGenerationFromStrings( |
| 110 csp->allowEval(0, ContentSecurityPolicy::SuppressReport)); | 110 csp->allowEval(0, ContentSecurityPolicy::SuppressReport)); |
| 111 context->SetErrorMessageForCodeGenerationFromStrings( | 111 context->SetErrorMessageForCodeGenerationFromStrings( |
| 112 v8String(isolate(), csp->evalDisabledErrorMessage())); | 112 v8String(isolate(), csp->evalDisabledErrorMessage())); |
| 113 } else { | 113 } else { |
| 114 updateActivityLogger(); | 114 updateActivityLogger(); |
| 115 origin = m_world->isolatedWorldSecurityOrigin(); | 115 origin = m_world->isolatedWorldSecurityOrigin(); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 // as the security token. | 235 // as the security token. |
| 236 context->SetSecurityToken(v8AtomicString(isolate(), token)); | 236 context->SetSecurityToken(v8AtomicString(isolate(), token)); |
| 237 } | 237 } |
| 238 | 238 |
| 239 void LocalWindowProxy::updateDocument() { | 239 void LocalWindowProxy::updateDocument() { |
| 240 DCHECK(m_world->isMainWorld()); | 240 DCHECK(m_world->isMainWorld()); |
| 241 // For an uninitialized main window proxy, there's nothing we need | 241 // For an uninitialized main window proxy, there's nothing we need |
| 242 // to update. The update is done when the window proxy gets initialized later. | 242 // to update. The update is done when the window proxy gets initialized later. |
| 243 if (m_lifecycle == Lifecycle::ContextUninitialized) | 243 if (m_lifecycle == Lifecycle::ContextUninitialized) |
| 244 return; | 244 return; |
| 245 // TODO(yukishiino): Is it okay to not update document when the context | 245 |
| 246 // is detached? It's not trivial to fix this because udpateDocumentProperty | 246 // If this WindowProxy was previously initialized, reinitialize it now to |
| 247 // requires a not-yet-detached context to instantiate a document wrapper. | 247 // preserve JS object identity. Otherwise, extant references to the |
| 248 if (m_lifecycle == Lifecycle::ContextDetached) | 248 // WindowProxy will be broken. |
| 249 if (m_lifecycle == Lifecycle::ContextDetached) { |
| 250 initialize(); |
| 251 DCHECK_EQ(Lifecycle::ContextInitialized, m_lifecycle); |
| 252 // Initialization internally updates the document properties, so just |
| 253 // return afterwards. |
| 249 return; | 254 return; |
| 255 } |
| 250 | 256 |
| 257 updateDocumentInternal(); |
| 258 } |
| 259 |
| 260 void LocalWindowProxy::updateDocumentInternal() { |
| 251 updateActivityLogger(); | 261 updateActivityLogger(); |
| 252 updateDocumentProperty(); | 262 updateDocumentProperty(); |
| 253 updateSecurityOrigin(frame()->document()->getSecurityOrigin()); | 263 updateSecurityOrigin(frame()->document()->getSecurityOrigin()); |
| 254 } | 264 } |
| 255 | 265 |
| 256 static v8::Local<v8::Value> getNamedProperty( | 266 static v8::Local<v8::Value> getNamedProperty( |
| 257 HTMLDocument* htmlDocument, | 267 HTMLDocument* htmlDocument, |
| 258 const AtomicString& key, | 268 const AtomicString& key, |
| 259 v8::Local<v8::Object> creationContext, | 269 v8::Local<v8::Object> creationContext, |
| 260 v8::Isolate* isolate) { | 270 v8::Isolate* isolate) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 | 364 |
| 355 setSecurityToken(origin); | 365 setSecurityToken(origin); |
| 356 } | 366 } |
| 357 | 367 |
| 358 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, | 368 LocalWindowProxy::LocalWindowProxy(v8::Isolate* isolate, |
| 359 LocalFrame& frame, | 369 LocalFrame& frame, |
| 360 RefPtr<DOMWrapperWorld> world) | 370 RefPtr<DOMWrapperWorld> world) |
| 361 : WindowProxy(isolate, frame, std::move(world)) {} | 371 : WindowProxy(isolate, frame, std::move(world)) {} |
| 362 | 372 |
| 363 } // namespace blink | 373 } // namespace blink |
| OLD | NEW |