OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "modules/worklet/WorkletGlobalScope.h" | |
6 | |
7 #include "bindings/core/v8/IsolatedScriptController.h" | |
8 | |
9 namespace blink { | |
10 | |
11 // static | |
12 PassRefPtrWillBeRawPtr<WorkletGlobalScope> WorkletGlobalScope::create(const KURL & url, const String& userAgent, v8::Isolate* isolate) | |
13 { | |
14 return adoptRefWillBeNoop(new WorkletGlobalScope(url, userAgent, isolate)); | |
15 } | |
16 | |
17 WorkletGlobalScope::WorkletGlobalScope(const KURL& url, const String& userAgent, v8::Isolate* isolate) | |
18 : m_isolate(isolate) | |
19 , m_script(IsolatedScriptController::create(this, this, m_isolate)) | |
20 { | |
21 } | |
22 | |
23 WorkletGlobalScope::~WorkletGlobalScope() | |
24 { | |
25 } | |
26 | |
27 IsolatedScriptController* WorkletGlobalScope::script() | |
28 { | |
29 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
| |
30 return m_script.get(); | |
31 } | |
32 | |
33 v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Objec t> creationContext) | |
34 { | |
35 // WorkletGlobalScope must never be wrapped with wrap method. The global | |
36 // object of ECMAScript environment is used as the wrapper. | |
37 RELEASE_ASSERT_NOT_REACHED(); | |
38 return v8::Local<v8::Object>(); | |
39 } | |
40 | |
41 v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, con st WrapperTypeInfo*, v8::Local<v8::Object> wrapper) | |
42 { | |
43 RELEASE_ASSERT_NOT_REACHED(); // same as wrap method | |
44 return v8::Local<v8::Object>(); | |
45 } | |
46 | |
47 void WorkletGlobalScope::disableEval(const String& errorMessage) | |
48 { | |
49 m_script->disableEval(errorMessage); | |
50 } | |
51 | |
52 bool WorkletGlobalScope::isSecureContext(String& errorMessage, const SecureConte xtCheck privilegeContextCheck) const | |
53 { | |
54 // Until there are APIs that are available in worklets and that | |
55 // require a privileged context test that checks ancestors, just do | |
56 // a simple check here. | |
57 return securityOrigin()->isPotentiallyTrustworthy(errorMessage); | |
58 } | |
59 | |
60 KURL WorkletGlobalScope::virtualCompleteURL(const String& url) const | |
61 { | |
62 // Always return a null URL when passed a null string. | |
63 // FIXME: Should we change the KURL constructor to have this behavior? | |
64 if (url.isNull()) | |
65 return KURL(); | |
66 // Always use UTF-8 in Worklets. | |
67 return KURL(m_url, url); | |
68 } | |
69 | |
70 DEFINE_TRACE(WorkletGlobalScope) | |
71 { | |
72 #if ENABLE(OILPAN) | |
haraken
2016/01/05 06:08:06
You don't need this #ifdef.
ikilpatrick
2016/01/07 22:47:35
Done.
| |
73 visitor->trace(m_script); | |
74 #endif | |
75 ExecutionContext::trace(visitor); | |
76 SecurityContext::trace(visitor); | |
77 } | |
78 | |
79 } // namespace blink | |
OLD | NEW |