| 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_DISPATCHER_H_ | 5 #ifndef EXTENSIONS_RENDERER_DISPATCHER_H_ |
| 6 #define EXTENSIONS_RENDERER_DISPATCHER_H_ | 6 #define EXTENSIONS_RENDERER_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 | 56 |
| 57 namespace content { | 57 namespace content { |
| 58 class RenderThread; | 58 class RenderThread; |
| 59 } | 59 } |
| 60 | 60 |
| 61 namespace extensions { | 61 namespace extensions { |
| 62 class ContentWatcher; | 62 class ContentWatcher; |
| 63 class DispatcherDelegate; | 63 class DispatcherDelegate; |
| 64 class FilteredEventRouter; | 64 class FilteredEventRouter; |
| 65 class JsExtensionBindingsSystem; |
| 65 class ManifestPermissionSet; | 66 class ManifestPermissionSet; |
| 66 class RequestSender; | 67 class RequestSender; |
| 67 class ScriptContext; | 68 class ScriptContext; |
| 68 class ScriptInjectionManager; | 69 class ScriptInjectionManager; |
| 69 struct Message; | 70 struct Message; |
| 70 | 71 |
| 71 // Dispatches extension control messages sent to the renderer and stores | 72 // Dispatches extension control messages sent to the renderer and stores |
| 72 // renderer extension related state. | 73 // renderer extension related state. |
| 73 class Dispatcher : public content::RenderThreadObserver, | 74 class Dispatcher : public content::RenderThreadObserver, |
| 74 public UserScriptSetManager::Observer { | 75 public UserScriptSetManager::Observer { |
| 75 public: | 76 public: |
| 76 explicit Dispatcher(DispatcherDelegate* delegate); | 77 explicit Dispatcher(DispatcherDelegate* delegate); |
| 77 ~Dispatcher() override; | 78 ~Dispatcher() override; |
| 78 | 79 |
| 79 const ScriptContextSet& script_context_set() const { | 80 const ScriptContextSet& script_context_set() const { |
| 80 return *script_context_set_; | 81 return *script_context_set_; |
| 81 } | 82 } |
| 82 | 83 |
| 83 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); } | 84 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); } |
| 84 | 85 |
| 85 ContentWatcher* content_watcher() { return content_watcher_.get(); } | 86 ContentWatcher* content_watcher() { return content_watcher_.get(); } |
| 86 | 87 |
| 87 RequestSender* request_sender() { return request_sender_.get(); } | |
| 88 | |
| 89 const std::string& webview_partition_id() { return webview_partition_id_; } | 88 const std::string& webview_partition_id() { return webview_partition_id_; } |
| 90 | 89 |
| 91 bool activity_logging_enabled() const { return activity_logging_enabled_; } | 90 bool activity_logging_enabled() const { return activity_logging_enabled_; } |
| 92 | 91 |
| 93 void OnRenderFrameCreated(content::RenderFrame* render_frame); | 92 void OnRenderFrameCreated(content::RenderFrame* render_frame); |
| 94 | 93 |
| 95 bool IsExtensionActive(const std::string& extension_id) const; | 94 bool IsExtensionActive(const std::string& extension_id) const; |
| 96 | 95 |
| 97 void DidCreateScriptContext(blink::WebLocalFrame* frame, | 96 void DidCreateScriptContext(blink::WebLocalFrame* frame, |
| 98 const v8::Local<v8::Context>& context, | 97 const v8::Local<v8::Context>& context, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 | 221 |
| 223 // Enable custom element whitelist in Apps. | 222 // Enable custom element whitelist in Apps. |
| 224 void EnableCustomElementWhiteList(); | 223 void EnableCustomElementWhiteList(); |
| 225 | 224 |
| 226 // Adds or removes bindings for every context belonging to |extension_id|, or | 225 // Adds or removes bindings for every context belonging to |extension_id|, or |
| 227 // or all contexts if |extension_id| is empty. | 226 // or all contexts if |extension_id| is empty. |
| 228 void UpdateBindings(const std::string& extension_id); | 227 void UpdateBindings(const std::string& extension_id); |
| 229 | 228 |
| 230 void UpdateBindingsForContext(ScriptContext* context); | 229 void UpdateBindingsForContext(ScriptContext* context); |
| 231 | 230 |
| 232 void RegisterBinding(const std::string& api_name, ScriptContext* context); | |
| 233 | |
| 234 void RegisterNativeHandlers(ModuleSystem* module_system, | 231 void RegisterNativeHandlers(ModuleSystem* module_system, |
| 235 ScriptContext* context, | 232 ScriptContext* context, |
| 236 RequestSender* request_sender, | 233 RequestSender* request_sender, |
| 237 V8SchemaRegistry* v8_schema_registry); | 234 V8SchemaRegistry* v8_schema_registry); |
| 238 | 235 |
| 239 // Determines if a ScriptContext can connect to any externally_connectable- | |
| 240 // enabled extension. | |
| 241 bool IsRuntimeAvailableToContext(ScriptContext* context); | |
| 242 | |
| 243 // Updates a web page context with any content capabilities granted by active | 236 // Updates a web page context with any content capabilities granted by active |
| 244 // extensions. | 237 // extensions. |
| 245 void UpdateContentCapabilities(ScriptContext* context); | 238 void UpdateContentCapabilities(ScriptContext* context); |
| 246 | 239 |
| 247 // Inserts static source code into |source_map_|. | 240 // Inserts static source code into |source_map_|. |
| 248 void PopulateSourceMap(); | 241 void PopulateSourceMap(); |
| 249 | 242 |
| 250 // Returns whether the current renderer hosts a platform app. | 243 // Returns whether the current renderer hosts a platform app. |
| 251 bool IsWithinPlatformApp(); | 244 bool IsWithinPlatformApp(); |
| 252 | 245 |
| 253 // Gets |field| from |object| or creates it as an empty object if it doesn't | |
| 254 // exist. | |
| 255 static v8::Local<v8::Object> GetOrCreateObject( | |
| 256 const v8::Local<v8::Object>& object, | |
| 257 const std::string& field, | |
| 258 v8::Isolate* isolate); | |
| 259 | |
| 260 static v8::Local<v8::Object> GetOrCreateBindObjectIfAvailable( | |
| 261 const std::string& api_name, | |
| 262 std::string* bind_name, | |
| 263 ScriptContext* context); | |
| 264 | |
| 265 // Requires the GuestView modules in the module system of the ScriptContext | 246 // Requires the GuestView modules in the module system of the ScriptContext |
| 266 // |context|. | 247 // |context|. |
| 267 void RequireGuestViewModules(ScriptContext* context); | 248 void RequireGuestViewModules(ScriptContext* context); |
| 268 | 249 |
| 269 // The delegate for this dispatcher. Not owned, but must extend beyond the | 250 // The delegate for this dispatcher. Not owned, but must extend beyond the |
| 270 // Dispatcher's own lifetime. | 251 // Dispatcher's own lifetime. |
| 271 DispatcherDelegate* delegate_; | 252 DispatcherDelegate* delegate_; |
| 272 | 253 |
| 273 // True if the IdleNotification timer should be set. | 254 // True if the IdleNotification timer should be set. |
| 274 bool set_idle_notifications_; | 255 bool set_idle_notifications_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 292 std::unique_ptr<base::RepeatingTimer> forced_idle_timer_; | 273 std::unique_ptr<base::RepeatingTimer> forced_idle_timer_; |
| 293 | 274 |
| 294 // The extensions and apps that are active in this process. | 275 // The extensions and apps that are active in this process. |
| 295 ExtensionIdSet active_extension_ids_; | 276 ExtensionIdSet active_extension_ids_; |
| 296 | 277 |
| 297 ResourceBundleSourceMap source_map_; | 278 ResourceBundleSourceMap source_map_; |
| 298 | 279 |
| 299 // Cache for the v8 representation of extension API schemas. | 280 // Cache for the v8 representation of extension API schemas. |
| 300 std::unique_ptr<V8SchemaRegistry> v8_schema_registry_; | 281 std::unique_ptr<V8SchemaRegistry> v8_schema_registry_; |
| 301 | 282 |
| 302 // Sends API requests to the extension host. | 283 // The bindings system associated with the main thread. |
| 303 std::unique_ptr<RequestSender> request_sender_; | 284 std::unique_ptr<JsExtensionBindingsSystem> bindings_system_; |
| 304 | 285 |
| 305 // The platforms system font family and size; | 286 // The platforms system font family and size; |
| 306 std::string system_font_family_; | 287 std::string system_font_family_; |
| 307 std::string system_font_size_; | 288 std::string system_font_size_; |
| 308 | 289 |
| 309 // It is important for this to come after the ScriptInjectionManager, so that | 290 // It is important for this to come after the ScriptInjectionManager, so that |
| 310 // the observer is destroyed before the UserScriptSet. | 291 // the observer is destroyed before the UserScriptSet. |
| 311 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer> | 292 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer> |
| 312 user_script_set_manager_observer_; | 293 user_script_set_manager_observer_; |
| 313 | 294 |
| 314 // Whether or not extension activity is enabled. | 295 // Whether or not extension activity is enabled. |
| 315 bool activity_logging_enabled_; | 296 bool activity_logging_enabled_; |
| 316 | 297 |
| 317 // The WebView partition ID associated with this process's storage partition, | 298 // The WebView partition ID associated with this process's storage partition, |
| 318 // if this renderer is a WebView guest render process. Otherwise, this will be | 299 // if this renderer is a WebView guest render process. Otherwise, this will be |
| 319 // empty. | 300 // empty. |
| 320 std::string webview_partition_id_; | 301 std::string webview_partition_id_; |
| 321 | 302 |
| 322 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 303 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
| 323 }; | 304 }; |
| 324 | 305 |
| 325 } // namespace extensions | 306 } // namespace extensions |
| 326 | 307 |
| 327 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ | 308 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ |
| OLD | NEW |