| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 #include "components/network_time/network_time_tracker.h" | 53 #include "components/network_time/network_time_tracker.h" |
| 54 #include "components/prefs/pref_service.h" | 54 #include "components/prefs/pref_service.h" |
| 55 #include "components/security_interstitials/core/controller_client.h" | 55 #include "components/security_interstitials/core/controller_client.h" |
| 56 #include "components/security_interstitials/core/metrics_helper.h" | 56 #include "components/security_interstitials/core/metrics_helper.h" |
| 57 #include "components/security_state/security_state_model.h" | 57 #include "components/security_state/security_state_model.h" |
| 58 #include "components/security_state/switches.h" | 58 #include "components/security_state/switches.h" |
| 59 #include "components/ssl_errors/error_classification.h" | 59 #include "components/ssl_errors/error_classification.h" |
| 60 #include "components/variations/variations_associated_data.h" | 60 #include "components/variations/variations_associated_data.h" |
| 61 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 61 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 62 #include "content/public/browser/browser_context.h" | 62 #include "content/public/browser/browser_context.h" |
| 63 #include "content/public/browser/cert_store.h" | |
| 64 #include "content/public/browser/interstitial_page.h" | 63 #include "content/public/browser/interstitial_page.h" |
| 65 #include "content/public/browser/navigation_controller.h" | 64 #include "content/public/browser/navigation_controller.h" |
| 66 #include "content/public/browser/navigation_entry.h" | 65 #include "content/public/browser/navigation_entry.h" |
| 67 #include "content/public/browser/notification_service.h" | 66 #include "content/public/browser/notification_service.h" |
| 68 #include "content/public/browser/render_frame_host.h" | 67 #include "content/public/browser/render_frame_host.h" |
| 69 #include "content/public/browser/render_view_host.h" | 68 #include "content/public/browser/render_view_host.h" |
| 70 #include "content/public/browser/render_widget_host_view.h" | 69 #include "content/public/browser/render_widget_host_view.h" |
| 71 #include "content/public/browser/web_contents.h" | 70 #include "content/public/browser/web_contents.h" |
| 72 #include "content/public/browser/web_contents_observer.h" | 71 #include "content/public/browser/web_contents_observer.h" |
| 73 #include "content/public/common/content_switches.h" | 72 #include "content/public/common/content_switches.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 } | 250 } |
| 252 | 251 |
| 253 const content::WebContents* web_contents_; | 252 const content::WebContents* web_contents_; |
| 254 SSLErrorHandler::TimerStartedCallback callback_; | 253 SSLErrorHandler::TimerStartedCallback callback_; |
| 255 | 254 |
| 256 std::unique_ptr<base::RunLoop> message_loop_runner_; | 255 std::unique_ptr<base::RunLoop> message_loop_runner_; |
| 257 | 256 |
| 258 DISALLOW_COPY_AND_ASSIGN(SSLInterstitialTimerObserver); | 257 DISALLOW_COPY_AND_ASSIGN(SSLInterstitialTimerObserver); |
| 259 }; | 258 }; |
| 260 | 259 |
| 261 // Checks that two SSLStatuses will result in the same security UI: that | |
| 262 // is, the cert ids can differ as long as they refer to the same cert, | |
| 263 // and otherwise SSLStatus::Equals() must be true. | |
| 264 void CheckSSLStatusesEquals(const content::SSLStatus& one, | |
| 265 const content::SSLStatus& two) { | |
| 266 content::CertStore* cert_store = content::CertStore::GetInstance(); | |
| 267 scoped_refptr<net::X509Certificate> cert1; | |
| 268 scoped_refptr<net::X509Certificate> cert2; | |
| 269 cert_store->RetrieveCert(one.cert_id, &cert1); | |
| 270 cert_store->RetrieveCert(two.cert_id, &cert2); | |
| 271 EXPECT_TRUE(cert1 && cert2); | |
| 272 EXPECT_TRUE(cert1->Equals(cert2.get())); | |
| 273 | |
| 274 SSLStatus one_without_cert_id = one; | |
| 275 one_without_cert_id.cert_id = 0; | |
| 276 SSLStatus two_without_cert_id = two; | |
| 277 two_without_cert_id.cert_id = 0; | |
| 278 EXPECT_TRUE(one_without_cert_id.Equals(two_without_cert_id)); | |
| 279 } | |
| 280 | |
| 281 class HungJob : public net::URLRequestJob { | 260 class HungJob : public net::URLRequestJob { |
| 282 public: | 261 public: |
| 283 HungJob(net::URLRequest* request, net::NetworkDelegate* network_delegate) | 262 HungJob(net::URLRequest* request, net::NetworkDelegate* network_delegate) |
| 284 : net::URLRequestJob(request, network_delegate) {} | 263 : net::URLRequestJob(request, network_delegate) {} |
| 285 | 264 |
| 286 void Start() override { | 265 void Start() override { |
| 287 } | 266 } |
| 288 }; | 267 }; |
| 289 | 268 |
| 290 class FaviconFilter : public net::URLRequestInterceptor { | 269 class FaviconFilter : public net::URLRequestInterceptor { |
| (...skipping 2404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2695 content::NavigationEntry* entry = tab->GetController().GetActiveEntry(); | 2674 content::NavigationEntry* entry = tab->GetController().GetActiveEntry(); |
| 2696 ASSERT_TRUE(entry); | 2675 ASSERT_TRUE(entry); |
| 2697 content::SSLStatus interstitial_ssl_status = entry->GetSSL(); | 2676 content::SSLStatus interstitial_ssl_status = entry->GetSSL(); |
| 2698 | 2677 |
| 2699 ProceedThroughInterstitial(tab); | 2678 ProceedThroughInterstitial(tab); |
| 2700 EXPECT_FALSE(tab->ShowingInterstitialPage()); | 2679 EXPECT_FALSE(tab->ShowingInterstitialPage()); |
| 2701 entry = tab->GetController().GetActiveEntry(); | 2680 entry = tab->GetController().GetActiveEntry(); |
| 2702 ASSERT_TRUE(entry); | 2681 ASSERT_TRUE(entry); |
| 2703 | 2682 |
| 2704 content::SSLStatus after_interstitial_ssl_status = entry->GetSSL(); | 2683 content::SSLStatus after_interstitial_ssl_status = entry->GetSSL(); |
| 2705 ASSERT_NO_FATAL_FAILURE(CheckSSLStatusesEquals(after_interstitial_ssl_status, | 2684 ASSERT_NO_FATAL_FAILURE( |
| 2706 interstitial_ssl_status)); | 2685 after_interstitial_ssl_status.Equals(interstitial_ssl_status)); |
| 2707 } | 2686 } |
| 2708 | 2687 |
| 2709 // As above, but for a bad clock interstitial. Tests that a clock | 2688 // As above, but for a bad clock interstitial. Tests that a clock |
| 2710 // interstitial's SSLStatus matches the SSLStatus of the HTTPS page | 2689 // interstitial's SSLStatus matches the SSLStatus of the HTTPS page |
| 2711 // after proceeding through a normal SSL interstitial. | 2690 // after proceeding through a normal SSL interstitial. |
| 2712 IN_PROC_BROWSER_TEST_F(SSLUITest, | 2691 IN_PROC_BROWSER_TEST_F(SSLUITest, |
| 2713 SSLStatusMatchesonClockInterstitialAndAfterProceed) { | 2692 SSLStatusMatchesonClockInterstitialAndAfterProceed) { |
| 2714 ASSERT_TRUE(https_server_expired_.Start()); | 2693 ASSERT_TRUE(https_server_expired_.Start()); |
| 2715 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2694 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2716 ASSERT_TRUE(tab); | 2695 ASSERT_TRUE(tab); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2746 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2725 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
| 2747 ssl_interstitial->GetDelegateForTesting()->GetTypeForTesting()); | 2726 ssl_interstitial->GetDelegateForTesting()->GetTypeForTesting()); |
| 2748 ProceedThroughInterstitial(tab); | 2727 ProceedThroughInterstitial(tab); |
| 2749 EXPECT_FALSE(tab->ShowingInterstitialPage()); | 2728 EXPECT_FALSE(tab->ShowingInterstitialPage()); |
| 2750 | 2729 |
| 2751 // Grab the SSLStatus from the page and check that it is the same as | 2730 // Grab the SSLStatus from the page and check that it is the same as |
| 2752 // on the clock interstitial. | 2731 // on the clock interstitial. |
| 2753 entry = tab->GetController().GetActiveEntry(); | 2732 entry = tab->GetController().GetActiveEntry(); |
| 2754 ASSERT_TRUE(entry); | 2733 ASSERT_TRUE(entry); |
| 2755 content::SSLStatus after_interstitial_ssl_status = entry->GetSSL(); | 2734 content::SSLStatus after_interstitial_ssl_status = entry->GetSSL(); |
| 2756 ASSERT_NO_FATAL_FAILURE(CheckSSLStatusesEquals( | 2735 ASSERT_NO_FATAL_FAILURE( |
| 2757 after_interstitial_ssl_status, clock_interstitial_ssl_status)); | 2736 after_interstitial_ssl_status.Equals(clock_interstitial_ssl_status)); |
| 2758 } | 2737 } |
| 2759 | 2738 |
| 2760 class CommonNameMismatchBrowserTest : public CertVerifierBrowserTest { | 2739 class CommonNameMismatchBrowserTest : public CertVerifierBrowserTest { |
| 2761 public: | 2740 public: |
| 2762 CommonNameMismatchBrowserTest() : CertVerifierBrowserTest() {} | 2741 CommonNameMismatchBrowserTest() : CertVerifierBrowserTest() {} |
| 2763 ~CommonNameMismatchBrowserTest() override {} | 2742 ~CommonNameMismatchBrowserTest() override {} |
| 2764 | 2743 |
| 2765 void SetUpCommandLine(base::CommandLine* command_line) override { | 2744 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 2766 // Enable finch experiment for SSL common name mismatch handling. | 2745 // Enable finch experiment for SSL common name mismatch handling. |
| 2767 command_line->AppendSwitchASCII(switches::kForceFieldTrials, | 2746 command_line->AppendSwitchASCII(switches::kForceFieldTrials, |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3271 | 3250 |
| 3272 // Visit a page over https that contains a frame with a redirect. | 3251 // Visit a page over https that contains a frame with a redirect. |
| 3273 | 3252 |
| 3274 // XMLHttpRequest insecure content in synchronous mode. | 3253 // XMLHttpRequest insecure content in synchronous mode. |
| 3275 | 3254 |
| 3276 // XMLHttpRequest insecure content in asynchronous mode. | 3255 // XMLHttpRequest insecure content in asynchronous mode. |
| 3277 | 3256 |
| 3278 // XMLHttpRequest over bad ssl in synchronous mode. | 3257 // XMLHttpRequest over bad ssl in synchronous mode. |
| 3279 | 3258 |
| 3280 // XMLHttpRequest over OK ssl in synchronous mode. | 3259 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |