OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 5 #ifndef EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 6 #define EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "extensions/common/features/feature.h" | 12 #include "extensions/common/features/feature.h" |
13 #include "extensions/common/permissions/api_permission_set.h" | |
13 #include "extensions/renderer/module_system.h" | 14 #include "extensions/renderer/module_system.h" |
14 #include "extensions/renderer/request_sender.h" | 15 #include "extensions/renderer/request_sender.h" |
15 #include "extensions/renderer/safe_builtins.h" | 16 #include "extensions/renderer/safe_builtins.h" |
16 #include "extensions/renderer/scoped_persistent.h" | 17 #include "extensions/renderer/scoped_persistent.h" |
17 #include "gin/runner.h" | 18 #include "gin/runner.h" |
18 #include "url/gurl.h" | 19 #include "url/gurl.h" |
19 #include "v8/include/v8.h" | 20 #include "v8/include/v8.h" |
20 | 21 |
21 namespace blink { | 22 namespace blink { |
22 class WebFrame; | 23 class WebFrame; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
143 | 144 |
144 // gin::Runner overrides. | 145 // gin::Runner overrides. |
145 void Run(const std::string& source, | 146 void Run(const std::string& source, |
146 const std::string& resource_name) override; | 147 const std::string& resource_name) override; |
147 v8::Handle<v8::Value> Call(v8::Handle<v8::Function> function, | 148 v8::Handle<v8::Value> Call(v8::Handle<v8::Function> function, |
148 v8::Handle<v8::Value> receiver, | 149 v8::Handle<v8::Value> receiver, |
149 int argc, | 150 int argc, |
150 v8::Handle<v8::Value> argv[]) override; | 151 v8::Handle<v8::Value> argv[]) override; |
151 gin::ContextHolder* GetContextHolder() override; | 152 gin::ContextHolder* GetContextHolder() override; |
152 | 153 |
154 // Grants a set of content capabilities to this context. | |
155 void SetContentCapabilities(const APIPermissionSet& permissions); | |
156 | |
157 // Indicates if this context has an effective API permission either by being | |
158 // a context for an extension which has that permission, or by being a web | |
159 // context which has been granted the corresponding capability by an | |
160 // extension. | |
161 bool HasEffectiveAPIPermission(APIPermission::ID permission) const; | |
not at google - send to devlin
2014/12/10 17:33:54
What is "Effective" about this?
Ideally we'd call
Ken Rockot(use gerrit already)
2014/12/10 18:31:41
Heh, that's what it was and then I changed it most
| |
162 | |
153 protected: | 163 protected: |
154 // The v8 context the bindings are accessible to. | 164 // The v8 context the bindings are accessible to. |
155 ScopedPersistent<v8::Context> v8_context_; | 165 ScopedPersistent<v8::Context> v8_context_; |
156 | 166 |
157 private: | 167 private: |
158 // The WebFrame associated with this context. This can be NULL because this | 168 // The WebFrame associated with this context. This can be NULL because this |
159 // object can outlive is destroyed asynchronously. | 169 // object can outlive is destroyed asynchronously. |
160 blink::WebFrame* web_frame_; | 170 blink::WebFrame* web_frame_; |
161 | 171 |
162 // The extension associated with this context, or NULL if there is none. This | 172 // The extension associated with this context, or NULL if there is none. This |
(...skipping 10 matching lines...) Expand all Loading... | |
173 | 183 |
174 // The type of context. | 184 // The type of context. |
175 Feature::Context effective_context_type_; | 185 Feature::Context effective_context_type_; |
176 | 186 |
177 // Owns and structures the JS that is injected to set up extension bindings. | 187 // Owns and structures the JS that is injected to set up extension bindings. |
178 scoped_ptr<ModuleSystem> module_system_; | 188 scoped_ptr<ModuleSystem> module_system_; |
179 | 189 |
180 // Contains safe copies of builtin objects like Function.prototype. | 190 // Contains safe copies of builtin objects like Function.prototype. |
181 SafeBuiltins safe_builtins_; | 191 SafeBuiltins safe_builtins_; |
182 | 192 |
193 // The set of capabilities granted to this context by extensions. | |
194 APIPermissionSet content_capabilities_; | |
195 | |
183 v8::Isolate* isolate_; | 196 v8::Isolate* isolate_; |
184 | 197 |
185 GURL url_; | 198 GURL url_; |
186 | 199 |
187 DISALLOW_COPY_AND_ASSIGN(ScriptContext); | 200 DISALLOW_COPY_AND_ASSIGN(ScriptContext); |
188 }; | 201 }; |
189 | 202 |
190 } // namespace extensions | 203 } // namespace extensions |
191 | 204 |
192 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ | 205 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ |
OLD | NEW |