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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 return false; | 209 return false; |
210 } | 210 } |
211 } | 211 } |
212 | 212 |
213 if (!m_world->isMainWorld()) { | 213 if (!m_world->isMainWorld()) { |
214 V8WindowShell* mainWindow = m_frame->script().existingWindowShell(DOMWra
pperWorld::mainWorld()); | 214 V8WindowShell* mainWindow = m_frame->script().existingWindowShell(DOMWra
pperWorld::mainWorld()); |
215 if (mainWindow && !mainWindow->context().IsEmpty()) | 215 if (mainWindow && !mainWindow->context().IsEmpty()) |
216 setInjectedScriptContextDebugId(context, m_frame->script().contextDe
bugId(mainWindow->context())); | 216 setInjectedScriptContextDebugId(context, m_frame->script().contextDe
bugId(mainWindow->context())); |
217 } | 217 } |
218 | 218 |
219 m_scriptState->perContextData()->setActivityLogger(V8DOMActivityLogger::acti
vityLogger( | |
220 m_world->worldId(), m_frame->document() ? m_frame->document()->baseURI()
: KURL())); | |
221 if (!installDOMWindow()) { | 219 if (!installDOMWindow()) { |
222 disposeContext(DoNotDetachGlobal); | 220 disposeContext(DoNotDetachGlobal); |
223 return false; | 221 return false; |
224 } | 222 } |
225 | 223 |
226 if (m_world->isMainWorld()) { | 224 if (m_world->isMainWorld()) { |
| 225 // ActivityLogger for main world is updated within updateDocument(). |
227 updateDocument(); | 226 updateDocument(); |
228 if (m_frame->document()) { | 227 if (m_frame->document()) { |
229 setSecurityToken(m_frame->document()->securityOrigin()); | 228 setSecurityToken(m_frame->document()->securityOrigin()); |
230 ContentSecurityPolicy* csp = m_frame->document()->contentSecurityPol
icy(); | 229 ContentSecurityPolicy* csp = m_frame->document()->contentSecurityPol
icy(); |
231 context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSec
urityPolicy::SuppressReport)); | 230 context->AllowCodeGenerationFromStrings(csp->allowEval(0, ContentSec
urityPolicy::SuppressReport)); |
232 context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isol
ate, csp->evalDisabledErrorMessage())); | 231 context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isol
ate, csp->evalDisabledErrorMessage())); |
233 } | 232 } |
234 } else { | 233 } else { |
| 234 updateActivityLogger(); |
235 SecurityOrigin* origin = m_world->isolatedWorldSecurityOrigin(); | 235 SecurityOrigin* origin = m_world->isolatedWorldSecurityOrigin(); |
236 setSecurityToken(origin); | 236 setSecurityToken(origin); |
237 if (origin && InspectorInstrumentation::hasFrontends()) { | 237 if (origin && InspectorInstrumentation::hasFrontends()) { |
238 InspectorInstrumentation::didCreateIsolatedContext(m_frame, m_script
State.get(), origin); | 238 InspectorInstrumentation::didCreateIsolatedContext(m_frame, m_script
State.get(), origin); |
239 } | 239 } |
240 } | 240 } |
241 m_frame->loader().client()->didCreateScriptContext(context, m_world->extensi
onGroup(), m_world->worldId()); | 241 m_frame->loader().client()->didCreateScriptContext(context, m_world->extensi
onGroup(), m_world->worldId()); |
242 return true; | 242 return true; |
243 } | 243 } |
244 | 244 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 | 362 |
363 void V8WindowShell::clearDocumentProperty() | 363 void V8WindowShell::clearDocumentProperty() |
364 { | 364 { |
365 ASSERT(isContextInitialized()); | 365 ASSERT(isContextInitialized()); |
366 if (!m_world->isMainWorld()) | 366 if (!m_world->isMainWorld()) |
367 return; | 367 return; |
368 v8::HandleScope handleScope(m_isolate); | 368 v8::HandleScope handleScope(m_isolate); |
369 m_scriptState->context()->Global()->ForceDelete(v8AtomicString(m_isolate, "d
ocument")); | 369 m_scriptState->context()->Global()->ForceDelete(v8AtomicString(m_isolate, "d
ocument")); |
370 } | 370 } |
371 | 371 |
| 372 void V8WindowShell::updateActivityLogger() |
| 373 { |
| 374 m_scriptState->perContextData()->setActivityLogger(V8DOMActivityLogger::acti
vityLogger( |
| 375 m_world->worldId(), m_frame->document() ? m_frame->document()->baseURI()
: KURL())); |
| 376 } |
| 377 |
372 void V8WindowShell::setSecurityToken(SecurityOrigin* origin) | 378 void V8WindowShell::setSecurityToken(SecurityOrigin* origin) |
373 { | 379 { |
374 // If two tokens are equal, then the SecurityOrigins canAccess each other. | 380 // If two tokens are equal, then the SecurityOrigins canAccess each other. |
375 // If two tokens are not equal, then we have to call canAccess. | 381 // If two tokens are not equal, then we have to call canAccess. |
376 // Note: we can't use the HTTPOrigin if it was set from the DOM. | 382 // Note: we can't use the HTTPOrigin if it was set from the DOM. |
377 String token; | 383 String token; |
378 // We stick with an empty token if document.domain was modified or if we | 384 // We stick with an empty token if document.domain was modified or if we |
379 // are in the initial empty document, so that we can do a full canAccess | 385 // are in the initial empty document, so that we can do a full canAccess |
380 // check in those cases. | 386 // check in those cases. |
381 bool delaySet = m_world->isMainWorld() | 387 bool delaySet = m_world->isMainWorld() |
(...skipping 21 matching lines...) Expand all Loading... |
403 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To
ken.length())); | 409 context->SetSecurityToken(v8AtomicString(m_isolate, utf8Token.data(), utf8To
ken.length())); |
404 } | 410 } |
405 | 411 |
406 void V8WindowShell::updateDocument() | 412 void V8WindowShell::updateDocument() |
407 { | 413 { |
408 ASSERT(m_world->isMainWorld()); | 414 ASSERT(m_world->isMainWorld()); |
409 if (!isGlobalInitialized()) | 415 if (!isGlobalInitialized()) |
410 return; | 416 return; |
411 if (!isContextInitialized()) | 417 if (!isContextInitialized()) |
412 return; | 418 return; |
| 419 updateActivityLogger(); |
413 updateDocumentProperty(); | 420 updateDocumentProperty(); |
414 updateSecurityOrigin(m_frame->document()->securityOrigin()); | 421 updateSecurityOrigin(m_frame->document()->securityOrigin()); |
415 } | 422 } |
416 | 423 |
417 static v8::Handle<v8::Value> getNamedProperty(HTMLDocument* htmlDocument, const
AtomicString& key, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) | 424 static v8::Handle<v8::Value> getNamedProperty(HTMLDocument* htmlDocument, const
AtomicString& key, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) |
418 { | 425 { |
419 if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key
)) | 426 if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key
)) |
420 return v8Undefined(); | 427 return v8Undefined(); |
421 | 428 |
422 RefPtrWillBeRawPtr<HTMLCollection> items = htmlDocument->documentNamedItems(
key); | 429 RefPtrWillBeRawPtr<HTMLCollection> items = htmlDocument->documentNamedItems(
key); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 492 |
486 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin) | 493 void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin) |
487 { | 494 { |
488 ASSERT(m_world->isMainWorld()); | 495 ASSERT(m_world->isMainWorld()); |
489 if (!isContextInitialized()) | 496 if (!isContextInitialized()) |
490 return; | 497 return; |
491 setSecurityToken(origin); | 498 setSecurityToken(origin); |
492 } | 499 } |
493 | 500 |
494 } // WebCore | 501 } // WebCore |
OLD | NEW |