[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 1 | // Copyright 2014 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 | #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
| 6 | #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
| 7 | |
asargent | 79b64c3 | 2016-08-04 17:17:14 | [diff] [blame] | 8 | #include <memory> |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 9 | #include <string> |
dcheng | e59eca160 | 2015-12-18 17:48:00 | [diff] [blame] | 10 | #include <utility> |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 11 | #include <vector> |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 12 | |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 13 | #include "base/callback.h" |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 14 | #include "base/compiler_specific.h" |
avi | 2d124c0 | 2015-12-23 06:36:42 | [diff] [blame] | 15 | #include "base/macros.h" |
kalman | 0475530 | 2015-09-14 18:52:11 | [diff] [blame] | 16 | #include "base/threading/thread_checker.h" |
Devlin Cronin | fe480ed | 2017-09-15 20:51:11 | [diff] [blame] | 17 | #include "base/unguessable_token.h" |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 18 | #include "extensions/common/features/feature.h" |
rockot | e261b16 | 2014-12-12 01:59:47 | [diff] [blame] | 19 | #include "extensions/common/permissions/api_permission_set.h" |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 20 | #include "extensions/renderer/module_system.h" |
kalman | 33076cb | 2015-08-11 19:12:07 | [diff] [blame] | 21 | #include "extensions/renderer/safe_builtins.h" |
rdevlin.cronin | 0d94256f | 2016-12-09 15:34:23 | [diff] [blame] | 22 | #include "extensions/renderer/script_injection_callback.h" |
Sadrul Habib Chowdhury | 0d7ef9f | 2014-12-03 20:07:30 | [diff] [blame] | 23 | #include "url/gurl.h" |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 24 | #include "v8/include/v8.h" |
| 25 | |
| 26 | namespace blink { |
Dmitry Gozman | 3eac179 | 2019-05-08 23:53:31 | [diff] [blame^] | 27 | class WebDocumentLoader; |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 28 | class WebLocalFrame; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | namespace content { |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 32 | class RenderFrame; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | namespace extensions { |
tbarzic | feb4b05 | 2016-11-29 18:23:09 | [diff] [blame] | 36 | enum class CheckAliasStatus; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 37 | class Extension; |
| 38 | |
kalman | 0475530 | 2015-09-14 18:52:11 | [diff] [blame] | 39 | // Extensions wrapper for a v8::Context. |
| 40 | // |
| 41 | // v8::Contexts can be constructed on any thread, and must only be accessed or |
| 42 | // destroyed that thread. |
| 43 | // |
| 44 | // Note that ScriptContexts bound to worker threads will not have the full |
| 45 | // functionality as those bound to the main RenderThread. |
Devlin Cronin | 86dcc70 | 2019-03-19 15:42:54 | [diff] [blame] | 46 | class ScriptContext { |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 47 | public: |
annekao | 53348222 | 2015-08-21 23:23:53 | [diff] [blame] | 48 | using RunScriptExceptionHandler = base::Callback<void(const v8::TryCatch&)>; |
| 49 | |
tfarina | f85316f | 2015-04-29 17:03:40 | [diff] [blame] | 50 | ScriptContext(const v8::Local<v8::Context>& context, |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 51 | blink::WebLocalFrame* frame, |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 52 | const Extension* extension, |
mek | 7e1d745 | 2014-09-08 23:55:57 | [diff] [blame] | 53 | Feature::Context context_type, |
| 54 | const Extension* effective_extension, |
| 55 | Feature::Context effective_context_type); |
Devlin Cronin | 86dcc70 | 2019-03-19 15:42:54 | [diff] [blame] | 56 | ~ScriptContext(); |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 57 | |
kalman | c81508d | 2015-04-23 17:14:02 | [diff] [blame] | 58 | // Returns whether |url| from any Extension in |extension_set| is sandboxed, |
| 59 | // as declared in each Extension's manifest. |
| 60 | // TODO(kalman): Delete this when crbug.com/466373 is fixed. |
| 61 | // See comment in HasAccessOrThrowError. |
annekao | 6572d5c | 2015-08-19 16:13:36 | [diff] [blame] | 62 | static bool IsSandboxedPage(const GURL& url); |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 63 | |
Devlin Cronin | d9ea834 | 2018-01-27 06:00:04 | [diff] [blame] | 64 | // Initializes |module_system| and associates it with this context. |
| 65 | void SetModuleSystem(std::unique_ptr<ModuleSystem> module_system); |
| 66 | |
Daniel Cheng | 971cd452 | 2017-05-31 21:58:22 | [diff] [blame] | 67 | // Clears the WebLocalFrame for this contexts and invalidates the associated |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 68 | // ModuleSystem. |
| 69 | void Invalidate(); |
| 70 | |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 71 | // Registers |observer| to be run when this context is invalidated. Closures |
| 72 | // are run immediately when Invalidate() is called, not in a message loop. |
Istiaque Ahmed | cf9175a | 2018-09-25 21:52:33 | [diff] [blame] | 73 | void AddInvalidationObserver(base::OnceClosure observer); |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 74 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 75 | // Returns true if this context is still valid, false if it isn't. |
| 76 | // A context becomes invalid via Invalidate(). |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 77 | bool is_valid() const { return is_valid_; } |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 78 | |
tfarina | f85316f | 2015-04-29 17:03:40 | [diff] [blame] | 79 | v8::Local<v8::Context> v8_context() const { |
kalman | 078a219 | 2015-03-09 18:19:39 | [diff] [blame] | 80 | return v8::Local<v8::Context>::New(isolate_, v8_context_); |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | const Extension* extension() const { return extension_.get(); } |
| 84 | |
mek | 7e1d745 | 2014-09-08 23:55:57 | [diff] [blame] | 85 | const Extension* effective_extension() const { |
| 86 | return effective_extension_.get(); |
| 87 | } |
| 88 | |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 89 | blink::WebLocalFrame* web_frame() const { return web_frame_; } |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 90 | |
| 91 | Feature::Context context_type() const { return context_type_; } |
| 92 | |
mek | 7e1d745 | 2014-09-08 23:55:57 | [diff] [blame] | 93 | Feature::Context effective_context_type() const { |
| 94 | return effective_context_type_; |
| 95 | } |
| 96 | |
Devlin Cronin | fe480ed | 2017-09-15 20:51:11 | [diff] [blame] | 97 | const base::UnguessableToken& context_id() const { return context_id_; } |
| 98 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 99 | ModuleSystem* module_system() { return module_system_.get(); } |
| 100 | |
kalman | 33076cb | 2015-08-11 19:12:07 | [diff] [blame] | 101 | SafeBuiltins* safe_builtins() { return &safe_builtins_; } |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 102 | |
kalman | 33076cb | 2015-08-11 19:12:07 | [diff] [blame] | 103 | const SafeBuiltins* safe_builtins() const { return &safe_builtins_; } |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 104 | |
| 105 | // Returns the ID of the extension associated with this context, or empty |
| 106 | // string if there is no such extension. |
[email protected] | 800f987 | 2014-06-12 04:12:51 | [diff] [blame] | 107 | const std::string& GetExtensionID() const; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 108 | |
[email protected] | 2101c4c | 2014-08-22 00:16:16 | [diff] [blame] | 109 | // Returns the RenderFrame associated with this context. Can return NULL if |
| 110 | // the context is in the process of being destroyed. |
| 111 | content::RenderFrame* GetRenderFrame() const; |
| 112 | |
rdevlin.cronin | a9bc8cc | 2016-10-06 15:51:17 | [diff] [blame] | 113 | // Safely calls the v8::Function, respecting the page load deferrer and |
| 114 | // possibly executing asynchronously. |
rdevlin.cronin | 12a457eb | 2016-10-25 20:39:58 | [diff] [blame] | 115 | // Doesn't catch exceptions; callers must do that if they want. |
rdevlin.cronin | 0d94256f | 2016-12-09 15:34:23 | [diff] [blame] | 116 | // USE THESE METHODS RATHER THAN v8::Function::Call WHEREVER POSSIBLE. |
rdevlin.cronin | a9bc8cc | 2016-10-06 15:51:17 | [diff] [blame] | 117 | void SafeCallFunction(const v8::Local<v8::Function>& function, |
| 118 | int argc, |
| 119 | v8::Local<v8::Value> argv[]); |
rdevlin.cronin | 0d94256f | 2016-12-09 15:34:23 | [diff] [blame] | 120 | void SafeCallFunction( |
| 121 | const v8::Local<v8::Function>& function, |
| 122 | int argc, |
| 123 | v8::Local<v8::Value> argv[], |
| 124 | const ScriptInjectionCallback::CompleteCallback& callback); |
rdevlin.cronin | a9bc8cc | 2016-10-06 15:51:17 | [diff] [blame] | 125 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 126 | // Returns the availability of the API |api_name|. |
| 127 | Feature::Availability GetAvailability(const std::string& api_name); |
tbarzic | feb4b05 | 2016-11-29 18:23:09 | [diff] [blame] | 128 | // Returns the availability of the API |api_name|. |
| 129 | // |check_alias| Whether API that has an alias that is available should be |
| 130 | // considered available (even if the API itself is not available). |
| 131 | Feature::Availability GetAvailability(const std::string& api_name, |
| 132 | CheckAliasStatus check_alias); |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 133 | |
| 134 | // Returns a string description of the type of context this is. |
kalman | 8bcbc759 | 2015-06-03 23:12:27 | [diff] [blame] | 135 | std::string GetContextTypeDescription() const; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 136 | |
mek | 7e1d745 | 2014-09-08 23:55:57 | [diff] [blame] | 137 | // Returns a string description of the effective type of context this is. |
kalman | 8bcbc759 | 2015-06-03 23:12:27 | [diff] [blame] | 138 | std::string GetEffectiveContextTypeDescription() const; |
mek | 7e1d745 | 2014-09-08 23:55:57 | [diff] [blame] | 139 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 140 | v8::Isolate* isolate() const { return isolate_; } |
| 141 | |
| 142 | // Get the URL of this context's web frame. |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 143 | // |
| 144 | // TODO(kalman): Remove this and replace with a GetOrigin() call which reads |
Dana Jansens | 7133125 | 2016-03-09 20:57:22 | [diff] [blame] | 145 | // of WebDocument::getSecurityOrigin(): |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 146 | // - The URL can change (e.g. pushState) but the origin cannot. Luckily it |
| 147 | // appears as though callers don't make security decisions based on the |
kalman | 0475530 | 2015-09-14 18:52:11 | [diff] [blame] | 148 | // result of url() so it's not a problem... yet. |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 149 | // - Origin is the correct check to be making. |
| 150 | // - It might let us remove the about:blank resolving? |
kalman | 0475530 | 2015-09-14 18:52:11 | [diff] [blame] | 151 | const GURL& url() const { return url_; } |
| 152 | |
lazyboy | 63b994a | 2017-06-30 21:20:23 | [diff] [blame] | 153 | const GURL& service_worker_scope() const; |
| 154 | |
Istiaque Ahmed | a14ec48 | 2018-08-25 01:02:18 | [diff] [blame] | 155 | int64_t service_worker_version_id() const { |
| 156 | return service_worker_version_id_; |
| 157 | } |
| 158 | |
kalman | 0475530 | 2015-09-14 18:52:11 | [diff] [blame] | 159 | // Sets the URL of this ScriptContext. Usually this will automatically be set |
| 160 | // on construction, unless this isn't constructed with enough information to |
| 161 | // determine the URL (e.g. frame was null). |
| 162 | // TODO(kalman): Make this a constructor parameter (as an origin). |
| 163 | void set_url(const GURL& url) { url_ = url; } |
lazyboy | 63b994a | 2017-06-30 21:20:23 | [diff] [blame] | 164 | void set_service_worker_scope(const GURL& scope) { |
| 165 | service_worker_scope_ = scope; |
| 166 | } |
Istiaque Ahmed | a14ec48 | 2018-08-25 01:02:18 | [diff] [blame] | 167 | void set_service_worker_version_id(int64_t service_worker_version_id) { |
| 168 | service_worker_version_id_ = service_worker_version_id; |
| 169 | } |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 170 | |
tbarzic | feb4b05 | 2016-11-29 18:23:09 | [diff] [blame] | 171 | // Returns whether the API |api| or any part of the API could be available in |
| 172 | // this context without taking into account the context's extension. |
| 173 | // |check_alias| Whether the API should be considered available if it has an |
| 174 | // alias that is available. |
| 175 | bool IsAnyFeatureAvailableToContext(const extensions::Feature& api, |
| 176 | CheckAliasStatus check_alias); |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 177 | |
Dmitry Gozman | 3eac179 | 2019-05-08 23:53:31 | [diff] [blame^] | 178 | // Scope which maps a frame to a document loader. This is used by various |
| 179 | // static methods below, which need to account for "just about to load" |
| 180 | // document when retrieving URL. |
| 181 | class ScopedFrameDocumentLoader { |
| 182 | public: |
| 183 | ScopedFrameDocumentLoader(blink::WebLocalFrame* frame, |
| 184 | blink::WebDocumentLoader* document_loader); |
| 185 | ~ScopedFrameDocumentLoader(); |
| 186 | |
| 187 | private: |
| 188 | blink::WebLocalFrame* frame_; |
| 189 | blink::WebDocumentLoader* document_loader_; |
| 190 | DISALLOW_COPY_AND_ASSIGN(ScopedFrameDocumentLoader); |
| 191 | }; |
| 192 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 193 | // Utility to get the URL we will match against for a frame. If the frame has |
| 194 | // committed, this is the commited URL. Otherwise it is the provisional URL. |
[email protected] | c1abb323 | 2014-07-30 18:28:39 | [diff] [blame] | 195 | // The returned URL may be invalid. |
Takeshi Yoshino | 41b671a | 2017-08-01 12:17:51 | [diff] [blame] | 196 | static GURL GetDocumentLoaderURLForFrame(const blink::WebLocalFrame* frame); |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 197 | |
Takeshi Yoshino | 41b671a | 2017-08-01 12:17:51 | [diff] [blame] | 198 | // Similar to GetDocumentLoaderURLForFrame, but only returns the data source |
| 199 | // URL if the frame's document url is empty and the frame has a security |
| 200 | // origin that allows access to the data source url. |
asargent | 79b64c3 | 2016-08-04 17:17:14 | [diff] [blame] | 201 | // TODO(asargent/devlin) - there may be places that should switch to using |
Takeshi Yoshino | 41b671a | 2017-08-01 12:17:51 | [diff] [blame] | 202 | // this instead of GetDocumentLoaderURLForFrame. |
Daniel Cheng | 971cd452 | 2017-05-31 21:58:22 | [diff] [blame] | 203 | static GURL GetAccessCheckedFrameURL(const blink::WebLocalFrame* frame); |
asargent | 79b64c3 | 2016-08-04 17:17:14 | [diff] [blame] | 204 | |
[email protected] | ae26b28 | 2014-05-15 16:40:16 | [diff] [blame] | 205 | // Returns the first non-about:-URL in the document hierarchy above and |
| 206 | // including |frame|. The document hierarchy is only traversed if |
| 207 | // |document_url| is an about:-URL and if |match_about_blank| is true. |
lukasza | bedb4b2 | 2017-06-23 00:00:13 | [diff] [blame] | 208 | static GURL GetEffectiveDocumentURL(blink::WebLocalFrame* frame, |
[email protected] | ae26b28 | 2014-05-15 16:40:16 | [diff] [blame] | 209 | const GURL& document_url, |
| 210 | bool match_about_blank); |
| 211 | |
rockot | e261b16 | 2014-12-12 01:59:47 | [diff] [blame] | 212 | // Grants a set of content capabilities to this context. |
Devlin Cronin | 32708b0 | 2018-12-05 17:58:04 | [diff] [blame] | 213 | void set_content_capabilities(APIPermissionSet capabilities) { |
| 214 | content_capabilities_ = std::move(capabilities); |
kalman | 0475530 | 2015-09-14 18:52:11 | [diff] [blame] | 215 | } |
rockot | e261b16 | 2014-12-12 01:59:47 | [diff] [blame] | 216 | |
| 217 | // Indicates if this context has an effective API permission either by being |
| 218 | // a context for an extension which has that permission, or by being a web |
| 219 | // context which has been granted the corresponding capability by an |
| 220 | // extension. |
| 221 | bool HasAPIPermission(APIPermission::ID permission) const; |
| 222 | |
kalman | c81508d | 2015-04-23 17:14:02 | [diff] [blame] | 223 | // Throws an Error in this context's JavaScript context, if this context does |
| 224 | // not have access to |name|. Returns true if this context has access (i.e. |
| 225 | // no exception thrown), false if it does not (i.e. an exception was thrown). |
| 226 | bool HasAccessOrThrowError(const std::string& name); |
| 227 | |
kalman | 8bcbc759 | 2015-06-03 23:12:27 | [diff] [blame] | 228 | // Returns a string representation of this ScriptContext, for debugging. |
| 229 | std::string GetDebugString() const; |
| 230 | |
dmazzoni | d6848287c | 2015-07-27 23:41:31 | [diff] [blame] | 231 | // Gets the current stack trace as a multi-line string to be logged. |
| 232 | std::string GetStackTraceAsString() const; |
| 233 | |
annekao | 53348222 | 2015-08-21 23:23:53 | [diff] [blame] | 234 | // Runs |code|, labelling the script that gets created as |name| (the name is |
| 235 | // used in the devtools and stack traces). |exception_handler| will be called |
| 236 | // re-entrantly if an exception is thrown during the script's execution. |
| 237 | v8::Local<v8::Value> RunScript( |
| 238 | v8::Local<v8::String> name, |
| 239 | v8::Local<v8::String> code, |
Leszek Swirski | d148e13 | 2017-11-15 16:50:35 | [diff] [blame] | 240 | const RunScriptExceptionHandler& exception_handler, |
| 241 | v8::ScriptCompiler::NoCacheReason no_cache_reason = |
| 242 | v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason); |
annekao | 53348222 | 2015-08-21 23:23:53 | [diff] [blame] | 243 | |
mlamouri | 60a2857d | 2015-04-14 15:22:36 | [diff] [blame] | 244 | private: |
rdevlin.cronin | cf5482bd | 2017-06-14 13:18:18 | [diff] [blame] | 245 | // DEPRECATED. |
| 246 | v8::Local<v8::Value> CallFunction(const v8::Local<v8::Function>& function, |
| 247 | int argc, |
| 248 | v8::Local<v8::Value> argv[]) const; |
| 249 | |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 250 | // Whether this context is valid. |
| 251 | bool is_valid_; |
| 252 | |
| 253 | // The v8 context the bindings are accessible to. |
| 254 | v8::Global<v8::Context> v8_context_; |
| 255 | |
kalman | f91cb89 | 2015-04-15 19:20:48 | [diff] [blame] | 256 | // The WebLocalFrame associated with this context. This can be NULL because |
| 257 | // this object can outlive is destroyed asynchronously. |
| 258 | blink::WebLocalFrame* web_frame_; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 259 | |
| 260 | // The extension associated with this context, or NULL if there is none. This |
| 261 | // might be a hosted app in the case that this context is hosting a web URL. |
| 262 | scoped_refptr<const Extension> extension_; |
| 263 | |
| 264 | // The type of context. |
| 265 | Feature::Context context_type_; |
| 266 | |
mek | 7e1d745 | 2014-09-08 23:55:57 | [diff] [blame] | 267 | // The effective extension associated with this context, or NULL if there is |
| 268 | // none. This is different from the above extension if this context is in an |
| 269 | // about:blank iframe for example. |
| 270 | scoped_refptr<const Extension> effective_extension_; |
| 271 | |
| 272 | // The type of context. |
| 273 | Feature::Context effective_context_type_; |
| 274 | |
Devlin Cronin | fe480ed | 2017-09-15 20:51:11 | [diff] [blame] | 275 | // A globally-unique ID for the script context. |
| 276 | base::UnguessableToken context_id_; |
| 277 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 278 | // Owns and structures the JS that is injected to set up extension bindings. |
dcheng | f6f8066 | 2016-04-20 20:26:04 | [diff] [blame] | 279 | std::unique_ptr<ModuleSystem> module_system_; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 280 | |
| 281 | // Contains safe copies of builtin objects like Function.prototype. |
kalman | 33076cb | 2015-08-11 19:12:07 | [diff] [blame] | 282 | SafeBuiltins safe_builtins_; |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 283 | |
rockot | e261b16 | 2014-12-12 01:59:47 | [diff] [blame] | 284 | // The set of capabilities granted to this context by extensions. |
| 285 | APIPermissionSet content_capabilities_; |
| 286 | |
Istiaque Ahmed | cf9175a | 2018-09-25 21:52:33 | [diff] [blame] | 287 | // A list of base::OnceClosure instances as an observer interface for |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 288 | // invalidation. |
Istiaque Ahmed | cf9175a | 2018-09-25 21:52:33 | [diff] [blame] | 289 | std::vector<base::OnceClosure> invalidate_observers_; |
kalman | b0c1c50 | 2015-04-15 00:25:06 | [diff] [blame] | 290 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 291 | v8::Isolate* isolate_; |
| 292 | |
Sadrul Habib Chowdhury | 0d7ef9f | 2014-12-03 20:07:30 | [diff] [blame] | 293 | GURL url_; |
| 294 | |
lazyboy | 63b994a | 2017-06-30 21:20:23 | [diff] [blame] | 295 | GURL service_worker_scope_; |
| 296 | |
Istiaque Ahmed | a14ec48 | 2018-08-25 01:02:18 | [diff] [blame] | 297 | int64_t service_worker_version_id_; |
| 298 | |
kalman | 0475530 | 2015-09-14 18:52:11 | [diff] [blame] | 299 | base::ThreadChecker thread_checker_; |
| 300 | |
[email protected] | f55c90ee6 | 2014-04-12 00:50:03 | [diff] [blame] | 301 | DISALLOW_COPY_AND_ASSIGN(ScriptContext); |
| 302 | }; |
| 303 | |
| 304 | } // namespace extensions |
| 305 | |
| 306 | #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |