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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 const std::string& event_name) const; | 126 const std::string& event_name) const; |
127 | 127 |
128 // Shared implementation of the various MessageInvoke IPCs. | 128 // Shared implementation of the various MessageInvoke IPCs. |
129 void InvokeModuleSystemMethod(content::RenderFrame* render_frame, | 129 void InvokeModuleSystemMethod(content::RenderFrame* render_frame, |
130 const std::string& extension_id, | 130 const std::string& extension_id, |
131 const std::string& module_name, | 131 const std::string& module_name, |
132 const std::string& function_name, | 132 const std::string& function_name, |
133 const base::ListValue& args, | 133 const base::ListValue& args, |
134 bool user_gesture); | 134 bool user_gesture); |
135 | 135 |
136 void ClearPortData(int port_id); | |
137 | |
138 // Returns a list of (module name, resource id) pairs for the JS modules to | 136 // Returns a list of (module name, resource id) pairs for the JS modules to |
139 // add to the source map. | 137 // add to the source map. |
140 static std::vector<std::pair<std::string, int> > GetJsResources(); | 138 static std::vector<std::pair<std::string, int> > GetJsResources(); |
141 static void RegisterNativeHandlers(ModuleSystem* module_system, | 139 static void RegisterNativeHandlers(ModuleSystem* module_system, |
142 ScriptContext* context, | 140 ScriptContext* context, |
143 Dispatcher* dispatcher, | 141 Dispatcher* dispatcher, |
144 RequestSender* request_sender, | 142 RequestSender* request_sender, |
145 V8SchemaRegistry* v8_schema_registry); | 143 V8SchemaRegistry* v8_schema_registry); |
146 | 144 |
147 bool WasWebRequestUsedBySomeExtensions() const { return webrequest_used_; } | 145 bool WasWebRequestUsedBySomeExtensions() const { return webrequest_used_; } |
148 | 146 |
149 private: | 147 private: |
150 // The RendererPermissionsPolicyDelegateTest.CannotScriptWebstore test needs | 148 // The RendererPermissionsPolicyDelegateTest.CannotScriptWebstore test needs |
151 // to call the OnActivateExtension IPCs. | 149 // to call the OnActivateExtension IPCs. |
152 friend class ::ChromeRenderViewTest; | 150 friend class ::ChromeRenderViewTest; |
153 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, | 151 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, |
154 CannotScriptWebstore); | 152 CannotScriptWebstore); |
155 | 153 |
156 // RenderThreadObserver implementation: | 154 // RenderThreadObserver implementation: |
157 bool OnControlMessageReceived(const IPC::Message& message) override; | 155 bool OnControlMessageReceived(const IPC::Message& message) override; |
158 void IdleNotification() override; | 156 void IdleNotification() override; |
159 void OnRenderProcessShutdown() override; | 157 void OnRenderProcessShutdown() override; |
160 | 158 |
161 void OnActivateExtension(const std::string& extension_id); | 159 void OnActivateExtension(const std::string& extension_id); |
162 void OnCancelSuspend(const std::string& extension_id); | 160 void OnCancelSuspend(const std::string& extension_id); |
163 void OnDeliverMessage(int target_port_id, const Message& message); | 161 void OnDeliverMessage(int target_port_id, |
| 162 int source_tab_id, |
| 163 const Message& message); |
164 void OnDispatchOnConnect(int target_port_id, | 164 void OnDispatchOnConnect(int target_port_id, |
165 const std::string& channel_name, | 165 const std::string& channel_name, |
166 const ExtensionMsg_TabConnectionInfo& source, | 166 const ExtensionMsg_TabConnectionInfo& source, |
167 const ExtensionMsg_ExternalConnectionInfo& info, | 167 const ExtensionMsg_ExternalConnectionInfo& info, |
168 const std::string& tls_channel_id); | 168 const std::string& tls_channel_id); |
169 void OnDispatchOnDisconnect(int port_id, const std::string& error_message); | 169 void OnDispatchOnDisconnect(int port_id, const std::string& error_message); |
170 void OnLoaded( | 170 void OnLoaded( |
171 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions); | 171 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions); |
172 void OnMessageInvoke(const std::string& extension_id, | 172 void OnMessageInvoke(const std::string& extension_id, |
173 const std::string& module_name, | 173 const std::string& module_name, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 // Cache for the v8 representation of extension API schemas. | 287 // Cache for the v8 representation of extension API schemas. |
288 std::unique_ptr<V8SchemaRegistry> v8_schema_registry_; | 288 std::unique_ptr<V8SchemaRegistry> v8_schema_registry_; |
289 | 289 |
290 // Sends API requests to the extension host. | 290 // Sends API requests to the extension host. |
291 std::unique_ptr<RequestSender> request_sender_; | 291 std::unique_ptr<RequestSender> request_sender_; |
292 | 292 |
293 // The platforms system font family and size; | 293 // The platforms system font family and size; |
294 std::string system_font_family_; | 294 std::string system_font_family_; |
295 std::string system_font_size_; | 295 std::string system_font_size_; |
296 | 296 |
297 // Mapping of port IDs to tabs. If there is no tab, the value would be -1. | |
298 std::map<int, int> port_to_tab_id_map_; | |
299 | |
300 // It is important for this to come after the ScriptInjectionManager, so that | 297 // It is important for this to come after the ScriptInjectionManager, so that |
301 // the observer is destroyed before the UserScriptSet. | 298 // the observer is destroyed before the UserScriptSet. |
302 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer> | 299 ScopedObserver<UserScriptSetManager, UserScriptSetManager::Observer> |
303 user_script_set_manager_observer_; | 300 user_script_set_manager_observer_; |
304 | 301 |
305 // Status of webrequest usage. | 302 // Status of webrequest usage. |
306 bool webrequest_used_; | 303 bool webrequest_used_; |
307 | 304 |
308 // The WebView partition ID associated with this process's storage partition, | 305 // The WebView partition ID associated with this process's storage partition, |
309 // if this renderer is a WebView guest render process. Otherwise, this will be | 306 // if this renderer is a WebView guest render process. Otherwise, this will be |
310 // empty. | 307 // empty. |
311 std::string webview_partition_id_; | 308 std::string webview_partition_id_; |
312 | 309 |
313 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 310 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
314 }; | 311 }; |
315 | 312 |
316 } // namespace extensions | 313 } // namespace extensions |
317 | 314 |
318 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ | 315 #endif // EXTENSIONS_RENDERER_DISPATCHER_H_ |
OLD | NEW |