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

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

Issue 2458183002: Eagerly install Origin Trial features on window (Closed)
Patch Set: Use correct context and enter it before installing attributes on window Created 4 years, 1 month 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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "bindings/core/v8/WindowProxy.h" 31 #include "bindings/core/v8/WindowProxy.h"
32 32
33 #include "bindings/core/v8/ConditionalFeatures.h"
33 #include "bindings/core/v8/DOMWrapperWorld.h" 34 #include "bindings/core/v8/DOMWrapperWorld.h"
34 #include "bindings/core/v8/ScriptController.h" 35 #include "bindings/core/v8/ScriptController.h"
35 #include "bindings/core/v8/V8Binding.h" 36 #include "bindings/core/v8/V8Binding.h"
36 #include "bindings/core/v8/V8DOMActivityLogger.h" 37 #include "bindings/core/v8/V8DOMActivityLogger.h"
37 #include "bindings/core/v8/V8Document.h" 38 #include "bindings/core/v8/V8Document.h"
38 #include "bindings/core/v8/V8GCForContextDispose.h" 39 #include "bindings/core/v8/V8GCForContextDispose.h"
39 #include "bindings/core/v8/V8HTMLCollection.h" 40 #include "bindings/core/v8/V8HTMLCollection.h"
40 #include "bindings/core/v8/V8HTMLDocument.h" 41 #include "bindings/core/v8/V8HTMLDocument.h"
41 #include "bindings/core/v8/V8HiddenValue.h" 42 #include "bindings/core/v8/V8HiddenValue.h"
42 #include "bindings/core/v8/V8Initializer.h" 43 #include "bindings/core/v8/V8Initializer.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 context->AllowCodeGenerationFromStrings( 257 context->AllowCodeGenerationFromStrings(
257 csp->allowEval(0, ContentSecurityPolicy::SuppressReport)); 258 csp->allowEval(0, ContentSecurityPolicy::SuppressReport));
258 context->SetErrorMessageForCodeGenerationFromStrings( 259 context->SetErrorMessageForCodeGenerationFromStrings(
259 v8String(m_isolate, csp->evalDisabledErrorMessage())); 260 v8String(m_isolate, csp->evalDisabledErrorMessage()));
260 } else { 261 } else {
261 updateActivityLogger(); 262 updateActivityLogger();
262 origin = m_world->isolatedWorldSecurityOrigin(); 263 origin = m_world->isolatedWorldSecurityOrigin();
263 setSecurityToken(origin); 264 setSecurityToken(origin);
264 } 265 }
265 266
266 // All interfaces must be registered to V8PerContextData.
267 // So we explicitly call constructorForType for the global object.
268 V8PerContextData::from(context)->constructorForType(
269 &V8Window::wrapperTypeInfo);
270
271 if (m_frame->isLocalFrame()) { 267 if (m_frame->isLocalFrame()) {
272 LocalFrame* frame = toLocalFrame(m_frame); 268 LocalFrame* frame = toLocalFrame(m_frame);
273 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame, 269 MainThreadDebugger::instance()->contextCreated(m_scriptState.get(), frame,
274 origin); 270 origin);
275 frame->loader().client()->didCreateScriptContext( 271 frame->loader().client()->didCreateScriptContext(
276 context, m_world->extensionGroup(), m_world->worldId()); 272 context, m_world->extensionGroup(), m_world->worldId());
277 } 273 }
274 // If conditional features for window have been queued before the V8 context
275 // was ready, then inject them into the context now
276 installPendingConditionalFeaturesOnWindow(m_scriptState.get());
haraken 2016/11/03 14:43:07 Just help me understand: Who prevents us from inst
iclelland 2016/11/03 16:00:01 We don't want to do that -- thanks for catching it
277
278 return true; 278 return true;
279 } 279 }
280 280
281 void WindowProxy::createContext() { 281 void WindowProxy::createContext() {
282 // FIXME: This should be a null check of m_frame->client(), but there are 282 // FIXME: This should be a null check of m_frame->client(), but there are
283 // still some edge cases 283 // still some edge cases
284 // that this fails to catch during frame detach. 284 // that this fails to catch during frame detach.
285 if (m_frame->isLocalFrame() && 285 if (m_frame->isLocalFrame() &&
286 !toLocalFrame(m_frame)->loader().documentLoader()) 286 !toLocalFrame(m_frame)->loader().documentLoader())
287 return; 287 return;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 v8String(m_isolate, name)); 577 v8String(m_isolate, name));
578 } 578 }
579 579
580 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) { 580 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) {
581 if (!isContextInitialized()) 581 if (!isContextInitialized())
582 return; 582 return;
583 setSecurityToken(origin); 583 setSecurityToken(origin);
584 } 584 }
585 585
586 } // namespace blink 586 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698