| 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_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 <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/extensions/extension_function.h" | 13 #include "chrome/browser/extensions/extension_function.h" |
| 14 #include "ipc/ipc_sender.h" | 14 #include "ipc/ipc_sender.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 class ChromeRenderMessageFilter; | 17 class ChromeRenderMessageFilter; |
| 18 class ExtensionInfoMap; | |
| 19 class Profile; | 18 class Profile; |
| 20 struct ExtensionHostMsg_Request_Params; | 19 struct ExtensionHostMsg_Request_Params; |
| 21 | 20 |
| 22 namespace content { | 21 namespace content { |
| 23 class RenderViewHost; | 22 class RenderViewHost; |
| 24 class WebContents; | 23 class WebContents; |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace extensions { | 26 namespace extensions { |
| 28 class Extension; | 27 class Extension; |
| 29 class ExtensionAPI; | 28 class ExtensionAPI; |
| 29 class InfoMap; |
| 30 class ProcessMap; | 30 class ProcessMap; |
| 31 class WindowController; | 31 class WindowController; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // A factory function for creating new ExtensionFunction instances. | 34 // A factory function for creating new ExtensionFunction instances. |
| 35 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); | 35 typedef ExtensionFunction* (*ExtensionFunctionFactory)(); |
| 36 | 36 |
| 37 // ExtensionFunctionDispatcher receives requests to execute functions from | 37 // ExtensionFunctionDispatcher receives requests to execute functions from |
| 38 // Chrome extensions running in a RenderViewHost and dispatches them to the | 38 // Chrome extensions running in a RenderViewHost and dispatches them to the |
| 39 // appropriate handler. It lives entirely on the UI thread. | 39 // appropriate handler. It lives entirely on the UI thread. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // false if no such function was registered. | 78 // false if no such function was registered. |
| 79 static bool OverrideFunction(const std::string& name, | 79 static bool OverrideFunction(const std::string& name, |
| 80 ExtensionFunctionFactory factory); | 80 ExtensionFunctionFactory factory); |
| 81 | 81 |
| 82 // Resets all functions to their initial implementation. | 82 // Resets all functions to their initial implementation. |
| 83 static void ResetFunctions(); | 83 static void ResetFunctions(); |
| 84 | 84 |
| 85 // Dispatches an IO-thread extension function. Only used for specific | 85 // Dispatches an IO-thread extension function. Only used for specific |
| 86 // functions that must be handled on the IO-thread. | 86 // functions that must be handled on the IO-thread. |
| 87 static void DispatchOnIOThread( | 87 static void DispatchOnIOThread( |
| 88 ExtensionInfoMap* extension_info_map, | 88 extensions::InfoMap* extension_info_map, |
| 89 void* profile, | 89 void* profile, |
| 90 int render_process_id, | 90 int render_process_id, |
| 91 base::WeakPtr<ChromeRenderMessageFilter> ipc_sender, | 91 base::WeakPtr<ChromeRenderMessageFilter> ipc_sender, |
| 92 int routing_id, | 92 int routing_id, |
| 93 const ExtensionHostMsg_Request_Params& params); | 93 const ExtensionHostMsg_Request_Params& params); |
| 94 | 94 |
| 95 // Public constructor. Callers must ensure that: | 95 // Public constructor. Callers must ensure that: |
| 96 // - |delegate| outlives this object. | 96 // - |delegate| outlives this object. |
| 97 // - This object outlives any RenderViewHost's passed to created | 97 // - This object outlives any RenderViewHost's passed to created |
| 98 // ExtensionFunctions. | 98 // ExtensionFunctions. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 // This map doesn't own either the keys or the values. When a RenderViewHost | 162 // This map doesn't own either the keys or the values. When a RenderViewHost |
| 163 // instance goes away, the corresponding entry in this map (if exists) will be | 163 // instance goes away, the corresponding entry in this map (if exists) will be |
| 164 // removed. | 164 // removed. |
| 165 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> | 165 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> |
| 166 UIThreadResponseCallbackWrapperMap; | 166 UIThreadResponseCallbackWrapperMap; |
| 167 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; | 167 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 170 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
| OLD | NEW |