Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: extensions/renderer/script_context.h

Issue 831423005: Split out the extensions gin::Runner implementation into a separate class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/module_system_test.cc ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 14 matching lines...) Expand all
25 25
26 namespace content { 26 namespace content {
27 class RenderFrame; 27 class RenderFrame;
28 class RenderView; 28 class RenderView;
29 } 29 }
30 30
31 namespace extensions { 31 namespace extensions {
32 class Extension; 32 class Extension;
33 33
34 // Extensions wrapper for a v8 context. 34 // Extensions wrapper for a v8 context.
35 class ScriptContext : public RequestSender::Source, public gin::Runner { 35 class ScriptContext : public RequestSender::Source {
36 public: 36 public:
37 ScriptContext(const v8::Handle<v8::Context>& context, 37 ScriptContext(const v8::Handle<v8::Context>& context,
38 blink::WebFrame* frame, 38 blink::WebFrame* frame,
39 const Extension* extension, 39 const Extension* extension,
40 Feature::Context context_type, 40 Feature::Context context_type,
41 const Extension* effective_extension, 41 const Extension* effective_extension,
42 Feature::Context effective_context_type); 42 Feature::Context effective_context_type);
43 ~ScriptContext() override; 43 ~ScriptContext() override;
44 44
45 // Clears the WebFrame for this contexts and invalidates the associated 45 // Clears the WebFrame for this contexts and invalidates the associated
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 bool match_about_blank); 135 bool match_about_blank);
136 136
137 // RequestSender::Source implementation. 137 // RequestSender::Source implementation.
138 ScriptContext* GetContext() override; 138 ScriptContext* GetContext() override;
139 void OnResponseReceived(const std::string& name, 139 void OnResponseReceived(const std::string& name,
140 int request_id, 140 int request_id,
141 bool success, 141 bool success,
142 const base::ListValue& response, 142 const base::ListValue& response,
143 const std::string& error) override; 143 const std::string& error) override;
144 144
145 // gin::Runner overrides.
146 void Run(const std::string& source,
147 const std::string& resource_name) override;
148 v8::Handle<v8::Value> Call(v8::Handle<v8::Function> function,
149 v8::Handle<v8::Value> receiver,
150 int argc,
151 v8::Handle<v8::Value> argv[]) override;
152 gin::ContextHolder* GetContextHolder() override;
153
154 // Grants a set of content capabilities to this context. 145 // Grants a set of content capabilities to this context.
155 void SetContentCapabilities(const APIPermissionSet& permissions); 146 void SetContentCapabilities(const APIPermissionSet& permissions);
156 147
157 // Indicates if this context has an effective API permission either by being 148 // 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 149 // 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 150 // context which has been granted the corresponding capability by an
160 // extension. 151 // extension.
161 bool HasAPIPermission(APIPermission::ID permission) const; 152 bool HasAPIPermission(APIPermission::ID permission) const;
162 153
163 protected: 154 protected:
164 // The v8 context the bindings are accessible to. 155 // The v8 context the bindings are accessible to.
165 ScopedPersistent<v8::Context> v8_context_; 156 ScopedPersistent<v8::Context> v8_context_;
166 157
167 private: 158 private:
159 class Runner;
160
168 // The WebFrame associated with this context. This can be NULL because this 161 // The WebFrame associated with this context. This can be NULL because this
169 // object can outlive is destroyed asynchronously. 162 // object can outlive is destroyed asynchronously.
170 blink::WebFrame* web_frame_; 163 blink::WebFrame* web_frame_;
171 164
172 // The extension associated with this context, or NULL if there is none. This 165 // The extension associated with this context, or NULL if there is none. This
173 // might be a hosted app in the case that this context is hosting a web URL. 166 // might be a hosted app in the case that this context is hosting a web URL.
174 scoped_refptr<const Extension> extension_; 167 scoped_refptr<const Extension> extension_;
175 168
176 // The type of context. 169 // The type of context.
177 Feature::Context context_type_; 170 Feature::Context context_type_;
(...skipping 12 matching lines...) Expand all
190 // Contains safe copies of builtin objects like Function.prototype. 183 // Contains safe copies of builtin objects like Function.prototype.
191 SafeBuiltins safe_builtins_; 184 SafeBuiltins safe_builtins_;
192 185
193 // The set of capabilities granted to this context by extensions. 186 // The set of capabilities granted to this context by extensions.
194 APIPermissionSet content_capabilities_; 187 APIPermissionSet content_capabilities_;
195 188
196 v8::Isolate* isolate_; 189 v8::Isolate* isolate_;
197 190
198 GURL url_; 191 GURL url_;
199 192
193 scoped_ptr<Runner> runner_;
194
200 DISALLOW_COPY_AND_ASSIGN(ScriptContext); 195 DISALLOW_COPY_AND_ASSIGN(ScriptContext);
201 }; 196 };
202 197
203 } // namespace extensions 198 } // namespace extensions
204 199
205 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_ 200 #endif // EXTENSIONS_RENDERER_SCRIPT_CONTEXT_H_
OLDNEW
« no previous file with comments | « extensions/renderer/module_system_test.cc ('k') | extensions/renderer/script_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698