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 // Calls a method |method_name| in a module |module_name| belonging to the |
| 133 // module system from |context|. Intended as a callback target from |
| 134 // ChromeV8ContextSet::ForEach. Public to be called from ExtensionHelper. |
| 135 static void CallModuleMethod(const std::string& module_name, |
| 136 const std::string& method_name, |
| 137 const base::ListValue* args, |
| 138 ChromeV8Context* context); |
| 139 |
132 private: | 140 private: |
133 friend class RenderViewTest; | 141 friend class RenderViewTest; |
134 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, | 142 FRIEND_TEST_ALL_PREFIXES(RendererPermissionsPolicyDelegateTest, |
135 CannotScriptWebstore); | 143 CannotScriptWebstore); |
136 typedef void (*BindingInstaller)(ModuleSystem* module_system, | 144 typedef void (*BindingInstaller)(ModuleSystem* module_system, |
137 v8::Handle<v8::Object> chrome, | 145 v8::Handle<v8::Object> chrome, |
138 v8::Handle<v8::Object> chrome_hidden); | 146 v8::Handle<v8::Object> chrome_hidden); |
139 | 147 |
140 // RenderProcessObserver implementation: | 148 // RenderProcessObserver implementation: |
141 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; | 149 virtual bool OnControlMessageReceived(const IPC::Message& message) OVERRIDE; |
142 virtual void WebKitInitialized() OVERRIDE; | 150 virtual void WebKitInitialized() OVERRIDE; |
143 virtual void IdleNotification() OVERRIDE; | 151 virtual void IdleNotification() OVERRIDE; |
144 | 152 |
145 void OnSetChannel(int channel); | 153 void OnSetChannel(int channel); |
146 void OnMessageInvoke(const std::string& extension_id, | 154 void OnMessageInvoke(const std::string& extension_id, |
| 155 const std::string& module_name, |
147 const std::string& function_name, | 156 const std::string& function_name, |
148 const base::ListValue& args, | 157 const base::ListValue& args, |
149 bool user_gesture); | 158 bool user_gesture); |
150 void OnDispatchOnConnect(int target_port_id, | 159 void OnDispatchOnConnect(int target_port_id, |
151 const std::string& channel_name, | 160 const std::string& channel_name, |
152 const base::DictionaryValue& source_tab, | 161 const base::DictionaryValue& source_tab, |
153 const ExtensionMsg_ExternalConnectionInfo& info); | 162 const ExtensionMsg_ExternalConnectionInfo& info); |
154 void OnDeliverMessage(int target_port_id, const std::string& message); | 163 void OnDeliverMessage(int target_port_id, const base::ListValue& message); |
155 void OnDispatchOnDisconnect(int port_id, const std::string& error_message); | 164 void OnDispatchOnDisconnect(int port_id, const std::string& error_message); |
156 void OnSetFunctionNames(const std::vector<std::string>& names); | 165 void OnSetFunctionNames(const std::vector<std::string>& names); |
157 void OnLoaded( | 166 void OnLoaded( |
158 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions); | 167 const std::vector<ExtensionMsg_Loaded_Params>& loaded_extensions); |
159 void OnLoadedInternal(scoped_refptr<const Extension> extension); | 168 void OnLoadedInternal(scoped_refptr<const Extension> extension); |
160 void OnUnloaded(const std::string& id); | 169 void OnUnloaded(const std::string& id); |
161 void OnSetScriptingWhitelist( | 170 void OnSetScriptingWhitelist( |
162 const Extension::ScriptingWhitelist& extension_ids); | 171 const Extension::ScriptingWhitelist& extension_ids); |
163 void OnPageActionsUpdated(const std::string& extension_id, | 172 void OnPageActionsUpdated(const std::string& extension_id, |
164 const std::vector<std::string>& page_actions); | 173 const std::vector<std::string>& page_actions); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 284 |
276 // Sends API requests to the extension host. | 285 // Sends API requests to the extension host. |
277 scoped_ptr<RequestSender> request_sender_; | 286 scoped_ptr<RequestSender> request_sender_; |
278 | 287 |
279 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 288 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
280 }; | 289 }; |
281 | 290 |
282 } // namespace extensions | 291 } // namespace extensions |
283 | 292 |
284 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ | 293 #endif // CHROME_RENDERER_EXTENSIONS_DISPATCHER_H_ |
OLD | NEW |