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 #include "chrome_frame/chrome_frame_automation.h" | 5 #include "chrome_frame/chrome_frame_automation.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 navigate_after_initialization_(false) { | 443 navigate_after_initialization_(false) { |
444 } | 444 } |
445 | 445 |
446 ChromeFrameAutomationClient::~ChromeFrameAutomationClient() { | 446 ChromeFrameAutomationClient::~ChromeFrameAutomationClient() { |
447 // Uninitialize must be called prior to the destructor | 447 // Uninitialize must be called prior to the destructor |
448 DCHECK(automation_server_ == NULL); | 448 DCHECK(automation_server_ == NULL); |
449 } | 449 } |
450 | 450 |
451 bool ChromeFrameAutomationClient::Initialize( | 451 bool ChromeFrameAutomationClient::Initialize( |
452 ChromeFrameDelegate* chrome_frame_delegate, | 452 ChromeFrameDelegate* chrome_frame_delegate, |
453 const ChromeFrameLaunchParams& chrome_launch_params) { | 453 int automation_server_launch_timeout, |
| 454 bool perform_version_check, |
| 455 const std::wstring& profile_name, |
| 456 const std::wstring& extra_chrome_arguments, |
| 457 bool incognito) { |
454 DCHECK(!IsWindow()); | 458 DCHECK(!IsWindow()); |
455 chrome_frame_delegate_ = chrome_frame_delegate; | 459 chrome_frame_delegate_ = chrome_frame_delegate; |
456 chrome_launch_params_ = chrome_launch_params; | |
457 ui_thread_id_ = PlatformThread::CurrentId(); | 460 ui_thread_id_ = PlatformThread::CurrentId(); |
458 #ifndef NDEBUG | 461 #ifndef NDEBUG |
459 // In debug mode give more time to work with a debugger. | 462 // In debug mode give more time to work with a debugger. |
460 if (IsDebuggerPresent()) { | 463 if (IsDebuggerPresent()) { |
461 // Don't use INFINITE (which is -1) or even MAXINT since we will convert | 464 // Don't use INFINITE (which is -1) or even MAXINT since we will convert |
462 // from milliseconds to microseconds when stored in a base::TimeDelta, | 465 // from milliseconds to microseconds when stored in a base::TimeDelta, |
463 // thus * 1000. An hour should be enough. | 466 // thus * 1000. An hour should be enough. |
464 chrome_launch_params_.automation_server_launch_timeout = 60 * 60 * 1000; | 467 automation_server_launch_timeout = 60 * 60 * 1000; |
465 } else { | 468 } else { |
466 DCHECK_LT(chrome_launch_params_.automation_server_launch_timeout, | 469 DCHECK_LT(automation_server_launch_timeout, MAXINT / 2000); |
467 MAXINT / 2000); | 470 automation_server_launch_timeout *= 2; |
468 chrome_launch_params_.automation_server_launch_timeout *= 2; | |
469 } | 471 } |
470 #endif // NDEBUG | 472 #endif // NDEBUG |
471 | 473 |
472 // Create a window on the UI thread for marshaling messages back and forth | 474 // Create a window on the UI thread for marshaling messages back and forth |
473 // from the IPC thread. This window cannot be a message only window as the | 475 // from the IPC thread. This window cannot be a message only window as the |
474 // external chrome tab window is created as a child of this window. This | 476 // external chrome tab window is created as a child of this window. This |
475 // window is eventually reparented to the ActiveX/NPAPI plugin window. | 477 // window is eventually reparented to the ActiveX/NPAPI plugin window. |
476 if (!Create(GetDesktopWindow(), NULL, NULL, | 478 if (!Create(GetDesktopWindow(), NULL, NULL, |
477 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, | 479 WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
478 WS_EX_TOOLWINDOW)) { | 480 WS_EX_TOOLWINDOW)) { |
479 NOTREACHED(); | 481 NOTREACHED(); |
480 return false; | 482 return false; |
481 } | 483 } |
482 | 484 |
483 // Keep object in memory, while the window is alive. | 485 // Keep object in memory, while the window is alive. |
484 // Corresponsing Release is in OnFinalMessage(); | 486 // Corresponsing Release is in OnFinalMessage(); |
485 AddRef(); | 487 AddRef(); |
486 | 488 |
487 // Mark our state as initializing. We'll reach initialized once | 489 // Mark our state as initializing. We'll reach initialized once |
488 // InitializeComplete is called successfully. | 490 // InitializeComplete is called successfully. |
489 init_state_ = INITIALIZING; | 491 init_state_ = INITIALIZING; |
490 | 492 |
491 if (navigate_after_initialization_) { | 493 chrome_launch_params_.automation_server_launch_timeout = |
492 chrome_launch_params_.url = url_; | 494 automation_server_launch_timeout; |
493 } | 495 chrome_launch_params_.profile_name = profile_name; |
| 496 chrome_launch_params_.extra_chrome_arguments = extra_chrome_arguments; |
| 497 chrome_launch_params_.perform_version_check = perform_version_check; |
| 498 chrome_launch_params_.url = navigate_after_initialization_ ? GURL() : url_; |
| 499 chrome_launch_params_.incognito_mode = incognito; |
494 | 500 |
495 proxy_factory_->GetAutomationServer( | 501 proxy_factory_->GetAutomationServer( |
496 static_cast<ProxyFactory::LaunchDelegate*>(this), | 502 static_cast<ProxyFactory::LaunchDelegate*>(this), |
497 chrome_launch_params_, &automation_server_id_); | 503 chrome_launch_params_, &automation_server_id_); |
498 | 504 |
499 return true; | 505 return true; |
500 } | 506 } |
501 | 507 |
502 void ChromeFrameAutomationClient::Uninitialize() { | 508 void ChromeFrameAutomationClient::Uninitialize() { |
503 DLOG(INFO) << __FUNCTION__; | 509 DLOG(INFO) << __FUNCTION__; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 // We should pass in the referrer for the initial navigation. | 834 // We should pass in the referrer for the initial navigation. |
829 const IPC::ExternalTabSettings settings = { | 835 const IPC::ExternalTabSettings settings = { |
830 m_hWnd, | 836 m_hWnd, |
831 gfx::Rect(), | 837 gfx::Rect(), |
832 WS_CHILD, | 838 WS_CHILD, |
833 chrome_launch_params_.incognito_mode, | 839 chrome_launch_params_.incognito_mode, |
834 !use_chrome_network_, | 840 !use_chrome_network_, |
835 handle_top_level_requests_, | 841 handle_top_level_requests_, |
836 chrome_launch_params_.url, | 842 chrome_launch_params_.url, |
837 chrome_launch_params_.referrer, | 843 chrome_launch_params_.referrer, |
838 !chrome_launch_params_.is_widget_mode // Infobars disabled in widget mode. | |
839 }; | 844 }; |
840 | 845 |
841 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( | 846 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( |
842 "ChromeFrame.HostNetworking", !use_chrome_network_, 0, 1, 2); | 847 "ChromeFrame.HostNetworking", !use_chrome_network_, 0, 1, 2); |
843 | 848 |
844 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( | 849 THREAD_SAFE_UMA_HISTOGRAM_CUSTOM_COUNTS( |
845 "ChromeFrame.HandleTopLevelRequests", handle_top_level_requests_, 0, 1, | 850 "ChromeFrame.HandleTopLevelRequests", handle_top_level_requests_, 0, 1, |
846 2); | 851 2); |
847 | 852 |
848 IPC::SyncMessage* message = | 853 IPC::SyncMessage* message = |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 automation_server_->Send(new AutomationMsg_RequestData(0, tab_->handle(), | 1234 automation_server_->Send(new AutomationMsg_RequestData(0, tab_->handle(), |
1230 request_id, data)); | 1235 request_id, data)); |
1231 } | 1236 } |
1232 | 1237 |
1233 void ChromeFrameAutomationClient::OnResponseEnd(int request_id, | 1238 void ChromeFrameAutomationClient::OnResponseEnd(int request_id, |
1234 const URLRequestStatus& status) { | 1239 const URLRequestStatus& status) { |
1235 automation_server_->Send(new AutomationMsg_RequestEnd(0, tab_->handle(), | 1240 automation_server_->Send(new AutomationMsg_RequestEnd(0, tab_->handle(), |
1236 request_id, status)); | 1241 request_id, status)); |
1237 } | 1242 } |
1238 | 1243 |
OLD | NEW |