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

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

Issue 2555653002: [WIP Prototype] ES6 https://html.spec.whatwg.org/#fetch-a-single-module-script implementation (Closed)
Patch Set: ModuleScriptLoaderTest Created 3 years, 11 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 28 matching lines...) Expand all
39 #include "bindings/core/v8/V8Document.h" 39 #include "bindings/core/v8/V8Document.h"
40 #include "bindings/core/v8/V8GCForContextDispose.h" 40 #include "bindings/core/v8/V8GCForContextDispose.h"
41 #include "bindings/core/v8/V8HTMLCollection.h" 41 #include "bindings/core/v8/V8HTMLCollection.h"
42 #include "bindings/core/v8/V8HTMLDocument.h" 42 #include "bindings/core/v8/V8HTMLDocument.h"
43 #include "bindings/core/v8/V8HiddenValue.h" 43 #include "bindings/core/v8/V8HiddenValue.h"
44 #include "bindings/core/v8/V8Initializer.h" 44 #include "bindings/core/v8/V8Initializer.h"
45 #include "bindings/core/v8/V8ObjectConstructor.h" 45 #include "bindings/core/v8/V8ObjectConstructor.h"
46 #include "bindings/core/v8/V8PagePopupControllerBinding.h" 46 #include "bindings/core/v8/V8PagePopupControllerBinding.h"
47 #include "bindings/core/v8/V8PrivateProperty.h" 47 #include "bindings/core/v8/V8PrivateProperty.h"
48 #include "bindings/core/v8/V8Window.h" 48 #include "bindings/core/v8/V8Window.h"
49 #include "core/dom/Modulator.h"
49 #include "core/frame/LocalFrame.h" 50 #include "core/frame/LocalFrame.h"
50 #include "core/frame/csp/ContentSecurityPolicy.h" 51 #include "core/frame/csp/ContentSecurityPolicy.h"
51 #include "core/html/DocumentNameCollection.h" 52 #include "core/html/DocumentNameCollection.h"
52 #include "core/html/HTMLCollection.h" 53 #include "core/html/HTMLCollection.h"
53 #include "core/html/HTMLIFrameElement.h" 54 #include "core/html/HTMLIFrameElement.h"
54 #include "core/inspector/InspectorInstrumentation.h" 55 #include "core/inspector/InspectorInstrumentation.h"
55 #include "core/inspector/MainThreadDebugger.h" 56 #include "core/inspector/MainThreadDebugger.h"
56 #include "core/loader/DocumentLoader.h" 57 #include "core/loader/DocumentLoader.h"
57 #include "core/loader/FrameLoader.h" 58 #include "core/loader/FrameLoader.h"
58 #include "core/loader/FrameLoaderClient.h" 59 #include "core/loader/FrameLoaderClient.h"
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 403
403 void WindowProxy::updateActivityLogger() { 404 void WindowProxy::updateActivityLogger() {
404 m_scriptState->perContextData()->setActivityLogger( 405 m_scriptState->perContextData()->setActivityLogger(
405 V8DOMActivityLogger::activityLogger( 406 V8DOMActivityLogger::activityLogger(
406 m_world->worldId(), 407 m_world->worldId(),
407 m_frame->isLocalFrame() && toLocalFrame(m_frame)->document() 408 m_frame->isLocalFrame() && toLocalFrame(m_frame)->document()
408 ? toLocalFrame(m_frame)->document()->baseURI() 409 ? toLocalFrame(m_frame)->document()->baseURI()
409 : KURL())); 410 : KURL()));
410 } 411 }
411 412
413 void WindowProxy::updateModuleResolver() {
414 if (!m_frame->isLocalFrame())
415 return;
416 if (Document* document = toLocalFrame(m_frame)->document()) {
417 if (Modulator* modulator = document->ensureModulator()) {
haraken 2017/01/06 05:47:58 I'm wondering if Modulator is a per-document thing
kouhei (in TOK) 2017/01/11 01:41:57 Done.
418 m_scriptState->perContextData()->setModuleResolver(
419 modulator->scriptModuleResolver());
420 }
421 }
422 }
423
412 void WindowProxy::setSecurityToken(SecurityOrigin* origin) { 424 void WindowProxy::setSecurityToken(SecurityOrigin* origin) {
413 // If two tokens are equal, then the SecurityOrigins canAccess each other. 425 // If two tokens are equal, then the SecurityOrigins canAccess each other.
414 // If two tokens are not equal, then we have to call canAccess. 426 // If two tokens are not equal, then we have to call canAccess.
415 // Note: we can't use the HTTPOrigin if it was set from the DOM. 427 // Note: we can't use the HTTPOrigin if it was set from the DOM.
416 String token; 428 String token;
417 // There are two situations where v8 needs to do a full canAccess check, 429 // There are two situations where v8 needs to do a full canAccess check,
418 // so set an empty security token instead: 430 // so set an empty security token instead:
419 // - document.domain was modified 431 // - document.domain was modified
420 // - the frame is remote 432 // - the frame is remote
421 bool delaySet = m_frame->isRemoteFrame() || 433 bool delaySet = m_frame->isRemoteFrame() ||
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 // as the security token. 469 // as the security token.
458 context->SetSecurityToken(v8AtomicString(m_isolate, token)); 470 context->SetSecurityToken(v8AtomicString(m_isolate, token));
459 } 471 }
460 472
461 void WindowProxy::updateDocument() { 473 void WindowProxy::updateDocument() {
462 DCHECK(m_world->isMainWorld()); 474 DCHECK(m_world->isMainWorld());
463 if (!isContextInitialized()) 475 if (!isContextInitialized())
464 return; 476 return;
465 477
466 updateActivityLogger(); 478 updateActivityLogger();
479 updateModuleResolver();
467 updateDocumentProperty(); 480 updateDocumentProperty();
468 updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin()); 481 updateSecurityOrigin(m_frame->securityContext()->getSecurityOrigin());
469 } 482 }
470 483
471 static v8::Local<v8::Value> getNamedProperty( 484 static v8::Local<v8::Value> getNamedProperty(
472 HTMLDocument* htmlDocument, 485 HTMLDocument* htmlDocument,
473 const AtomicString& key, 486 const AtomicString& key,
474 v8::Local<v8::Object> creationContext, 487 v8::Local<v8::Object> creationContext,
475 v8::Isolate* isolate) { 488 v8::Isolate* isolate) {
476 if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key)) 489 if (!htmlDocument->hasNamedItem(key) && !htmlDocument->hasExtraNamedItem(key))
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 .ToChecked(); 563 .ToChecked();
551 } 564 }
552 565
553 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { 566 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) {
554 if (!isContextInitialized()) 567 if (!isContextInitialized())
555 return; 568 return;
556 setSecurityToken(origin); 569 setSecurityToken(origin);
557 } 570 }
558 571
559 } // namespace blink 572 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698