| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef CHROME_BROWSER_SSL_BAD_CLOCK_BLOCKING_PAGE_H_ | 5 #ifndef CHROME_BROWSER_SSL_BAD_CLOCK_BLOCKING_PAGE_H_ |
| 6 #define CHROME_BROWSER_SSL_BAD_CLOCK_BLOCKING_PAGE_H_ | 6 #define CHROME_BROWSER_SSL_BAD_CLOCK_BLOCKING_PAGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "chrome/browser/interstitials/security_interstitial_page.h" | 12 #include "chrome/browser/interstitials/security_interstitial_page.h" |
| 13 #include "chrome/browser/ssl/ssl_cert_reporter.h" | 13 #include "chrome/browser/ssl/ssl_cert_reporter.h" |
| 14 #include "net/ssl/ssl_info.h" | 14 #include "net/ssl/ssl_info.h" |
| 15 | 15 |
| 16 class CertReportHelper; | 16 class CertReportHelper; |
| 17 class GURL; | 17 class GURL; |
| 18 | 18 |
| 19 // This class is responsible for showing/hiding the interstitial page that is | 19 namespace security_interstitials { |
| 20 // shown when a certificate error happens. This error is not overridable. | 20 class BadClockUI; |
| 21 // It deletes itself when the interstitial page is closed. | 21 } |
| 22 |
| 23 // This class is responsible for showing/hiding the interstitial page that |
| 24 // occurs when an SSL error is triggered by a clock misconfiguration. It |
| 25 // creates the UI using security_interstitials::BadClockUI and then |
| 26 // displays it. It deletes itself when the interstitial page is closed. |
| 22 class BadClockBlockingPage : public SecurityInterstitialPage { | 27 class BadClockBlockingPage : public SecurityInterstitialPage { |
| 23 public: | 28 public: |
| 24 // Interstitial type, used in tests. | 29 // Interstitial type, used in tests. |
| 25 static InterstitialPageDelegate::TypeID kTypeForTesting; | 30 static InterstitialPageDelegate::TypeID kTypeForTesting; |
| 26 | 31 |
| 27 // Creates a bad clock interstitial. If the blocking page isn't shown, the | 32 // If the blocking page isn't shown, the caller is responsible for cleaning |
| 28 // caller is responsible for cleaning up the blocking page, otherwise the | 33 // up the blocking page. Otherwise, the interstitial takes ownership when |
| 29 // interstitial takes ownership when shown. | 34 // shown. |
| 30 BadClockBlockingPage(content::WebContents* web_contents, | 35 BadClockBlockingPage(content::WebContents* web_contents, |
| 31 int cert_error, | 36 int cert_error, |
| 32 const net::SSLInfo& ssl_info, | 37 const net::SSLInfo& ssl_info, |
| 33 const GURL& request_url, | 38 const GURL& request_url, |
| 34 const base::Time& time_triggered, | 39 const base::Time& time_triggered, |
| 35 scoped_ptr<SSLCertReporter> ssl_cert_reporter, | 40 scoped_ptr<SSLCertReporter> ssl_cert_reporter, |
| 36 const base::Callback<void(bool)>& callback); | 41 const base::Callback<void(bool)>& callback); |
| 37 | 42 |
| 38 ~BadClockBlockingPage() override; | 43 ~BadClockBlockingPage() override; |
| 39 | 44 |
| 40 // InterstitialPageDelegate method: | 45 // InterstitialPageDelegate method: |
| 41 InterstitialPageDelegate::TypeID GetTypeForTesting() const override; | 46 InterstitialPageDelegate::TypeID GetTypeForTesting() const override; |
| 42 | 47 |
| 43 void SetSSLCertReporterForTesting( | 48 void SetSSLCertReporterForTesting( |
| 44 scoped_ptr<SSLCertReporter> ssl_cert_reporter); | 49 scoped_ptr<SSLCertReporter> ssl_cert_reporter); |
| 45 | 50 |
| 46 protected: | 51 protected: |
| 47 // InterstitialPageDelegate implementation. | 52 // InterstitialPageDelegate implementation: |
| 48 void CommandReceived(const std::string& command) override; | 53 void CommandReceived(const std::string& command) override; |
| 49 void OverrideEntry(content::NavigationEntry* entry) override; | 54 void OverrideEntry(content::NavigationEntry* entry) override; |
| 50 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; | 55 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; |
| 51 void OnDontProceed() override; | 56 void OnDontProceed() override; |
| 52 | 57 |
| 53 // SecurityInterstitialPage implementation: | 58 // SecurityInterstitialPage implementation: |
| 54 bool ShouldCreateNewNavigation() const override; | 59 bool ShouldCreateNewNavigation() const override; |
| 55 void PopulateInterstitialStrings( | 60 void PopulateInterstitialStrings( |
| 56 base::DictionaryValue* load_time_data) override; | 61 base::DictionaryValue* load_time_data) override; |
| 62 void AfterShow() override; |
| 57 | 63 |
| 58 private: | 64 private: |
| 59 void NotifyDenyCertificate(); | 65 void NotifyDenyCertificate(); |
| 60 | 66 |
| 61 base::Callback<void(bool)> callback_; | 67 base::Callback<void(bool)> callback_; |
| 62 const int cert_error_; | 68 const int cert_error_; |
| 63 const net::SSLInfo ssl_info_; | 69 const net::SSLInfo ssl_info_; |
| 70 const base::Time time_triggered_; |
| 71 scoped_ptr<ChromeControllerClient> controller_; |
| 64 | 72 |
| 65 // The time at which the interstitial was triggered. The interstitial | 73 scoped_ptr<security_interstitials::BadClockUI> bad_clock_ui_; |
| 66 // calculates all times relative to this. | |
| 67 const base::Time time_triggered_; | |
| 68 | |
| 69 scoped_ptr<CertReportHelper> cert_report_helper_; | 74 scoped_ptr<CertReportHelper> cert_report_helper_; |
| 70 | 75 |
| 71 DISALLOW_COPY_AND_ASSIGN(BadClockBlockingPage); | 76 DISALLOW_COPY_AND_ASSIGN(BadClockBlockingPage); |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 #endif // CHROME_BROWSER_SSL_BAD_CLOCK_BLOCKING_PAGE_H_ | 79 #endif // CHROME_BROWSER_SSL_BAD_CLOCK_BLOCKING_PAGE_H_ |
| OLD | NEW |