OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 5 #ifndef CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
6 #define CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 6 #define CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 void OnExtensionResponse(int request_id, | 115 void OnExtensionResponse(int request_id, |
116 bool success, | 116 bool success, |
117 const base::ListValue& response, | 117 const base::ListValue& response, |
118 const std::string& error); | 118 const std::string& error); |
119 | 119 |
120 // Checks that the current context contains an extension that has permission | 120 // Checks that the current context contains an extension that has permission |
121 // to execute the specified function. If it does not, a v8 exception is thrown | 121 // to execute the specified function. If it does not, a v8 exception is thrown |
122 // and the method returns false. Otherwise returns true. | 122 // and the method returns false. Otherwise returns true. |
123 bool CheckCurrentContextAccessToExtensionAPI( | 123 bool CheckContextAccessToExtensionAPI( |
124 const std::string& function_name) const; | 124 const std::string& function_name, ChromeV8Context* context) const; |
125 | 125 |
126 private: | 126 private: |
127 friend class RenderViewTest; | 127 friend class RenderViewTest; |
128 typedef void (*BindingInstaller)(ModuleSystem* module_system, | 128 typedef void (*BindingInstaller)(ModuleSystem* module_system, |
129 v8::Handle<v8::Object> chrome, | 129 v8::Handle<v8::Object> chrome, |
130 v8::Handle<v8::Object> chrome_hidden); | 130 v8::Handle<v8::Object> chrome_hidden); |
131 | 131 |
132 // RenderProcessObserver implementation: | 132 // RenderProcessObserver implementation: |
133 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 133 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
134 virtual void WebKitInitialized() OVERRIDE; | 134 virtual void WebKitInitialized() OVERRIDE; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 // Sets up the host permissions for |extension|. | 183 // Sets up the host permissions for |extension|. |
184 void InitOriginPermissions(const Extension* extension); | 184 void InitOriginPermissions(const Extension* extension); |
185 void AddOrRemoveOriginPermissions( | 185 void AddOrRemoveOriginPermissions( |
186 UpdatedExtensionPermissionsInfo::Reason reason, | 186 UpdatedExtensionPermissionsInfo::Reason reason, |
187 const Extension* extension, | 187 const Extension* extension, |
188 const URLPatternSet& origins); | 188 const URLPatternSet& origins); |
189 | 189 |
190 void RegisterNativeHandlers(ModuleSystem* module_system, | 190 void RegisterNativeHandlers(ModuleSystem* module_system, |
191 ChromeV8Context* context); | 191 ChromeV8Context* context); |
| 192 void RegisterSchemaGeneratedBindings(ModuleSystem* module_system, |
| 193 ChromeV8Context* context, |
| 194 v8::Handle<v8::Context> v8_context); |
192 | 195 |
193 // Inserts static source code into |source_map_|. | 196 // Inserts static source code into |source_map_|. |
194 void PopulateSourceMap(); | 197 void PopulateSourceMap(); |
195 | 198 |
196 // Inserts BindingInstallers into |lazy_bindings_map_|. | 199 // Inserts BindingInstallers into |lazy_bindings_map_|. |
197 void PopulateLazyBindingsMap(); | 200 void PopulateLazyBindingsMap(); |
198 | 201 |
199 // Sets up the bindings for the given api. | 202 // Sets up the bindings for the given api. |
200 void InstallBindings(ModuleSystem* module_system, | 203 void InstallBindings(ModuleSystem* module_system, |
201 v8::Handle<v8::Context> v8_context, | 204 v8::Handle<v8::Context> v8_context, |
202 const std::string& api); | 205 const std::string& api); |
203 | 206 |
204 // Determines whether |frame| is loading a platform app resource URL. (this | 207 // Determines whether |frame| is loading a platform app resource URL. (this |
205 // evaluates to true for iframes in platform apps and sandboxed resources that | 208 // evaluates to true for iframes in platform apps and sandboxed resources that |
206 // are not in the same origin). | 209 // are not in the same origin). |
207 bool IsWithinPlatformApp(const WebKit::WebFrame* frame); | 210 bool IsWithinPlatformApp(const WebKit::WebFrame* frame); |
208 | 211 |
209 // Returns the Feature::Context type of context for a JavaScript context. | 212 // Returns the Feature::Context type of context for a JavaScript context. |
210 Feature::Context ClassifyJavaScriptContext(const std::string& extension_id, | 213 Feature::Context ClassifyJavaScriptContext(const std::string& extension_id, |
211 int extension_group, | 214 int extension_group, |
212 const ExtensionURLInfo& url_info); | 215 const ExtensionURLInfo& url_info); |
213 | 216 |
| 217 // Gets |field| from |object| or creates it as an empty object if it doesn't |
| 218 // exist. |
| 219 v8::Handle<v8::Object> GetOrCreateObject(v8::Handle<v8::Object> object, |
| 220 const std::string& field); |
| 221 |
214 // True if this renderer is running extensions. | 222 // True if this renderer is running extensions. |
215 bool is_extension_process_; | 223 bool is_extension_process_; |
216 | 224 |
217 // Contains all loaded extensions. This is essentially the renderer | 225 // Contains all loaded extensions. This is essentially the renderer |
218 // counterpart to ExtensionService in the browser. It contains information | 226 // counterpart to ExtensionService in the browser. It contains information |
219 // about all extensions currently loaded by the browser. | 227 // about all extensions currently loaded by the browser. |
220 ExtensionSet extensions_; | 228 ExtensionSet extensions_; |
221 | 229 |
222 // All the bindings contexts that are currently loaded for this renderer. | 230 // All the bindings contexts that are currently loaded for this renderer. |
223 // There is zero or one for each v8 context. | 231 // There is zero or one for each v8 context. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 265 |
258 // Sends API requests to the extension host. | 266 // Sends API requests to the extension host. |
259 scoped_ptr<RequestSender> request_sender_; | 267 scoped_ptr<RequestSender> request_sender_; |
260 | 268 |
261 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 269 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
262 }; | 270 }; |
263 | 271 |
264 } // namespace extensions | 272 } // namespace extensions |
265 | 273 |
266 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 274 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
OLD | NEW |