| 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 14 | 14 |
| 15 class Browser; | 15 class Browser; |
| 16 class Extension; | 16 class Extension; |
| 17 class ExtensionFunction; | 17 class ExtensionFunction; |
| 18 class ExtensionHost; | 18 class ExtensionHost; |
| 19 class Profile; | 19 class Profile; |
| 20 class RenderViewHost; | 20 class RenderViewHost; |
| 21 class RenderViewHostDelegate; | 21 class RenderViewHostDelegate; |
| 22 class Value; |
| 22 | 23 |
| 23 // A factory function for creating new ExtensionFunction instances. | 24 // A factory function for creating new ExtensionFunction instances. |
| 24 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); | 25 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); |
| 25 | 26 |
| 26 // ExtensionFunctionDispatcher receives requests to execute functions from | 27 // ExtensionFunctionDispatcher receives requests to execute functions from |
| 27 // Chromium extensions running in a RenderViewHost and dispatches them to the | 28 // Chromium extensions running in a RenderViewHost and dispatches them to the |
| 28 // appropriate handler. It lives entirely on the UI thread. | 29 // appropriate handler. It lives entirely on the UI thread. |
| 29 class ExtensionFunctionDispatcher { | 30 class ExtensionFunctionDispatcher { |
| 30 public: | 31 public: |
| 31 class Delegate { | 32 class Delegate { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 54 | 55 |
| 55 // Retrieves a vector of all EFD instances. | 56 // Retrieves a vector of all EFD instances. |
| 56 static std::set<ExtensionFunctionDispatcher*>* all_instances(); | 57 static std::set<ExtensionFunctionDispatcher*>* all_instances(); |
| 57 | 58 |
| 58 ExtensionFunctionDispatcher(RenderViewHost* render_view_host, | 59 ExtensionFunctionDispatcher(RenderViewHost* render_view_host, |
| 59 Delegate* delegate, | 60 Delegate* delegate, |
| 60 const GURL& url); | 61 const GURL& url); |
| 61 ~ExtensionFunctionDispatcher(); | 62 ~ExtensionFunctionDispatcher(); |
| 62 | 63 |
| 63 // Handle a request to execute an extension function. | 64 // Handle a request to execute an extension function. |
| 64 void HandleRequest(const std::string& name, const std::string& args, | 65 void HandleRequest(const std::string& name, const Value* args, |
| 65 int request_id, bool has_callback); | 66 int request_id, bool has_callback); |
| 66 | 67 |
| 67 // Send a response to a function. | 68 // Send a response to a function. |
| 68 void SendResponse(ExtensionFunction* api, bool success); | 69 void SendResponse(ExtensionFunction* api, bool success); |
| 69 | 70 |
| 70 // Gets the browser extension functions should operate relative to. For | 71 // Gets the browser extension functions should operate relative to. For |
| 71 // example, for positioning windows, or alert boxes, or creating tabs. | 72 // example, for positioning windows, or alert boxes, or creating tabs. |
| 72 Browser* GetBrowser(); | 73 Browser* GetBrowser(); |
| 73 | 74 |
| 74 // Gets the ExtensionHost associated with this object. In the case of | 75 // Gets the ExtensionHost associated with this object. In the case of |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 107 |
| 107 // AutomationExtensionFunction requires access to the RenderViewHost | 108 // AutomationExtensionFunction requires access to the RenderViewHost |
| 108 // associated with us. We make it a friend rather than exposing the | 109 // associated with us. We make it a friend rather than exposing the |
| 109 // RenderViewHost as a public method as we wouldn't want everyone to | 110 // RenderViewHost as a public method as we wouldn't want everyone to |
| 110 // start assuming a 1:1 relationship between us and RenderViewHost, | 111 // start assuming a 1:1 relationship between us and RenderViewHost, |
| 111 // whereas AutomationExtensionFunction is by necessity "tight" with us. | 112 // whereas AutomationExtensionFunction is by necessity "tight" with us. |
| 112 friend class AutomationExtensionFunction; | 113 friend class AutomationExtensionFunction; |
| 113 }; | 114 }; |
| 114 | 115 |
| 115 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 116 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| OLD | NEW |