Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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/WorkerOrWorkletScriptController.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_script(WorkerOrWorkletScriptController::create(this, isolate)) | |
| 19 { | |
| 20 m_script->initializeContextIfNeeded(); | |
| 21 } | |
| 22 | |
| 23 WorkletGlobalScope::~WorkletGlobalScope() | |
| 24 { | |
| 25 } | |
| 26 | |
| 27 v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Objec t> creationContext) | |
| 28 { | |
| 29 // WorkletGlobalScope must never be wrapped with wrap method. The global | |
| 30 // object of ECMAScript environment is used as the wrapper. | |
| 31 RELEASE_ASSERT_NOT_REACHED(); | |
| 32 return v8::Local<v8::Object>(); | |
| 33 } | |
| 34 | |
| 35 v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, con st WrapperTypeInfo*, v8::Local<v8::Object> wrapper) | |
| 36 { | |
| 37 RELEASE_ASSERT_NOT_REACHED(); // same as wrap method | |
|
kinuko
2016/01/13 02:59:20
nit: this is probably just copy-pasted, but let's
| |
| 38 return v8::Local<v8::Object>(); | |
| 39 } | |
| 40 | |
| 41 void WorkletGlobalScope::disableEval(const String& errorMessage) | |
| 42 { | |
| 43 m_script->disableEval(errorMessage); | |
| 44 } | |
| 45 | |
| 46 bool WorkletGlobalScope::isSecureContext(String& errorMessage, const SecureConte xtCheck privilegeContextCheck) const | |
| 47 { | |
| 48 // Until there are APIs that are available in worklets and that | |
| 49 // require a privileged context test that checks ancestors, just do | |
| 50 // a simple check here. | |
| 51 return securityOrigin()->isPotentiallyTrustworthy(errorMessage); | |
| 52 } | |
| 53 | |
| 54 KURL WorkletGlobalScope::virtualCompleteURL(const String& url) const | |
| 55 { | |
| 56 // Always return a null URL when passed a null string. | |
| 57 // FIXME(ikilpatrick): Should we change the KURL constructor to have this | |
|
kinuko
2016/01/13 02:59:20
FIXME -> TODO (per our new guideline)?
ikilpatrick
2016/01/13 04:12:29
Done.
| |
| 58 // behavior? | |
| 59 if (url.isNull()) | |
| 60 return KURL(); | |
| 61 // Always use UTF-8 in Worklets. | |
| 62 return KURL(m_url, url); | |
| 63 } | |
| 64 | |
| 65 DEFINE_TRACE(WorkletGlobalScope) | |
| 66 { | |
| 67 visitor->trace(m_script); | |
| 68 ExecutionContext::trace(visitor); | |
| 69 SecurityContext::trace(visitor); | |
| 70 } | |
| 71 | |
| 72 } // namespace blink | |
| OLD | NEW |