| 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 CheckContextAccessToExtensionAPI( | 123 bool CheckCurrentContextAccessToExtensionAPI( |
| 124 const std::string& function_name, ChromeV8Context* context) const; | 124 const std::string& function_name) 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); | |
| 195 | 192 |
| 196 // Inserts static source code into |source_map_|. | 193 // Inserts static source code into |source_map_|. |
| 197 void PopulateSourceMap(); | 194 void PopulateSourceMap(); |
| 198 | 195 |
| 199 // Inserts BindingInstallers into |lazy_bindings_map_|. | 196 // Inserts BindingInstallers into |lazy_bindings_map_|. |
| 200 void PopulateLazyBindingsMap(); | 197 void PopulateLazyBindingsMap(); |
| 201 | 198 |
| 202 // Sets up the bindings for the given api. | 199 // Sets up the bindings for the given api. |
| 203 void InstallBindings(ModuleSystem* module_system, | 200 void InstallBindings(ModuleSystem* module_system, |
| 204 v8::Handle<v8::Context> v8_context, | 201 v8::Handle<v8::Context> v8_context, |
| 205 const std::string& api); | 202 const std::string& api); |
| 206 | 203 |
| 207 // Determines whether |frame| is loading a platform app resource URL. (this | 204 // Determines whether |frame| is loading a platform app resource URL. (this |
| 208 // evaluates to true for iframes in platform apps and sandboxed resources that | 205 // evaluates to true for iframes in platform apps and sandboxed resources that |
| 209 // are not in the same origin). | 206 // are not in the same origin). |
| 210 bool IsWithinPlatformApp(const WebKit::WebFrame* frame); | 207 bool IsWithinPlatformApp(const WebKit::WebFrame* frame); |
| 211 | 208 |
| 212 // Returns the Feature::Context type of context for a JavaScript context. | 209 // Returns the Feature::Context type of context for a JavaScript context. |
| 213 Feature::Context ClassifyJavaScriptContext(const std::string& extension_id, | 210 Feature::Context ClassifyJavaScriptContext(const std::string& extension_id, |
| 214 int extension_group, | 211 int extension_group, |
| 215 const ExtensionURLInfo& url_info); | 212 const ExtensionURLInfo& url_info); |
| 216 | 213 |
| 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 | |
| 222 // True if this renderer is running extensions. | 214 // True if this renderer is running extensions. |
| 223 bool is_extension_process_; | 215 bool is_extension_process_; |
| 224 | 216 |
| 225 // Contains all loaded extensions. This is essentially the renderer | 217 // Contains all loaded extensions. This is essentially the renderer |
| 226 // counterpart to ExtensionService in the browser. It contains information | 218 // counterpart to ExtensionService in the browser. It contains information |
| 227 // about all extensions currently loaded by the browser. | 219 // about all extensions currently loaded by the browser. |
| 228 ExtensionSet extensions_; | 220 ExtensionSet extensions_; |
| 229 | 221 |
| 230 // All the bindings contexts that are currently loaded for this renderer. | 222 // All the bindings contexts that are currently loaded for this renderer. |
| 231 // There is zero or one for each v8 context. | 223 // There is zero or one for each v8 context. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 257 |
| 266 // Sends API requests to the extension host. | 258 // Sends API requests to the extension host. |
| 267 scoped_ptr<RequestSender> request_sender_; | 259 scoped_ptr<RequestSender> request_sender_; |
| 268 | 260 |
| 269 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 261 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
| 270 }; | 262 }; |
| 271 | 263 |
| 272 } // namespace extensions | 264 } // namespace extensions |
| 273 | 265 |
| 274 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 266 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
| OLD | NEW |