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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 bool success, | 122 bool success, |
123 const base::ListValue& response, | 123 const base::ListValue& response, |
124 const std::string& error); | 124 const std::string& error); |
125 | 125 |
126 // Checks that the current context contains an extension that has permission | 126 // Checks that the current context contains an extension that has permission |
127 // to execute the specified function. If it does not, a v8 exception is thrown | 127 // to execute the specified function. If it does not, a v8 exception is thrown |
128 // and the method returns false. Otherwise returns true. | 128 // and the method returns false. Otherwise returns true. |
129 bool CheckContextAccessToExtensionAPI( | 129 bool CheckContextAccessToExtensionAPI( |
130 const std::string& function_name, ChromeV8Context* context) const; | 130 const std::string& function_name, ChromeV8Context* context) const; |
131 | 131 |
| 132 // Dispatches the event named |event_name| to all render views. |
| 133 void DispatchEvent(const std::string& extension_id, |
| 134 const std::string& event_name) const; |
| 135 |
| 136 // Shared implementation of the various MessageInvoke IPCs. |
| 137 void InvokeModuleSystemMethod( |
| 138 content::RenderView* render_view, |
| 139 const std::string& extension_id, |
| 140 const std::string& module_name, |
| 141 const std::string& function_name, |
| 142 const base::ListValue& args, |
| 143 bool user_gesture); |
| 144 |
132 private: | 145 private: |
133 friend class RenderViewTest; | 146 friend class RenderViewTest; |
134 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, | 147 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, |
135 CannotScriptWebstore); | 148 CannotScriptWebstore); |
136 typedef void (*BindingInstaller)(ModuleSystem* module_system, | 149 typedef void (*BindingInstaller)(ModuleSystem* module_system, |
137 v8::Handle<v8::Object> chrome, | 150 v8::Handle<v8::Object> chrome, |
138 v8::Handle<v8::Object> chrome_hidden); | 151 v8::Handle<v8::Object> chrome_hidden); |
139 | 152 |
140 // RenderProcessObserver implementation: | 153 // RenderProcessObserver implementation: |
141 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 154 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
142 virtual void WebKitInitialized() OVERRIDE; | 155 virtual void WebKitInitialized() OVERRIDE; |
143 virtual void IdleNotification() OVERRIDE; | 156 virtual void IdleNotification() OVERRIDE; |
144 | 157 |
145 void OnSetChannel(int channel); | 158 void OnSetChannel(int channel); |
146 void OnMessageInvoke(const std::string& extension_id, | 159 void OnMessageInvoke(const std::string& extension_id, |
| 160 const std::string& module_name, |
147 const std::string& function_name, | 161 const std::string& function_name, |
148 const base::ListValue& args, | 162 const base::ListValue& args, |
149 bool user_gesture); | 163 bool user_gesture); |
150 void OnDispatchOnConnect(int target_port_id, | 164 void OnDispatchOnConnect(int target_port_id, |
151 const std::string& channel_name, | 165 const std::string& channel_name, |
152 const base::DictionaryValue& source_tab, | 166 const base::DictionaryValue& source_tab, |
153 const ExtensionMsg_ExternalConnectionInfo& info); | 167 const ExtensionMsg_ExternalConnectionInfo& info); |
154 void OnDeliverMessage(int target_port_id, const base::ListValue& message); | 168 void OnDeliverMessage(int target_port_id, const base::ListValue& message); |
155 void OnDispatchOnDisconnect(int port_id, const std::string& error_message); | 169 void OnDispatchOnDisconnect(int port_id, const std::string& error_message); |
156 void OnSetFunctionNames(const std::vector<std::string>& names); | 170 void OnSetFunctionNames(const std::vector<std::string>& names); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 289 |
276 // Sends API requests to the extension host. | 290 // Sends API requests to the extension host. |
277 scoped_ptr<RequestSender> request_sender_; | 291 scoped_ptr<RequestSender> request_sender_; |
278 | 292 |
279 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 293 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
280 }; | 294 }; |
281 | 295 |
282 } // namespace extensions | 296 } // namespace extensions |
283 | 297 |
284 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 298 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
OLD | NEW |