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 #include "chrome_frame/external_tab.h" | 5 #include "chrome_frame/external_tab.h" |
6 #include "base/lazy_instance.h" | 6 #include "base/lazy_instance.h" |
7 #include "base/tracked.h" | 7 #include "base/tracked.h" |
8 #include "base/task.h" | 8 #include "base/task.h" |
9 #include "base/waitable_event.h" | 9 #include "base/waitable_event.h" |
10 #include "chrome/common/automation_messages.h" | 10 #include "chrome/common/automation_messages.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 ExternalTabProxy::ExternalTabProxy() : state_(NONE), tab_(0), tab_wnd_(NULL), | 28 ExternalTabProxy::ExternalTabProxy() : state_(NONE), tab_(0), tab_wnd_(NULL), |
29 chrome_wnd_(NULL), proxy_factory_(g_proxy_factory.Pointer()), proxy_(NULL), | 29 chrome_wnd_(NULL), proxy_factory_(g_proxy_factory.Pointer()), proxy_(NULL), |
30 ui_delegate_(NULL) { | 30 ui_delegate_(NULL) { |
31 } | 31 } |
32 | 32 |
33 ExternalTabProxy::~ExternalTabProxy() { | 33 ExternalTabProxy::~ExternalTabProxy() { |
34 Destroy(); | 34 Destroy(); |
35 } | 35 } |
36 | 36 |
| 37 void ExternalTabProxy::OnMessageReceived(const IPC::Message& message) { |
| 38 IPC_BEGIN_MESSAGE_MAP(ExternalTabProxy, message) |
| 39 IPC_MESSAGE_HANDLER(AutomationMsg_NavigationStateChanged, |
| 40 OnNavigationStateChanged) |
| 41 IPC_MESSAGE_HANDLER(AutomationMsg_UpdateTargetUrl, OnUpdateTargetUrl) |
| 42 IPC_MESSAGE_HANDLER(AutomationMsg_HandleAccelerator, OnHandleAccelerator) |
| 43 IPC_MESSAGE_HANDLER(AutomationMsg_TabbedOut, OnTabbedOut) |
| 44 IPC_MESSAGE_HANDLER(AutomationMsg_OpenURL, OnOpenURL) |
| 45 IPC_MESSAGE_HANDLER(AutomationMsg_NavigationFailed, OnNavigationFailed) |
| 46 IPC_MESSAGE_HANDLER(AutomationMsg_DidNavigate, OnDidNavigate) |
| 47 IPC_MESSAGE_HANDLER(AutomationMsg_TabLoaded, OnTabLoaded) |
| 48 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardMessageToExternalHost, |
| 49 OnMessageToHost) |
| 50 IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuToExternalHost, |
| 51 OnHandleContextMenu) |
| 52 IPC_MESSAGE_HANDLER(AutomationMsg_RequestStart, OnNetwork_Start) |
| 53 IPC_MESSAGE_HANDLER(AutomationMsg_RequestRead, OnNetwork_Read) |
| 54 IPC_MESSAGE_HANDLER(AutomationMsg_RequestEnd, OnNetwork_End) |
| 55 IPC_MESSAGE_HANDLER(AutomationMsg_DownloadRequestInHost, |
| 56 OnNetwork_DownloadInHost) |
| 57 IPC_MESSAGE_HANDLER(AutomationMsg_GetCookiesFromHost, OnGetCookies) |
| 58 IPC_MESSAGE_HANDLER(AutomationMsg_SetCookieAsync, OnSetCookie) |
| 59 IPC_MESSAGE_HANDLER(AutomationMsg_AttachExternalTab, OnAttachTab) |
| 60 IPC_MESSAGE_HANDLER(AutomationMsg_RequestGoToHistoryEntryOffset, |
| 61 OnGoToHistoryOffset) |
| 62 IPC_MESSAGE_HANDLER(AutomationMsg_CloseExternalTab, OnTabClosed) |
| 63 IPC_END_MESSAGE_MAP() |
| 64 } |
| 65 |
37 void ExternalTabProxy::Init() { | 66 void ExternalTabProxy::Init() { |
38 if (m_hWnd == NULL) { | 67 if (m_hWnd == NULL) { |
39 // Create a window on the UI thread for marshaling messages back and forth | 68 // Create a window on the UI thread for marshaling messages back and forth |
40 // from the IPC thread. This window cannot be a message only window as the | 69 // from the IPC thread. This window cannot be a message only window as the |
41 // external chrome tab window initially is created as a child of this window | 70 // external chrome tab window initially is created as a child of this window |
42 CWindowImpl<ExternalTabProxy>::Create(GetDesktopWindow(), NULL, NULL, | 71 CWindowImpl<ExternalTabProxy>::Create(GetDesktopWindow(), NULL, NULL, |
43 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_TOOLWINDOW); | 72 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WS_EX_TOOLWINDOW); |
44 DCHECK(m_hWnd != NULL); | 73 DCHECK(m_hWnd != NULL); |
45 ui_.SetWindow(m_hWnd, WM_APP + 6); | 74 ui_.SetWindow(m_hWnd, WM_APP + 6); |
46 } | 75 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 110 } |
82 | 111 |
83 void ExternalTabProxy::Connected(ChromeProxy* proxy) { | 112 void ExternalTabProxy::Connected(ChromeProxy* proxy) { |
84 // in ipc thread | 113 // in ipc thread |
85 ui_.PostTask(FROM_HERE, NewRunnableMethod(this, | 114 ui_.PostTask(FROM_HERE, NewRunnableMethod(this, |
86 &ExternalTabProxy::UiConnected, proxy)); | 115 &ExternalTabProxy::UiConnected, proxy)); |
87 } | 116 } |
88 | 117 |
89 void ExternalTabProxy::UiConnected(ChromeProxy* proxy) { | 118 void ExternalTabProxy::UiConnected(ChromeProxy* proxy) { |
90 proxy_ = proxy; | 119 proxy_ = proxy; |
91 IPC::ExternalTabSettings settings; | 120 ExternalTabSettings settings; |
92 settings.parent = m_hWnd; | 121 settings.parent = m_hWnd; |
93 settings.style = WS_CHILD; | 122 settings.style = WS_CHILD; |
94 settings.is_off_the_record = tab_params_.is_incognito; | 123 settings.is_off_the_record = tab_params_.is_incognito; |
95 // TODO(stoyan): FIX this. | 124 // TODO(stoyan): FIX this. |
96 settings.load_requests_via_automation = true; | 125 settings.load_requests_via_automation = true; |
97 // TODO(stoyan): FIX this. | 126 // TODO(stoyan): FIX this. |
98 settings.handle_top_level_requests = true; | 127 settings.handle_top_level_requests = true; |
99 settings.initial_url = tab_params_.url; | 128 settings.initial_url = tab_params_.url; |
100 settings.referrer = tab_params_.referrer; | 129 settings.referrer = tab_params_.referrer; |
101 // Infobars are disabled in widget mode. | 130 // Infobars are disabled in widget mode. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 244 |
216 void ExternalTabProxy::Completed_CreateTab(bool success, HWND chrome_wnd, | 245 void ExternalTabProxy::Completed_CreateTab(bool success, HWND chrome_wnd, |
217 HWND tab_window, int tab_handle, | 246 HWND tab_window, int tab_handle, |
218 int session_id) { | 247 int session_id) { |
219 // in ipc_thread. | 248 // in ipc_thread. |
220 ui_.PostTask(FROM_HERE, NewRunnableMethod(this, | 249 ui_.PostTask(FROM_HERE, NewRunnableMethod(this, |
221 &ExternalTabProxy::UiCompleted_CreateTab, | 250 &ExternalTabProxy::UiCompleted_CreateTab, |
222 success, chrome_wnd, tab_window, tab_handle, session_id)); | 251 success, chrome_wnd, tab_window, tab_handle, session_id)); |
223 } | 252 } |
224 | 253 |
225 void ExternalTabProxy::Completed_ConnectToTab(bool success, | 254 void ExternalTabProxy::Completed_ConnectToTab( |
226 HWND chrome_window, HWND tab_window, int tab_handle, int session_id) { | 255 bool success, HWND chrome_window, HWND tab_window, int tab_handle, |
| 256 int session_id) { |
227 CHECK(0); | 257 CHECK(0); |
228 } | 258 } |
229 | 259 |
230 void ExternalTabProxy::Completed_Navigate(bool success, | 260 void ExternalTabProxy::Completed_Navigate( |
231 enum AutomationMsg_NavigationResponseValues res) { | 261 bool success, enum AutomationMsg_NavigationResponseValues res) { |
232 // ipc_thread; | 262 // ipc_thread; |
233 CHECK(0); | 263 CHECK(0); |
234 } | 264 } |
235 | 265 |
236 void ExternalTabProxy::Completed_InstallExtension(bool success, | 266 void ExternalTabProxy::Completed_InstallExtension( |
237 enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) { | 267 bool success, enum AutomationMsg_ExtensionResponseValues res, |
| 268 SyncMessageContext* ctx) { |
238 CHECK(0); | 269 CHECK(0); |
239 } | 270 } |
240 | 271 |
241 void ExternalTabProxy::Completed_LoadExpandedExtension(bool success, | 272 void ExternalTabProxy::Completed_LoadExpandedExtension( |
242 enum AutomationMsg_ExtensionResponseValues res, SyncMessageContext* ctx) { | 273 bool success, enum AutomationMsg_ExtensionResponseValues res, |
| 274 SyncMessageContext* ctx) { |
243 CHECK(0); | 275 CHECK(0); |
244 } | 276 } |
245 | 277 |
246 void ExternalTabProxy::Completed_GetEnabledExtensions(bool success, | 278 void ExternalTabProxy::Completed_GetEnabledExtensions( |
247 const std::vector<FilePath>* extensions) { | 279 bool success, const std::vector<FilePath>* extensions) { |
248 CHECK(0); | 280 CHECK(0); |
249 } | 281 } |
250 | 282 |
251 void ExternalTabProxy::NavigationStateChanged(int flags, | 283 void ExternalTabProxy::OnNavigationStateChanged( |
252 const IPC::NavigationInfo& nav_info) { | 284 int flags, const NavigationInfo& nav_info) { |
253 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 285 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
254 &UIDelegate::OnNavigationStateChanged, flags, nav_info)); | 286 &UIDelegate::OnNavigationStateChanged, flags, nav_info)); |
255 } | 287 } |
256 | 288 |
257 void ExternalTabProxy::UpdateTargetUrl(const std::wstring& url) { | 289 void ExternalTabProxy::OnUpdateTargetUrl(const std::wstring& url) { |
258 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 290 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
259 &UIDelegate::OnUpdateTargetUrl, url)); | 291 &UIDelegate::OnUpdateTargetUrl, url)); |
260 } | 292 } |
261 | 293 |
262 void ExternalTabProxy::TabLoaded(const GURL& url) { | 294 void ExternalTabProxy::OnTabLoaded(const GURL& url) { |
263 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 295 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
264 &UIDelegate::OnLoad, url)); | 296 &UIDelegate::OnLoad, url)); |
265 } | 297 } |
266 | 298 |
267 void ExternalTabProxy::MessageToHost(const std::string& message, | 299 void ExternalTabProxy::OnMessageToHost(const std::string& message, |
268 const std::string& origin, | 300 const std::string& origin, |
269 const std::string& target) { | 301 const std::string& target) { |
270 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 302 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
271 &UIDelegate::OnMessageFromChromeFrame, message, origin, target)); | 303 &UIDelegate::OnMessageFromChromeFrame, message, origin, target)); |
272 } | 304 } |
273 | 305 |
274 void ExternalTabProxy::HandleAccelerator(const MSG& accel_message) { | 306 void ExternalTabProxy::OnHandleAccelerator(const MSG& accel_message) { |
275 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 307 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
276 &UIDelegate::OnHandleAccelerator, accel_message)); | 308 &UIDelegate::OnHandleAccelerator, accel_message)); |
277 } | 309 } |
278 | 310 |
279 void ExternalTabProxy::HandleContextMenu( | 311 void ExternalTabProxy::OnHandleContextMenu( |
280 HANDLE menu_handle, | 312 HANDLE menu_handle, |
281 int align_flags, | 313 int align_flags, |
282 const IPC::MiniContextMenuParams& params) { | 314 const MiniContextMenuParams& params) { |
283 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 315 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
284 &UIDelegate::OnHandleContextMenu, menu_handle, align_flags, params)); | 316 &UIDelegate::OnHandleContextMenu, menu_handle, align_flags, params)); |
285 } | 317 } |
286 | 318 |
287 void ExternalTabProxy::TabbedOut(bool reverse) { | 319 void ExternalTabProxy::OnTabbedOut(bool reverse) { |
288 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 320 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
289 &UIDelegate::OnTabbedOut, reverse)); | 321 &UIDelegate::OnTabbedOut, reverse)); |
290 } | 322 } |
291 | 323 |
292 void ExternalTabProxy::GoToHistoryOffset(int offset) { | 324 void ExternalTabProxy::OnGoToHistoryOffset(int offset) { |
293 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 325 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
294 &UIDelegate::OnGoToHistoryOffset, offset)); | 326 &UIDelegate::OnGoToHistoryOffset, offset)); |
295 } | 327 } |
296 | 328 |
297 void ExternalTabProxy::OpenURL(const GURL& url_to_open, const GURL& referrer, | 329 void ExternalTabProxy::OnOpenURL(const GURL& url_to_open, const GURL& referrer, |
298 int open_disposition) { | 330 int open_disposition) { |
299 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, | 331 ui_.PostTask(FROM_HERE, NewRunnableMethod(ui_delegate_, |
300 &UIDelegate::OnOpenURL, url_to_open, referrer, open_disposition)); | 332 &UIDelegate::OnOpenURL, url_to_open, referrer, open_disposition)); |
301 } | 333 } |
302 | 334 |
303 void ExternalTabProxy::NavigationFailed(int error_code, const GURL& gurl) { | 335 void ExternalTabProxy::OnNavigationFailed(int error_code, const GURL& gurl) { |
304 // TODO(stoyan): | 336 // TODO(stoyan): |
305 } | 337 } |
306 | 338 |
307 void ExternalTabProxy::DidNavigate(const IPC::NavigationInfo& navigation_info) { | 339 void ExternalTabProxy::OnDidNavigate(const NavigationInfo& navigation_info) { |
308 // TODO(stoyan): | 340 // TODO(stoyan): |
309 } | 341 } |
310 | 342 |
311 void ExternalTabProxy::Network_Start( | 343 void ExternalTabProxy::OnNetwork_Start( |
312 int request_id, const IPC::AutomationURLRequest& request_info) { | 344 int request_id, const AutomationURLRequest& request_info) { |
313 // TODO(stoyan): url_fetcher_.Start(); | 345 // TODO(stoyan): url_fetcher_.Start(); |
314 } | 346 } |
315 | 347 |
316 void ExternalTabProxy::Network_Read(int request_id, int bytes_to_read) { | 348 void ExternalTabProxy::OnNetwork_Read(int request_id, int bytes_to_read) { |
317 // TODO(stoyan): url_fetcher_.Read(); | 349 // TODO(stoyan): url_fetcher_.Read(); |
318 } | 350 } |
319 | 351 |
320 void ExternalTabProxy::Network_End(int request_id, const URLRequestStatus& s) { | 352 void ExternalTabProxy::OnNetwork_End(int request_id, |
| 353 const URLRequestStatus& s) { |
321 // TODO(stoyan): | 354 // TODO(stoyan): |
322 } | 355 } |
323 | 356 |
324 void ExternalTabProxy::Network_DownloadInHost(int request_id) { | 357 void ExternalTabProxy::OnNetwork_DownloadInHost(int request_id) { |
325 // TODO(stoyan): | 358 // TODO(stoyan): |
326 } | 359 } |
327 | 360 |
328 void ExternalTabProxy::GetCookies(const GURL& url, int cookie_id) { | 361 void ExternalTabProxy::OnGetCookies(const GURL& url, int cookie_id) { |
329 // TODO(stoyan): | 362 // TODO(stoyan): |
330 } | 363 } |
331 | 364 |
332 void ExternalTabProxy::SetCookie(const GURL& url, const std::string& cookie) { | 365 void ExternalTabProxy::OnSetCookie(const GURL& url, const std::string& cookie) { |
333 // TODO(stoyan): | 366 // TODO(stoyan): |
334 } | 367 } |
335 | 368 |
336 void ExternalTabProxy::TabClosed() { | 369 void ExternalTabProxy::OnTabClosed() { |
337 // TODO(stoyan): | 370 // TODO(stoyan): |
338 } | 371 } |
339 | 372 |
340 void ExternalTabProxy::AttachTab( | 373 void ExternalTabProxy::OnAttachTab( |
341 const IPC::AttachExternalTabParams& attach_params) { | 374 const AttachExternalTabParams& attach_params) { |
342 // TODO(stoyan): | 375 // TODO(stoyan): |
343 } | 376 } |
OLD | NEW |