OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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) | |
haraken
2016/05/27 00:01:42
This method should take ScriptState. ScriptState c
iclelland
2016/05/27 03:19:43
That's a great idea -- thank you for that!
| |
546 { | |
547 // TODO(iclelland): Generate all of this logic at compile-time, based on the | |
548 // configuration of origin trial enabled attibutes and interfaces in IDL | |
549 // files. (crbug.com/615060) | |
550 DCHECK(!context.IsEmpty()); | |
551 (*s_originalInitializeOriginTrialsFunction)(context, world); | |
552 | |
553 ExecutionContext* executionContext = toExecutionContext(context); | |
554 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC ontext, OriginTrialContext::DontCreateIfNotExists); | |
555 if (!originTrialContext) | |
556 return; | |
557 | |
558 context->Enter(); | |
haraken
2016/05/27 00:01:42
ScriptState::Scope scope(scriptState);
iclelland
2016/05/27 03:19:43
Done.
| |
559 v8::Local<v8::Object> global = context->Global(); | |
560 v8::Isolate* isolate = context->GetIsolate(); | |
561 // TODO(iclelland): This is a placeholder for the real interface object, | |
562 // which we don't try to obtain at this time. (An assertion in the bindings | |
563 // generation code prevents it from actually being used.) It should be | |
564 // replaced with the actual interface if possible, in order to allow origin | |
565 // trials on static attributes. (crbug.com/614352) | |
566 v8::Local<v8::Function> interface = v8::Function::New(context, nullptr).ToLo calChecked(); | |
567 | |
568 if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab led("DurableStorage", nullptr))) { | |
haraken
2016/05/27 00:01:42
Let's drop RuntimeEnableFeatures::durableStorageEn
iclelland
2016/05/27 03:19:43
DurableStorage isn't a runtime-enabled attribute a
| |
569 if (executionContext->isDocument()) { | |
570 v8::Local<v8::String> navigatorName = v8::String::NewFromUtf8(isolat e, "navigator", v8::NewStringType::kNormal).ToLocalChecked(); | |
571 v8::Local<v8::Object> navigator = global->Get(context, navigatorName ).ToLocalChecked()->ToObject(); | |
572 V8WindowPartial::installDurableStorage(isolate, world, global, inter face); | |
573 V8NavigatorPartial::installDurableStorage(isolate, world, navigator, interface); | |
574 } else if (executionContext->isSharedWorkerGlobalScope()) { | |
575 V8SharedWorkerGlobalScopePartial::installDurableStorage(isolate, wor ld, global, interface); | |
576 } else if (executionContext->isDedicatedWorkerGlobalScope()) { | |
577 V8DedicatedWorkerGlobalScopePartial::installDurableStorage(isolate, world, global, interface); | |
578 } else if (executionContext->isServiceWorkerGlobalScope()) { | |
579 V8ServiceWorkerGlobalScope::installDurableStorage(isolate, world, gl obal, interface); | |
580 } | |
581 originTrialContext->setFeatureBindingsInstalled("DurableStorage"); | |
haraken
2016/05/27 00:01:42
Before this CL, how was DurableStorage installed?
iclelland
2016/05/27 03:19:43
In early development, it was [RuntimeEnabled=Durab
| |
582 } | |
583 context->Exit(); | |
584 } | |
585 | |
586 void registerInitializeOriginTrialsForModules() | |
587 { | |
588 s_originalInitializeOriginTrialsFunction = setInitializeOriginTrialsFunction (&initializeOriginTrialsForModules); | |
589 } | |
535 } // namespace blink | 590 } // namespace blink |
OLD | NEW |