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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp

Issue 1880933002: Begin to enable extension APIs in Extension Service Worker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync @tott 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_message_start.h ('k') | third_party/WebKit/public/platform/Platform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp b/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
index 5d73eba912b751c4202c91332a6d521c214e076a..1e3265bbcaa58e992fa4679f539bea9783f709fd 100644
--- a/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/WorkerOrWorkletScriptController.cpp
@@ -31,6 +31,7 @@
#include "bindings/core/v8/WorkerOrWorkletScriptController.h"
#include "bindings/core/v8/ScriptCallStack.h"
+#include "bindings/core/v8/ScriptController.h"
#include "bindings/core/v8/ScriptSourceCode.h"
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/V8DedicatedWorkerGlobalScope.h"
@@ -165,8 +166,18 @@ bool WorkerOrWorkletScriptController::initializeContextIfNeeded()
v8::Local<v8::ObjectTemplate> globalTemplate = globalInterfaceTemplate->InstanceTemplate();
v8::Local<v8::Context> context;
{
+ // Initialize V8 extensions before creating the context.
+ Vector<const char*> extensionNames;
+ if (m_globalScope->isServiceWorkerGlobalScope() && Platform::current()->allowScriptExtensionForServiceWorker(toWorkerGlobalScope(m_globalScope.get())->url())) {
+ const V8Extensions& extensions = ScriptController::registeredExtensions();
+ extensionNames.reserveInitialCapacity(extensions.size());
+ for (const auto* extension : extensions)
+ extensionNames.append(extension->name());
+ }
+ v8::ExtensionConfiguration extensionConfiguration(extensionNames.size(), extensionNames.data());
+
V8PerIsolateData::UseCounterDisabledScope useCounterDisabled(V8PerIsolateData::from(m_isolate));
- context = v8::Context::New(m_isolate, nullptr, globalTemplate);
+ context = v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate);
}
if (context.IsEmpty())
return false;
« no previous file with comments | « ipc/ipc_message_start.h ('k') | third_party/WebKit/public/platform/Platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698