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 InstallOriginTrialsFunction s_originalInstallOriginTrialsFunction = nullptr; |
| 543 } |
| 544 |
| 545 void installOriginTrialsForModules(ScriptState* scriptState) |
| 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 (*s_originalInstallOriginTrialsFunction)(scriptState); |
| 551 |
| 552 v8::Local<v8::Context> context = scriptState->context(); |
| 553 ExecutionContext* executionContext = toExecutionContext(context); |
| 554 OriginTrialContext* originTrialContext = OriginTrialContext::from(executionC
ontext, OriginTrialContext::DontCreateIfNotExists); |
| 555 if (!originTrialContext) |
| 556 return; |
| 557 |
| 558 ScriptState::Scope scope(scriptState); |
| 559 v8::Local<v8::Object> global = context->Global(); |
| 560 v8::Isolate* isolate = scriptState->isolate(); |
| 561 |
| 562 if (!originTrialContext->featureBindingsInstalled("DurableStorage") && (Runt
imeEnabledFeatures::durableStorageEnabled() || originTrialContext->isFeatureEnab
led("DurableStorage", nullptr))) { |
| 563 if (executionContext->isDocument()) { |
| 564 v8::Local<v8::String> navigatorName = v8::String::NewFromOneByte(iso
late, reinterpret_cast<const uint8_t*>("navigator"), v8::NewStringType::kNormal)
.ToLocalChecked(); |
| 565 v8::Local<v8::Object> navigator = global->Get(context, navigatorName
).ToLocalChecked()->ToObject(); |
| 566 V8WindowPartial::installDurableStorage(scriptState, global); |
| 567 V8NavigatorPartial::installDurableStorage(scriptState, navigator); |
| 568 } else if (executionContext->isSharedWorkerGlobalScope()) { |
| 569 V8SharedWorkerGlobalScopePartial::installDurableStorage(scriptState,
global); |
| 570 } else if (executionContext->isDedicatedWorkerGlobalScope()) { |
| 571 V8DedicatedWorkerGlobalScopePartial::installDurableStorage(scriptSta
te, global); |
| 572 } else if (executionContext->isServiceWorkerGlobalScope()) { |
| 573 V8ServiceWorkerGlobalScope::installDurableStorage(scriptState, globa
l); |
| 574 } |
| 575 originTrialContext->setFeatureBindingsInstalled("DurableStorage"); |
| 576 } |
| 577 } |
| 578 |
| 579 void registerInstallOriginTrialsForModules() |
| 580 { |
| 581 s_originalInstallOriginTrialsFunction = setInstallOriginTrialsFunction(&inst
allOriginTrialsForModules); |
| 582 } |
535 } // namespace blink | 583 } // namespace blink |
OLD | NEW |