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

Side by Side Diff: third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp

Issue 2005433002: [Origin Trials] Install origin trial bindings on V8 context conditionally (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@track-ef-install
Patch Set: Change navigator.storage from RuntimeEnabled to OriginTrialEnabled Created 4 years, 7 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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 18 matching lines...) Expand all
29 #include "bindings/core/v8/SerializedScriptValueFactory.h" 29 #include "bindings/core/v8/SerializedScriptValueFactory.h"
30 #include "bindings/core/v8/V8ArrayBuffer.h" 30 #include "bindings/core/v8/V8ArrayBuffer.h"
31 #include "bindings/core/v8/V8ArrayBufferView.h" 31 #include "bindings/core/v8/V8ArrayBufferView.h"
32 #include "bindings/core/v8/V8Binding.h" 32 #include "bindings/core/v8/V8Binding.h"
33 #include "bindings/core/v8/V8Blob.h" 33 #include "bindings/core/v8/V8Blob.h"
34 #include "bindings/core/v8/V8DOMStringList.h" 34 #include "bindings/core/v8/V8DOMStringList.h"
35 #include "bindings/core/v8/V8File.h" 35 #include "bindings/core/v8/V8File.h"
36 #include "bindings/core/v8/V8Uint8Array.h" 36 #include "bindings/core/v8/V8Uint8Array.h"
37 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 37 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
38 #include "bindings/modules/v8/ToV8ForModules.h" 38 #include "bindings/modules/v8/ToV8ForModules.h"
39 #include "bindings/modules/v8/V8DedicatedWorkerGlobalScopePartial.h"
39 #include "bindings/modules/v8/V8IDBCursor.h" 40 #include "bindings/modules/v8/V8IDBCursor.h"
40 #include "bindings/modules/v8/V8IDBCursorWithValue.h" 41 #include "bindings/modules/v8/V8IDBCursorWithValue.h"
41 #include "bindings/modules/v8/V8IDBDatabase.h" 42 #include "bindings/modules/v8/V8IDBDatabase.h"
42 #include "bindings/modules/v8/V8IDBIndex.h" 43 #include "bindings/modules/v8/V8IDBIndex.h"
43 #include "bindings/modules/v8/V8IDBKeyRange.h" 44 #include "bindings/modules/v8/V8IDBKeyRange.h"
44 #include "bindings/modules/v8/V8IDBObjectStore.h" 45 #include "bindings/modules/v8/V8IDBObjectStore.h"
46 #include "bindings/modules/v8/V8NavigatorPartial.h"
47 #include "bindings/modules/v8/V8ServiceWorkerGlobalScope.h"
48 #include "bindings/modules/v8/V8SharedWorkerGlobalScopePartial.h"
49 #include "bindings/modules/v8/V8WindowPartial.h"
45 #include "bindings/modules/v8/V8WorkletGlobalScope.h" 50 #include "bindings/modules/v8/V8WorkletGlobalScope.h"
46 #include "core/dom/DOMArrayBuffer.h" 51 #include "core/dom/DOMArrayBuffer.h"
47 #include "core/dom/DOMArrayBufferView.h" 52 #include "core/dom/DOMArrayBufferView.h"
48 #include "core/dom/ExecutionContext.h" 53 #include "core/dom/ExecutionContext.h"
54 #include "core/origin_trials/OriginTrialContext.h"
49 #include "modules/indexeddb/IDBKey.h" 55 #include "modules/indexeddb/IDBKey.h"
50 #include "modules/indexeddb/IDBKeyPath.h" 56 #include "modules/indexeddb/IDBKeyPath.h"
51 #include "modules/indexeddb/IDBKeyRange.h" 57 #include "modules/indexeddb/IDBKeyRange.h"
52 #include "modules/indexeddb/IDBTracing.h" 58 #include "modules/indexeddb/IDBTracing.h"
53 #include "modules/indexeddb/IDBValue.h" 59 #include "modules/indexeddb/IDBValue.h"
54 #include "modules/worklet/WorkletGlobalScope.h" 60 #include "modules/worklet/WorkletGlobalScope.h"
55 #include "platform/RuntimeEnabledFeatures.h" 61 #include "platform/RuntimeEnabledFeatures.h"
56 #include "platform/SharedBuffer.h" 62 #include "platform/SharedBuffer.h"
57 #include "wtf/MathExtras.h" 63 #include "wtf/MathExtras.h"
58 #include "wtf/Vector.h" 64 #include "wtf/Vector.h"
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 if (context.IsEmpty()) 531 if (context.IsEmpty())
526 return nullptr; 532 return nullptr;
527 v8::Local<v8::Object> global = context->Global(); 533 v8::Local<v8::Object> global = context->Global();
528 v8::Local<v8::Object> workletWrapper = V8WorkletGlobalScope::findInstanceInP rototypeChain(global, context->GetIsolate()); 534 v8::Local<v8::Object> workletWrapper = V8WorkletGlobalScope::findInstanceInP rototypeChain(global, context->GetIsolate());
529 if (!workletWrapper.IsEmpty()) 535 if (!workletWrapper.IsEmpty())
530 return V8WorkletGlobalScope::toImpl(workletWrapper); 536 return V8WorkletGlobalScope::toImpl(workletWrapper);
531 // FIXME: Is this line of code reachable? 537 // FIXME: Is this line of code reachable?
532 return nullptr; 538 return nullptr;
533 } 539 }
534 540
541 namespace {
542 initializeOriginTrialsFunction s_originalInitializeOriginTrialsFunction = nullpt r;
543 }
544
545 void initializeOriginTrialsForModules(v8::Local<v8::Context> context, const DOMW rapperWorld& world)
546 {
547 DCHECK(!context.IsEmpty());
548 (*s_originalInitializeOriginTrialsFunction)(context, world);
549 context->Enter();
550
551 ExecutionContext* executionContext = toExecutionContext(context);
552 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC ontext, OriginTrialContext::DontCreateIfNotExists);
553 if (!originTrialContext)
554 return;
555
556 v8::Local<v8::Object> global = context->Global();
557 v8::Isolate* isolate = context->GetIsolate();
558 v8::Local<v8::Function> interface = v8::Function::New(context, nullptr).ToLo calChecked();
559
560 if (originTrialContext->isFeatureEnabled("DurableStorage", nullptr) && !orig inTrialContext->featureBindingsInstalled("DurableStorage")) {
chasej 2016/05/20 20:18:14 Add a comment/TODO that this will eventually be ge
chasej 2016/05/20 20:18:14 Should this check if the bindings have been instal
iclelland 2016/05/26 17:09:21 Done.
iclelland 2016/05/26 17:09:21 Done. Also in WebCoreTestSupport.cpp
561 if (executionContext->isDocument()) {
562 v8::Local<v8::String> navigatorName = v8::String::NewFromUtf8(isolat e, "navigator", v8::NewStringType::kNormal).ToLocalChecked();
563 v8::Local<v8::Object> navigator = global->Get(context, navigatorName ).ToLocalChecked()->ToObject();
564 V8WindowPartial::installDurableStorage(isolate, world, global, inter face);
565 V8NavigatorPartial::installDurableStorage(isolate, world, navigator, interface);
566 } else if (executionContext->isSharedWorkerGlobalScope()) {
567 V8SharedWorkerGlobalScopePartial::installDurableStorage(isolate, wor ld, global, interface);
568 } else if (executionContext->isDedicatedWorkerGlobalScope()) {
569 V8DedicatedWorkerGlobalScopePartial::installDurableStorage(isolate, world, global, interface);
570 } else if (executionContext->isServiceWorkerGlobalScope()) {
571 V8ServiceWorkerGlobalScope::installDurableStorage(isolate, world, gl obal, interface);
572 }
573 originTrialContext->setFeatureBindingsInstalled("DurableStorage");
574 }
575 context->Exit();
576 }
577
578 void registerInitializeOriginTrialsForModules()
579 {
580 s_originalInitializeOriginTrialsFunction = setInitializeOriginTrialsFunction (&initializeOriginTrialsForModules);
581 }
535 } // namespace blink 582 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698