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