Index: third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp |
diff --git a/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp b/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..88a0ca526a4d8584bef5520f440b19f69151d489 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.cpp |
@@ -0,0 +1,79 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "modules/worklet/WorkletGlobalScope.h" |
+ |
+#include "bindings/core/v8/IsolatedScriptController.h" |
+ |
+namespace blink { |
+ |
+// static |
+PassRefPtrWillBeRawPtr<WorkletGlobalScope> WorkletGlobalScope::create(const KURL& url, const String& userAgent, v8::Isolate* isolate) |
+{ |
+ return adoptRefWillBeNoop(new WorkletGlobalScope(url, userAgent, isolate)); |
+} |
+ |
+WorkletGlobalScope::WorkletGlobalScope(const KURL& url, const String& userAgent, v8::Isolate* isolate) |
+ : m_isolate(isolate) |
+ , m_script(IsolatedScriptController::create(this, this, m_isolate)) |
+{ |
+} |
+ |
+WorkletGlobalScope::~WorkletGlobalScope() |
+{ |
+} |
+ |
+IsolatedScriptController* WorkletGlobalScope::script() |
+{ |
+ m_script->initializeContextIfNeeded(); |
haraken
2016/01/05 06:08:06
Is this a good timing to initialize the context?
ikilpatrick
2016/01/07 22:47:35
I've moved this to constructor at the moment.
A W
|
+ return m_script.get(); |
+} |
+ |
+v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Object> creationContext) |
+{ |
+ // WorkletGlobalScope must never be wrapped with wrap method. The global |
+ // object of ECMAScript environment is used as the wrapper. |
+ RELEASE_ASSERT_NOT_REACHED(); |
+ return v8::Local<v8::Object>(); |
+} |
+ |
+v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, const WrapperTypeInfo*, v8::Local<v8::Object> wrapper) |
+{ |
+ RELEASE_ASSERT_NOT_REACHED(); // same as wrap method |
+ return v8::Local<v8::Object>(); |
+} |
+ |
+void WorkletGlobalScope::disableEval(const String& errorMessage) |
+{ |
+ m_script->disableEval(errorMessage); |
+} |
+ |
+bool WorkletGlobalScope::isSecureContext(String& errorMessage, const SecureContextCheck privilegeContextCheck) const |
+{ |
+ // Until there are APIs that are available in worklets and that |
+ // require a privileged context test that checks ancestors, just do |
+ // a simple check here. |
+ return securityOrigin()->isPotentiallyTrustworthy(errorMessage); |
+} |
+ |
+KURL WorkletGlobalScope::virtualCompleteURL(const String& url) const |
+{ |
+ // Always return a null URL when passed a null string. |
+ // FIXME: Should we change the KURL constructor to have this behavior? |
+ if (url.isNull()) |
+ return KURL(); |
+ // Always use UTF-8 in Worklets. |
+ return KURL(m_url, url); |
+} |
+ |
+DEFINE_TRACE(WorkletGlobalScope) |
+{ |
+#if ENABLE(OILPAN) |
haraken
2016/01/05 06:08:06
You don't need this #ifdef.
ikilpatrick
2016/01/07 22:47:35
Done.
|
+ visitor->trace(m_script); |
+#endif |
+ ExecutionContext::trace(visitor); |
+ SecurityContext::trace(visitor); |
+} |
+ |
+} // namespace blink |