| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 const ScriptContextSet& script_context_set() const { | 76 const ScriptContextSet& script_context_set() const { |
| 77 return *script_context_set_; | 77 return *script_context_set_; |
| 78 } | 78 } |
| 79 | 79 |
| 80 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); } | 80 V8SchemaRegistry* v8_schema_registry() { return v8_schema_registry_.get(); } |
| 81 | 81 |
| 82 ContentWatcher* content_watcher() { return content_watcher_.get(); } | 82 ContentWatcher* content_watcher() { return content_watcher_.get(); } |
| 83 | 83 |
| 84 RequestSender* request_sender() { return request_sender_.get(); } | 84 RequestSender* request_sender() { return request_sender_.get(); } |
| 85 | 85 |
| 86 // Thread safe. |
| 87 static void InstallV8ExtensionForServiceWorkers(const GURL& script_url); |
| 88 |
| 86 const std::string& webview_partition_id() { return webview_partition_id_; } | 89 const std::string& webview_partition_id() { return webview_partition_id_; } |
| 87 | 90 |
| 88 void OnRenderFrameCreated(content::RenderFrame* render_frame); | 91 void OnRenderFrameCreated(content::RenderFrame* render_frame); |
| 89 | 92 |
| 90 bool IsExtensionActive(const std::string& extension_id) const; | 93 bool IsExtensionActive(const std::string& extension_id) const; |
| 91 | 94 |
| 92 void DidCreateScriptContext(blink::WebLocalFrame* frame, | 95 void DidCreateScriptContext(blink::WebLocalFrame* frame, |
| 93 const v8::Local<v8::Context>& context, | 96 const v8::Local<v8::Context>& context, |
| 94 int extension_group, | 97 int extension_group, |
| 95 int world_id); | 98 int world_id); |
| 96 | 99 |
| 97 // Runs on a different thread and should not use any member variables. | 100 // Runs on a different thread and should only use thread safe member |
| 98 static void DidInitializeServiceWorkerContextOnWorkerThread( | 101 // variables. |
| 102 void DidInitializeServiceWorkerContextOnWorkerThread( |
| 99 v8::Local<v8::Context> v8_context, | 103 v8::Local<v8::Context> v8_context, |
| 104 int embedded_worker_id, |
| 100 const GURL& url); | 105 const GURL& url); |
| 101 | 106 |
| 102 void WillReleaseScriptContext(blink::WebLocalFrame* frame, | 107 void WillReleaseScriptContext(blink::WebLocalFrame* frame, |
| 103 const v8::Local<v8::Context>& context, | 108 const v8::Local<v8::Context>& context, |
| 104 int world_id); | 109 int world_id); |
| 105 | 110 |
| 106 // Runs on a different thread and should not use any member variables. | 111 // Runs on a different thread and should not use any member variables. |
| 107 static void WillDestroyServiceWorkerContextOnWorkerThread( | 112 static void WillDestroyServiceWorkerContextOnWorkerThread( |
| 108 v8::Local<v8::Context> v8_context, | 113 v8::Local<v8::Context> v8_context, |
| 114 int embedded_worker_id, |
| 109 const GURL& url); | 115 const GURL& url); |
| 110 | 116 |
| 111 // This method is not allowed to run JavaScript code in the frame. | 117 // This method is not allowed to run JavaScript code in the frame. |
| 112 void DidCreateDocumentElement(blink::WebLocalFrame* frame); | 118 void DidCreateDocumentElement(blink::WebLocalFrame* frame); |
| 113 | 119 |
| 114 // These methods may run (untrusted) JavaScript code in the frame, and | 120 // These methods may run (untrusted) JavaScript code in the frame, and |
| 115 // cause |render_frame| to become invalid. | 121 // cause |render_frame| to become invalid. |
| 116 void RunScriptsAtDocumentStart(content::RenderFrame* render_frame); | 122 void RunScriptsAtDocumentStart(content::RenderFrame* render_frame); |
| 117 void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame); | 123 void RunScriptsAtDocumentEnd(content::RenderFrame* render_frame); |
| 118 | 124 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 222 |
| 217 // Adds or removes bindings for every context belonging to |extension_id|, or | 223 // Adds or removes bindings for every context belonging to |extension_id|, or |
| 218 // or all contexts if |extension_id| is empty. | 224 // or all contexts if |extension_id| is empty. |
| 219 void UpdateBindings(const std::string& extension_id); | 225 void UpdateBindings(const std::string& extension_id); |
| 220 | 226 |
| 221 void UpdateBindingsForContext(ScriptContext* context); | 227 void UpdateBindingsForContext(ScriptContext* context); |
| 222 | 228 |
| 223 void RegisterBinding(const std::string& api_name, ScriptContext* context); | 229 void RegisterBinding(const std::string& api_name, ScriptContext* context); |
| 224 | 230 |
| 225 void RegisterNativeHandlers(ModuleSystem* module_system, | 231 void RegisterNativeHandlers(ModuleSystem* module_system, |
| 226 ScriptContext* context); | 232 ScriptContext* context, |
| 233 RequestSender* request_sender, |
| 234 V8SchemaRegistry* v8_schema_registry); |
| 227 | 235 |
| 228 // Determines if a ScriptContext can connect to any externally_connectable- | 236 // Determines if a ScriptContext can connect to any externally_connectable- |
| 229 // enabled extension. | 237 // enabled extension. |
| 230 bool IsRuntimeAvailableToContext(ScriptContext* context); | 238 bool IsRuntimeAvailableToContext(ScriptContext* context); |
| 231 | 239 |
| 232 // Updates a web page context with any content capabilities granted by active | 240 // Updates a web page context with any content capabilities granted by active |
| 233 // extensions. | 241 // extensions. |
| 234 void UpdateContentCapabilities(ScriptContext* context); | 242 void UpdateContentCapabilities(ScriptContext* context); |
| 235 | 243 |
| 236 // Inserts static source code into |source_map_|. | 244 // Inserts static source code into |source_map_|. |
| 237 void PopulateSourceMap(); | 245 void PopulateSourceMap(); |
| 238 | 246 |
| 239 // Returns whether the current renderer hosts a platform app. | 247 // Returns whether the current renderer hosts a platform app. |
| 240 bool IsWithinPlatformApp(); | 248 bool IsWithinPlatformApp(); |
| 241 | 249 |
| 242 // Gets |field| from |object| or creates it as an empty object if it doesn't | 250 // Gets |field| from |object| or creates it as an empty object if it doesn't |
| 243 // exist. | 251 // exist. |
| 244 v8::Local<v8::Object> GetOrCreateObject(const v8::Local<v8::Object>& object, | 252 static v8::Local<v8::Object> GetOrCreateObject( |
| 245 const std::string& field, | 253 const v8::Local<v8::Object>& object, |
| 246 v8::Isolate* isolate); | 254 const std::string& field, |
| 255 v8::Isolate* isolate); |
| 247 | 256 |
| 248 v8::Local<v8::Object> GetOrCreateBindObjectIfAvailable( | 257 static v8::Local<v8::Object> GetOrCreateBindObjectIfAvailable( |
| 249 const std::string& api_name, | 258 const std::string& api_name, |
| 250 std::string* bind_name, | 259 std::string* bind_name, |
| 251 ScriptContext* context); | 260 ScriptContext* context); |
| 252 | 261 |
| 253 // Requires the GuestView modules in the module system of the ScriptContext | 262 // Requires the GuestView modules in the module system of the ScriptContext |
| 254 // |context|. | 263 // |context|. |
| 255 void RequireGuestViewModules(ScriptContext* context); | 264 void RequireGuestViewModules(ScriptContext* context); |
| 256 | 265 |
| 257 // The delegate for this dispatcher. Not owned, but must extend beyond the | 266 // The delegate for this dispatcher. Not owned, but must extend beyond the |
| 258 // Dispatcher's own lifetime. | 267 // Dispatcher's own lifetime. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 // if this renderer is a WebView guest render process. Otherwise, this will be | 318 // if this renderer is a WebView guest render process. Otherwise, this will be |
| 310 // empty. | 319 // empty. |
| 311 std::string webview_partition_id_; | 320 std::string webview_partition_id_; |
| 312 | 321 |
| 313 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 322 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
| 314 }; | 323 }; |
| 315 | 324 |
| 316 } // namespace extensions | 325 } // namespace extensions |
| 317 | 326 |
| 318 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ | 327 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ |
| OLD | NEW |