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 "app/app_switches.h" | 7 #include "app/app_switches.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/file_version_info.h" | 13 #include "base/file_version_info.h" |
14 #include "base/lock.h" | 14 #include "base/lock.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
17 #include "base/process_util.h" | 17 #include "base/process_util.h" |
18 #include "base/singleton.h" | 18 #include "base/singleton.h" |
19 #include "base/string_util.h" | 19 #include "base/string_util.h" |
20 #include "base/sys_info.h" | 20 #include "base/sys_info.h" |
21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
22 #include "base/waitable_event.h" | 22 #include "base/waitable_event.h" |
23 #include "chrome/app/client_util.h" | 23 #include "chrome/app/client_util.h" |
24 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/test/automation/tab_proxy.h" | 26 #include "chrome/test/automation/tab_proxy.h" |
27 #include "chrome_frame/chrome_launcher_utils.h" | 27 #include "chrome_frame/chrome_launcher_utils.h" |
28 #include "chrome_frame/crash_reporting/crash_metrics.h" | 28 #include "chrome_frame/crash_reporting/crash_metrics.h" |
29 #include "chrome_frame/custom_sync_call_context.h" | 29 #include "chrome_frame/custom_sync_call_context.h" |
| 30 #include "chrome_frame/navigation_constraints.h" |
30 #include "chrome_frame/simple_resource_loader.h" | 31 #include "chrome_frame/simple_resource_loader.h" |
31 #include "chrome_frame/utils.h" | 32 #include "chrome_frame/utils.h" |
32 | 33 |
33 #ifdef NDEBUG | 34 #ifdef NDEBUG |
34 int64 kAutomationServerReasonableLaunchDelay = 1000; // in milliseconds | 35 int64 kAutomationServerReasonableLaunchDelay = 1000; // in milliseconds |
35 #else | 36 #else |
36 int64 kAutomationServerReasonableLaunchDelay = 1000 * 10; | 37 int64 kAutomationServerReasonableLaunchDelay = 1000 * 10; |
37 #endif | 38 #endif |
38 | 39 |
39 int kDefaultSendUMADataInterval = 20000; // in milliseconds. | 40 int kDefaultSendUMADataInterval = 20000; // in milliseconds. |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 648 |
648 // Keep object in memory, while the window is alive. | 649 // Keep object in memory, while the window is alive. |
649 // Corresponding Release is in OnFinalMessage(); | 650 // Corresponding Release is in OnFinalMessage(); |
650 AddRef(); | 651 AddRef(); |
651 | 652 |
652 // Mark our state as initializing. We'll reach initialized once | 653 // Mark our state as initializing. We'll reach initialized once |
653 // InitializeComplete is called successfully. | 654 // InitializeComplete is called successfully. |
654 init_state_ = INITIALIZING; | 655 init_state_ = INITIALIZING; |
655 | 656 |
656 HRESULT hr = S_OK; | 657 HRESULT hr = S_OK; |
657 // If chrome crashed and is being restarted, the security_manager_ object | |
658 // might already be valid. | |
659 if (security_manager_.get() == NULL) | |
660 hr = security_manager_.CreateInstance(CLSID_InternetSecurityManager); | |
661 | |
662 if (FAILED(hr)) { | |
663 NOTREACHED() << __FUNCTION__ | |
664 << " Failed to create InternetSecurityManager. Error: 0x%x" | |
665 << hr; | |
666 } | |
667 | 658 |
668 if (chrome_launch_params_->url().is_valid()) | 659 if (chrome_launch_params_->url().is_valid()) |
669 navigate_after_initialization_ = false; | 660 navigate_after_initialization_ = false; |
670 | 661 |
671 proxy_factory_->GetAutomationServer(static_cast<LaunchDelegate*>(this), | 662 proxy_factory_->GetAutomationServer(static_cast<LaunchDelegate*>(this), |
672 chrome_launch_params_, &automation_server_id_); | 663 chrome_launch_params_, &automation_server_id_); |
673 | 664 |
674 return true; | 665 return true; |
675 } | 666 } |
676 | 667 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
713 if (::IsWindow(m_hWnd)) | 704 if (::IsWindow(m_hWnd)) |
714 DestroyWindow(); | 705 DestroyWindow(); |
715 | 706 |
716 // DCHECK(navigate_after_initialization_ == false); | 707 // DCHECK(navigate_after_initialization_ == false); |
717 handle_top_level_requests_ = false; | 708 handle_top_level_requests_ = false; |
718 ui_thread_id_ = 0; | 709 ui_thread_id_ = 0; |
719 chrome_frame_delegate_ = NULL; | 710 chrome_frame_delegate_ = NULL; |
720 init_state_ = UNINITIALIZED; | 711 init_state_ = UNINITIALIZED; |
721 } | 712 } |
722 | 713 |
723 bool ChromeFrameAutomationClient::InitiateNavigation(const std::string& url, | 714 bool ChromeFrameAutomationClient::InitiateNavigation( |
724 const std::string& referrer, bool is_privileged) { | 715 const std::string& url, |
| 716 const std::string& referrer, |
| 717 NavigationConstraints* navigation_constraints) { |
725 if (url.empty()) | 718 if (url.empty()) |
726 return false; | 719 return false; |
727 | 720 |
728 GURL parsed_url(url); | 721 GURL parsed_url(url); |
729 | 722 |
730 // Catch invalid URLs early. | 723 // Catch invalid URLs early. |
731 // Can we allow this navigation to happen? | 724 // Can we allow this navigation to happen? |
732 if (!CanNavigate(parsed_url, security_manager_, is_privileged)) { | 725 if (!CanNavigate(parsed_url, navigation_constraints)) { |
733 DLOG(ERROR) << __FUNCTION__ << " Not allowing navigation to: " << url; | 726 DLOG(ERROR) << __FUNCTION__ << " Not allowing navigation to: " << url; |
734 return false; | 727 return false; |
735 } | 728 } |
736 | 729 |
737 // If we are not yet initialized ignore attempts to navigate to the same url. | 730 // If we are not yet initialized ignore attempts to navigate to the same url. |
738 // Navigation attempts to the same URL could occur if the automation client | 731 // Navigation attempts to the same URL could occur if the automation client |
739 // was reused for a new active document instance. | 732 // was reused for a new active document instance. |
740 if (!chrome_launch_params_ || is_initialized() || | 733 if (!chrome_launch_params_ || is_initialized() || |
741 parsed_url != chrome_launch_params_->url()) { | 734 parsed_url != chrome_launch_params_->url()) { |
742 // Important: Since we will be using the referrer_ variable from a | 735 // Important: Since we will be using the referrer_ variable from a |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 const URLRequestStatus& status) { | 1467 const URLRequestStatus& status) { |
1475 automation_server_->Send(new AutomationMsg_RequestEnd(0, tab_->handle(), | 1468 automation_server_->Send(new AutomationMsg_RequestEnd(0, tab_->handle(), |
1476 request_id, status)); | 1469 request_id, status)); |
1477 } | 1470 } |
1478 | 1471 |
1479 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, | 1472 void ChromeFrameAutomationClient::OnCookiesRetrieved(bool success, |
1480 const GURL& url, const std::string& cookie_string, int cookie_id) { | 1473 const GURL& url, const std::string& cookie_string, int cookie_id) { |
1481 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse(0, | 1474 automation_server_->Send(new AutomationMsg_GetCookiesHostResponse(0, |
1482 tab_->handle(), success, url, cookie_string, cookie_id)); | 1475 tab_->handle(), success, url, cookie_string, cookie_id)); |
1483 } | 1476 } |
OLD | NEW |