OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_FRAME_CFPROXY_H_ | 5 #ifndef CHROME_FRAME_CFPROXY_H_ |
6 #define CHROME_FRAME_CFPROXY_H_ | 6 #define CHROME_FRAME_CFPROXY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <windows.h> | 9 #include <windows.h> |
10 #include <map> // for proxy factory | 10 #include <map> // for proxy factory |
11 #include <vector> | 11 #include <vector> |
12 #include <string> | 12 #include <string> |
13 #include "base/lock.h" | 13 #include "base/lock.h" |
14 #include "base/time.h" // for base::TimeDelta | 14 #include "base/time.h" // for base::TimeDelta |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "chrome/common/automation_constants.h" | 16 #include "chrome/common/automation_constants.h" |
17 #include "chrome/common/page_zoom.h" | 17 #include "chrome/common/page_zoom.h" |
| 18 #include "ipc/ipc_channel.h" |
18 | 19 |
19 enum FindInPageDirection { BACK = 0, FWD = 1 }; | 20 enum FindInPageDirection { BACK = 0, FWD = 1 }; |
20 enum FindInPageCase { IGNORE_CASE = 0, CASE_SENSITIVE = 1 }; | 21 enum FindInPageCase { IGNORE_CASE = 0, CASE_SENSITIVE = 1 }; |
21 // Specifies the font size on a page which is requested by an automation | 22 // Specifies the font size on a page which is requested by an automation |
22 // client. | 23 // client. |
23 enum AutomationPageFontSize { | 24 enum AutomationPageFontSize { |
24 SMALLEST_FONT = 8, | 25 SMALLEST_FONT = 8, |
25 SMALL_FONT = 12, | 26 SMALL_FONT = 12, |
26 MEDIUM_FONT = 16, | 27 MEDIUM_FONT = 16, |
27 LARGE_FONT = 24, | 28 LARGE_FONT = 24, |
28 LARGEST_FONT = 36 | 29 LARGEST_FONT = 36 |
29 }; | 30 }; |
30 | 31 |
| 32 class ChromeProxyDelegate; |
| 33 class ChromeProxyFactory; |
| 34 class GURL; |
31 class URLRequestStatus; | 35 class URLRequestStatus; |
32 namespace IPC { | 36 struct AttachExternalTabParams; |
33 struct ExternalTabSettings; | 37 struct AutomationURLRequest; |
34 struct NavigationInfo; | 38 struct ExternalTabSettings; |
35 struct AutomationURLRequest; | 39 struct MiniContextMenuParams; |
36 struct AttachExternalTabParams; | 40 struct NavigationInfo; |
37 struct MiniContextMenuParams; | |
38 }; | |
39 | |
40 class GURL; | |
41 class ChromeProxyFactory; | |
42 class ChromeProxyDelegate; | |
43 struct ProxyParams; | 41 struct ProxyParams; |
44 | 42 |
45 // Some callers of synchronous messages wants a context to be passed back | 43 // Some callers of synchronous messages wants a context to be passed back |
46 // in order to identify the call they made. Presumably one can make | 44 // in order to identify the call they made. Presumably one can make |
47 // multiple sync calls of same type (as async) and want to identify what | 45 // multiple sync calls of same type (as async) and want to identify what |
48 // is what. | 46 // is what. |
49 struct SyncMessageContext { | 47 struct SyncMessageContext { |
50 virtual ~SyncMessageContext() {} | 48 virtual ~SyncMessageContext() {} |
51 }; | 49 }; |
52 | 50 |
(...skipping 29 matching lines...) Expand all Loading... |
82 SyncMessageContext* ctx) = 0; | 80 SyncMessageContext* ctx) = 0; |
83 virtual void LoadExtension(ChromeProxyDelegate* delegate, | 81 virtual void LoadExtension(ChromeProxyDelegate* delegate, |
84 const FilePath& path, | 82 const FilePath& path, |
85 SyncMessageContext* ctx) = 0; | 83 SyncMessageContext* ctx) = 0; |
86 virtual void GetEnabledExtensions(ChromeProxyDelegate* delegate, | 84 virtual void GetEnabledExtensions(ChromeProxyDelegate* delegate, |
87 SyncMessageContext* ctx) = 0; | 85 SyncMessageContext* ctx) = 0; |
88 virtual void SetProxyConfig(const std::string& json_encoded_settings) = 0; | 86 virtual void SetProxyConfig(const std::string& json_encoded_settings) = 0; |
89 | 87 |
90 // Tab management. | 88 // Tab management. |
91 virtual void CreateTab(ChromeProxyDelegate* delegate, | 89 virtual void CreateTab(ChromeProxyDelegate* delegate, |
92 const IPC::ExternalTabSettings& settings) = 0; | 90 const ExternalTabSettings& settings) = 0; |
93 virtual void ConnectTab(ChromeProxyDelegate* delegate, HWND hwnd, | 91 virtual void ConnectTab(ChromeProxyDelegate* delegate, HWND hwnd, |
94 uint64 cookie) = 0; | 92 uint64 cookie) = 0; |
95 virtual void BlockTab(uint64 cookie) = 0; | 93 virtual void BlockTab(uint64 cookie) = 0; |
96 | 94 |
97 // Tab related. | 95 // Tab related. |
98 virtual void Tab_PostMessage(int tab, const std::string& message, | 96 virtual void Tab_PostMessage(int tab, const std::string& message, |
99 const std::string& origin, | 97 const std::string& origin, |
100 const std::string& target) = 0; | 98 const std::string& target) = 0; |
101 virtual void Tab_Reload(int tab) = 0; | 99 virtual void Tab_Reload(int tab) = 0; |
102 virtual void Tab_Stop(int tab) = 0; | 100 virtual void Tab_Stop(int tab) = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 virtual void Init(const ProxyParams& params) = 0; | 133 virtual void Init(const ProxyParams& params) = 0; |
136 virtual int AddDelegate(ChromeProxyDelegate* delegate) = 0; | 134 virtual int AddDelegate(ChromeProxyDelegate* delegate) = 0; |
137 virtual int RemoveDelegate(ChromeProxyDelegate* delegate) = 0; | 135 virtual int RemoveDelegate(ChromeProxyDelegate* delegate) = 0; |
138 }; | 136 }; |
139 | 137 |
140 // The object that uses ChromeProxy should implement ChromeProxyDelegate in | 138 // The object that uses ChromeProxy should implement ChromeProxyDelegate in |
141 // order to get notified about important events/requests coming from the | 139 // order to get notified about important events/requests coming from the |
142 // instance of Chromium. | 140 // instance of Chromium. |
143 // Allow only one delegate per tab, i.e. delegate can handle only a single tab. | 141 // Allow only one delegate per tab, i.e. delegate can handle only a single tab. |
144 // Note: all of the methods are invoked always in a background IPC thread. | 142 // Note: all of the methods are invoked always in a background IPC thread. |
145 class ChromeProxyDelegate { | 143 class ChromeProxyDelegate : public IPC::Channel::Listener { |
146 public: | 144 public: |
147 enum DisconnectReason { | 145 enum DisconnectReason { |
148 CHROME_EXE_LAUNCH_FAILED, | 146 CHROME_EXE_LAUNCH_FAILED, |
149 CHROME_EXE_LAUNCH_TIMEOUT, | 147 CHROME_EXE_LAUNCH_TIMEOUT, |
150 CHANNEL_ERROR | 148 CHANNEL_ERROR |
151 }; | 149 }; |
152 | 150 |
| 151 // IPC::Channel::Listener. |
| 152 void OnMessageReceived(const IPC::Message& message) = 0; |
| 153 |
153 virtual void Connected(ChromeProxy* proxy) = 0; | 154 virtual void Connected(ChromeProxy* proxy) = 0; |
154 virtual void Disconnected() = 0; | 155 virtual void Disconnected() = 0; |
155 virtual void PeerLost(ChromeProxy* proxy, DisconnectReason reason) = 0; | 156 virtual void PeerLost(ChromeProxy* proxy, DisconnectReason reason) = 0; |
156 virtual int tab_handle() = 0; // to avoid reverse lookup :) | 157 virtual int tab_handle() = 0; // to avoid reverse lookup :) |
157 | 158 |
158 // Sync message responses. | 159 // Sync message responses. |
159 virtual void Completed_CreateTab(bool success, HWND chrome_wnd, | 160 virtual void Completed_CreateTab(bool success, HWND chrome_wnd, |
160 HWND tab_window, int tab_handle, int session_id) = 0; | 161 HWND tab_window, int tab_handle, int session_id) = 0; |
161 virtual void Completed_ConnectToTab(bool success, HWND chrome_window, | 162 virtual void Completed_ConnectToTab(bool success, HWND chrome_window, |
162 HWND tab_window, int tab_handle, int session_id) = 0; | 163 HWND tab_window, int tab_handle, int session_id) = 0; |
163 virtual void Completed_Navigate(bool success, | 164 virtual void Completed_Navigate(bool success, |
164 enum AutomationMsg_NavigationResponseValues res) = 0; | 165 enum AutomationMsg_NavigationResponseValues res) = 0; |
165 virtual void Completed_InstallExtension(bool success, | 166 virtual void Completed_InstallExtension(bool success, |
166 AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) = 0; | 167 AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) = 0; |
167 virtual void Completed_LoadExpandedExtension(bool success, | 168 virtual void Completed_LoadExpandedExtension(bool success, |
168 AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) = 0; | 169 AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) = 0; |
169 virtual void Completed_GetEnabledExtensions(bool success, | 170 virtual void Completed_GetEnabledExtensions(bool success, |
170 const std::vector<FilePath>* extensions) = 0; | 171 const std::vector<FilePath>* extensions) = 0; |
171 | 172 |
172 // Network requests from Chrome. | |
173 virtual void Network_Start(int request_id, | |
174 const IPC::AutomationURLRequest& request_info) = 0; | |
175 virtual void Network_Read(int request_id, int bytes_to_read) = 0; | |
176 virtual void Network_End(int request_id, const URLRequestStatus& status) = 0; | |
177 virtual void Network_DownloadInHost(int request_id) = 0; | |
178 virtual void GetCookies(const GURL& url, int cookie_id) = 0; | |
179 virtual void SetCookie(const GURL& url, const std::string& cookie) = 0; | |
180 | |
181 // Navigation progress notifications. | |
182 virtual void NavigationStateChanged(int flags, | |
183 const IPC::NavigationInfo& nav_info) = 0; | |
184 virtual void UpdateTargetUrl(const std::wstring& url) = 0; | |
185 virtual void NavigationFailed(int error_code, const GURL& gurl) = 0; | |
186 virtual void DidNavigate(const IPC::NavigationInfo& navigation_info) = 0; | |
187 virtual void TabLoaded(const GURL& url) = 0; | |
188 | |
189 // Navigation and messaging. | |
190 virtual void OpenURL(const GURL& url_to_open, const GURL& referrer, | |
191 int open_disposition) = 0; | |
192 virtual void GoToHistoryOffset(int offset) = 0; | |
193 virtual void MessageToHost(const std::string& message, | |
194 const std::string& origin, | |
195 const std::string& target) = 0; | |
196 // Misc. UI. | |
197 virtual void HandleAccelerator(const MSG& accel_message) = 0; | |
198 virtual void HandleContextMenu(HANDLE menu_handle, int align_flags, | |
199 const IPC::MiniContextMenuParams& params) = 0; | |
200 virtual void TabbedOut(bool reverse) = 0; | |
201 | |
202 // Tab related. | |
203 virtual void TabClosed() = 0; | |
204 virtual void AttachTab(const IPC::AttachExternalTabParams& attach_params) = 0; | |
205 protected: | 173 protected: |
206 ~ChromeProxyDelegate() {} | 174 ~ChromeProxyDelegate() {} |
207 }; | 175 }; |
208 | 176 |
209 // a way to obtain a ChromeProxy implementation | 177 // a way to obtain a ChromeProxy implementation |
210 struct ProxyParams { | 178 struct ProxyParams { |
211 std::string profile; | 179 std::string profile; |
212 std::wstring extra_params; | 180 std::wstring extra_params; |
213 FilePath profile_path; | 181 FilePath profile_path; |
214 base::TimeDelta timeout; | 182 base::TimeDelta timeout; |
215 }; | 183 }; |
216 | 184 |
217 class ChromeProxyFactory { | 185 class ChromeProxyFactory { |
218 public: | 186 public: |
219 ChromeProxyFactory(); | 187 ChromeProxyFactory(); |
220 ~ChromeProxyFactory(); | 188 ~ChromeProxyFactory(); |
221 void GetProxy(ChromeProxyDelegate* delegate, const ProxyParams& params); | 189 void GetProxy(ChromeProxyDelegate* delegate, const ProxyParams& params); |
222 bool ReleaseProxy(ChromeProxyDelegate* delegate, const std::string& profile); | 190 bool ReleaseProxy(ChromeProxyDelegate* delegate, const std::string& profile); |
223 protected: | 191 protected: |
224 virtual ChromeProxy* CreateProxy(); | 192 virtual ChromeProxy* CreateProxy(); |
225 typedef std::map<std::string, ChromeProxy*> ProxyMap; | 193 typedef std::map<std::string, ChromeProxy*> ProxyMap; |
226 ProxyMap proxies_; | 194 ProxyMap proxies_; |
227 Lock lock_; | 195 Lock lock_; |
228 }; | 196 }; |
229 | 197 |
230 #endif // CHROME_FRAME_CFPROXY_H_ | 198 #endif // CHROME_FRAME_CFPROXY_H_ |
OLD | NEW |