| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/ssl/ssl_error_handler.h" | 5 #include "chrome/browser/ssl/ssl_error_handler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/feature_list.h" | 11 #include "base/feature_list.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/time/clock.h" | 17 #include "base/time/clock.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/ssl/bad_clock_blocking_page.h" | 21 #include "chrome/browser/ssl/bad_clock_blocking_page.h" |
| 22 #include "chrome/browser/ssl/ssl_blocking_page.h" | 22 #include "chrome/browser/ssl/ssl_blocking_page.h" |
| 23 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 23 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 24 #include "chrome/common/features.h" | 24 #include "chrome/common/features.h" |
| 25 #include "components/network_time/network_time_tracker.h" | 25 #include "components/network_time/network_time_tracker.h" |
| 26 #include "components/ssl_errors/error_classification.h" | 26 #include "components/ssl_errors/error_classification.h" |
| 27 #include "components/ssl_errors/error_info.h" | 27 #include "components/ssl_errors/error_info.h" |
| 28 #include "content/public/browser/navigation_handle.h" |
| 28 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 29 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
| 30 #include "content/public/browser/render_frame_host.h" | 31 #include "content/public/browser/render_frame_host.h" |
| 31 #include "content/public/browser/web_contents.h" | 32 #include "content/public/browser/web_contents.h" |
| 32 #include "net/base/net_errors.h" | 33 #include "net/base/net_errors.h" |
| 33 | 34 |
| 34 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 35 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 35 #include "chrome/browser/captive_portal/captive_portal_service.h" | 36 #include "chrome/browser/captive_portal/captive_portal_service.h" |
| 36 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" | 37 #include "chrome/browser/captive_portal/captive_portal_service_factory.h" |
| 37 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 38 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 timer_.Stop(); | 462 timer_.Stop(); |
| 462 CaptivePortalService::Results* results = | 463 CaptivePortalService::Results* results = |
| 463 content::Details<CaptivePortalService::Results>(details).ptr(); | 464 content::Details<CaptivePortalService::Results>(details).ptr(); |
| 464 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) | 465 if (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL) |
| 465 ShowCaptivePortalInterstitial(results->landing_url); | 466 ShowCaptivePortalInterstitial(results->landing_url); |
| 466 else | 467 else |
| 467 ShowSSLInterstitial(); | 468 ShowSSLInterstitial(); |
| 468 #endif | 469 #endif |
| 469 } | 470 } |
| 470 | 471 |
| 471 void SSLErrorHandler::DidStartNavigationToPendingEntry( | 472 void SSLErrorHandler::DidStartNavigation( |
| 472 const GURL& /* url */, | 473 content::NavigationHandle* navigation_handle) { |
| 473 content::ReloadType /* reload_type */) { | 474 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) |
| 475 return; |
| 476 |
| 474 // Destroy the error handler on all new navigations. This ensures that the | 477 // Destroy the error handler on all new navigations. This ensures that the |
| 475 // handler is properly recreated when a hanging page is navigated to an SSL | 478 // handler is properly recreated when a hanging page is navigated to an SSL |
| 476 // error, even when the tab's WebContents doesn't change. | 479 // error, even when the tab's WebContents doesn't change. |
| 477 DeleteSSLErrorHandler(); | 480 DeleteSSLErrorHandler(); |
| 478 } | 481 } |
| 479 | 482 |
| 480 void SSLErrorHandler::NavigationStopped() { | 483 void SSLErrorHandler::NavigationStopped() { |
| 481 // Destroy the error handler when the page load is stopped. | 484 // Destroy the error handler when the page load is stopped. |
| 482 DeleteSSLErrorHandler(); | 485 DeleteSSLErrorHandler(); |
| 483 } | 486 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 network_time::NetworkTimeTracker* tracker = | 541 network_time::NetworkTimeTracker* tracker = |
| 539 g_config.Pointer()->network_time_tracker(); | 542 g_config.Pointer()->network_time_tracker(); |
| 540 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); | 543 ssl_errors::ClockState clock_state = ssl_errors::GetClockState(now, tracker); |
| 541 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || | 544 if (clock_state == ssl_errors::CLOCK_STATE_FUTURE || |
| 542 clock_state == ssl_errors::CLOCK_STATE_PAST) { | 545 clock_state == ssl_errors::CLOCK_STATE_PAST) { |
| 543 ShowBadClockInterstitial(now, clock_state); | 546 ShowBadClockInterstitial(now, clock_state); |
| 544 return; // |this| is deleted after showing the interstitial. | 547 return; // |this| is deleted after showing the interstitial. |
| 545 } | 548 } |
| 546 ShowSSLInterstitial(); | 549 ShowSSLInterstitial(); |
| 547 } | 550 } |
| OLD | NEW |