| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 | 12 |
| 13 class Browser; |
| 13 class ExtensionFunction; | 14 class ExtensionFunction; |
| 14 class Profile; | 15 class Profile; |
| 15 class RenderViewHost; | 16 class RenderViewHost; |
| 17 class RenderViewHostDelegate; |
| 16 | 18 |
| 17 // ExtensionFunctionDispatcher receives requests to execute functions from | 19 // ExtensionFunctionDispatcher receives requests to execute functions from |
| 18 // Chromium extensions running in a RenderViewHost and dispatches them to the | 20 // Chromium extensions running in a RenderViewHost and dispatches them to the |
| 19 // appropriate handler. It lives entirely on the UI thread. | 21 // appropriate handler. It lives entirely on the UI thread. |
| 20 class ExtensionFunctionDispatcher { | 22 class ExtensionFunctionDispatcher { |
| 21 public: | 23 public: |
| 22 // Gets a list of all known extension function names. | 24 // Gets a list of all known extension function names. |
| 23 static void GetAllFunctionNames(std::vector<std::string>* names); | 25 static void GetAllFunctionNames(std::vector<std::string>* names); |
| 24 | 26 |
| 25 ExtensionFunctionDispatcher(RenderViewHost* render_view_host, | 27 ExtensionFunctionDispatcher(RenderViewHost* render_view_host, |
| 28 Browser* browser, |
| 26 const std::string& extension_id); | 29 const std::string& extension_id); |
| 27 | 30 |
| 28 // Handle a request to execute an extension function. | 31 // Handle a request to execute an extension function. |
| 29 void HandleRequest(const std::string& name, const std::string& args, | 32 void HandleRequest(const std::string& name, const std::string& args, |
| 30 int callback_id); | 33 int callback_id); |
| 31 | 34 |
| 32 // Send a response to a function. | 35 // Send a response to a function. |
| 33 void SendResponse(ExtensionFunction* api); | 36 void SendResponse(ExtensionFunction* api); |
| 34 | 37 |
| 38 Browser* browser() { return browser_; } |
| 39 |
| 35 // Handle a malformed message. Possibly the result of an attack, so kill | 40 // Handle a malformed message. Possibly the result of an attack, so kill |
| 36 // the renderer. | 41 // the renderer. |
| 37 void HandleBadMessage(ExtensionFunction* api); | 42 void HandleBadMessage(ExtensionFunction* api); |
| 38 | 43 |
| 39 // Gets the ID for this extension. | 44 // Gets the ID for this extension. |
| 40 std::string extension_id() { return extension_id_; } | 45 std::string extension_id() { return extension_id_; } |
| 41 | 46 |
| 42 // The profile that this dispatcher is associated with. | 47 // The profile that this dispatcher is associated with. |
| 43 Profile* profile(); | 48 Profile* profile(); |
| 44 | 49 |
| 45 private: | 50 private: |
| 46 RenderViewHost* render_view_host_; | 51 RenderViewHost* render_view_host_; |
| 47 | 52 |
| 53 Browser* browser_; |
| 54 |
| 48 std::string extension_id_; | 55 std::string extension_id_; |
| 49 }; | 56 }; |
| 50 | 57 |
| 51 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 58 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| OLD | NEW |