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 "extensions/browser/extension_function.h" | 13 #include "extensions/browser/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 struct ExtensionHostMsg_Request_Params; | 18 struct ExtensionHostMsg_Request_Params; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 class BrowserContext; | 21 class BrowserContext; |
22 class RenderFrameHost; | |
22 class RenderViewHost; | 23 class RenderViewHost; |
23 class WebContents; | 24 class WebContents; |
24 } | 25 } |
25 | 26 |
26 namespace extensions { | 27 namespace extensions { |
27 class Extension; | 28 class Extension; |
28 class ExtensionAPI; | 29 class ExtensionAPI; |
29 class InfoMap; | 30 class InfoMap; |
30 class ProcessMap; | 31 class ProcessMap; |
31 class WindowController; | 32 class WindowController; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 // - This object outlives any RenderViewHost's passed to created | 98 // - This object outlives any RenderViewHost's passed to created |
98 // ExtensionFunctions. | 99 // ExtensionFunctions. |
99 ExtensionFunctionDispatcher(content::BrowserContext* browser_context, | 100 ExtensionFunctionDispatcher(content::BrowserContext* browser_context, |
100 Delegate* delegate); | 101 Delegate* delegate); |
101 | 102 |
102 ~ExtensionFunctionDispatcher(); | 103 ~ExtensionFunctionDispatcher(); |
103 | 104 |
104 Delegate* delegate() { return delegate_; } | 105 Delegate* delegate() { return delegate_; } |
105 | 106 |
106 // Message handlers. | 107 // Message handlers. |
107 // The response is sent to the corresponding render view in an | 108 // The response is sent to the corresponding render view in an |
Yoyo Zhou
2013/12/20 00:28:37
Does this comment need updating?
jam
2013/12/20 17:00:48
Done.
| |
108 // ExtensionMsg_Response message. | 109 // ExtensionMsg_Response message. |
109 void Dispatch(const ExtensionHostMsg_Request_Params& params, | 110 void Dispatch(const ExtensionHostMsg_Request_Params& params, |
110 content::RenderViewHost* render_view_host); | 111 content::RenderViewHost* render_view_host); |
yzshen1
2013/12/20 01:52:49
Now the two Dispatch.*() methods don't use the sam
jam
2013/12/20 17:00:48
exactly
| |
111 // |callback| is called when the function execution completes. | 112 // |callback| is called when the function execution completes. |
112 void DispatchWithCallback( | 113 void DispatchWithCallback( |
113 const ExtensionHostMsg_Request_Params& params, | 114 const ExtensionHostMsg_Request_Params& params, |
114 content::RenderViewHost* render_view_host, | 115 content::RenderFrameHost* render_frame_host, |
115 const ExtensionFunction::ResponseCallback& callback); | 116 const ExtensionFunction::ResponseCallback& callback); |
116 | 117 |
117 // Called when an ExtensionFunction is done executing, after it has sent | 118 // Called when an ExtensionFunction is done executing, after it has sent |
118 // a response (if any) to the extension. | 119 // a response (if any) to the extension. |
119 void OnExtensionFunctionCompleted(const extensions::Extension* extension); | 120 void OnExtensionFunctionCompleted(const extensions::Extension* extension); |
120 | 121 |
121 // The BrowserContext that this dispatcher is associated with. | 122 // The BrowserContext that this dispatcher is associated with. |
122 content::BrowserContext* browser_context() { return browser_context_; } | 123 content::BrowserContext* browser_context() { return browser_context_; } |
123 | 124 |
124 private: | 125 private: |
(...skipping 24 matching lines...) Expand all Loading... | |
149 const extensions::ProcessMap& process_map, | 150 const extensions::ProcessMap& process_map, |
150 extensions::ExtensionAPI* api, | 151 extensions::ExtensionAPI* api, |
151 void* profile, | 152 void* profile, |
152 const ExtensionFunction::ResponseCallback& callback); | 153 const ExtensionFunction::ResponseCallback& callback); |
153 | 154 |
154 // Helper to run the response callback with an access denied error. Can be | 155 // Helper to run the response callback with an access denied error. Can be |
155 // called on any thread. | 156 // called on any thread. |
156 static void SendAccessDenied( | 157 static void SendAccessDenied( |
157 const ExtensionFunction::ResponseCallback& callback); | 158 const ExtensionFunction::ResponseCallback& callback); |
158 | 159 |
160 void DispatchWithCallbackInternal( | |
161 const ExtensionHostMsg_Request_Params& params, | |
162 content::RenderViewHost* render_view_host, | |
163 content::RenderFrameHost* render_frame_host, | |
164 const ExtensionFunction::ResponseCallback& callback); | |
165 | |
159 content::BrowserContext* browser_context_; | 166 content::BrowserContext* browser_context_; |
160 | 167 |
161 Delegate* delegate_; | 168 Delegate* delegate_; |
162 | 169 |
163 // This map doesn't own either the keys or the values. When a RenderViewHost | 170 // This map doesn't own either the keys or the values. When a RenderViewHost |
164 // instance goes away, the corresponding entry in this map (if exists) will be | 171 // instance goes away, the corresponding entry in this map (if exists) will be |
165 // removed. | 172 // removed. |
166 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> | 173 typedef std::map<content::RenderViewHost*, UIThreadResponseCallbackWrapper*> |
167 UIThreadResponseCallbackWrapperMap; | 174 UIThreadResponseCallbackWrapperMap; |
168 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; | 175 UIThreadResponseCallbackWrapperMap ui_thread_response_callback_wrappers_; |
169 }; | 176 }; |
170 | 177 |
171 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ | 178 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_FUNCTION_DISPATCHER_H_ |
OLD | NEW |