Chromium Code Reviews| 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 #ifndef CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | 5 #ifndef CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ |
| 6 #define CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | 6 #define CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | |
| 8 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 9 #include "content/public/browser/interstitial_page_delegate.h" | 10 #include "content/public/browser/interstitial_page_delegate.h" |
| 10 #include "url/gurl.h" | 11 #include "url/gurl.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 class DictionaryValue; | 14 class DictionaryValue; |
| 14 } | 15 } |
| 15 | 16 |
| 17 namespace chrome_browser_net { | |
| 18 class CertificateErrorReporter; | |
| 19 } | |
| 20 | |
| 16 namespace content { | 21 namespace content { |
| 17 class InterstitialPage; | 22 class InterstitialPage; |
| 18 class WebContents; | 23 class WebContents; |
| 19 } | 24 } |
| 20 | 25 |
| 26 namespace interstitials { | |
| 27 // Constants used to communicate with the JavaScript. | |
| 28 extern const char kBoxChecked[]; | |
| 29 extern const char kDisplayCheckBox[]; | |
| 30 extern const char kOptInLink[]; | |
| 31 extern const char kPrivacyLinkHtml[]; | |
| 32 } | |
| 33 | |
| 21 class SecurityInterstitialPage : public content::InterstitialPageDelegate { | 34 class SecurityInterstitialPage : public content::InterstitialPageDelegate { |
| 22 public: | 35 public: |
| 23 SecurityInterstitialPage(content::WebContents* web_contents, | 36 SecurityInterstitialPage(content::WebContents* web_contents, |
| 24 const GURL& url); | 37 const GURL& url); |
| 25 ~SecurityInterstitialPage() override; | 38 ~SecurityInterstitialPage() override; |
| 26 | 39 |
| 27 // Creates an interstitial and shows it. | 40 // Creates an interstitial and shows it. |
| 28 virtual void Show(); | 41 virtual void Show(); |
| 29 | 42 |
| 30 // Prevents creating the actual interstitial view for testing. | 43 // Prevents creating the actual interstitial view for testing. |
| 31 void DontCreateViewForTesting(); | 44 void DontCreateViewForTesting(); |
| 32 | 45 |
| 46 // Allows tests to be notified when an invalid cert chain report has | |
| 47 // been sent (or not sent). | |
| 48 void SetCertificateReportCallbackForTesting(const base::Closure& callback); | |
| 49 // Useful for tests to inject a mock reporter. | |
|
Ryan Sleevi
2015/03/14 03:09:42
add newline between 48/49
The comment style betwe
estark
2015/03/16 23:40:52
No longer applicable since the reporter now lives
| |
| 50 void SetCertificateReporterForTesting( | |
| 51 scoped_refptr<chrome_browser_net::CertificateErrorReporter> | |
|
Ryan Sleevi
2015/03/14 03:09:42
always pass scoped_refptr's const and by-ref.
Put
estark
2015/03/16 23:40:52
no longer applicable but noted for future
| |
| 52 certificate_reporter_for_testing); | |
|
Ryan Sleevi
2015/03/14 03:09:42
Is this method vestigal? Didn't see it in the .cc
estark
2015/03/16 23:40:52
Done.
| |
| 53 | |
| 33 protected: | 54 protected: |
| 34 // Returns true if the interstitial should create a new navigation entry. | 55 // Returns true if the interstitial should create a new navigation entry. |
| 35 virtual bool ShouldCreateNewNavigation() const = 0; | 56 virtual bool ShouldCreateNewNavigation() const = 0; |
| 36 | 57 |
| 37 // Populates the strings used to generate the HTML from the template. | 58 // Populates the strings used to generate the HTML from the template. |
| 38 virtual void PopulateInterstitialStrings( | 59 virtual void PopulateInterstitialStrings( |
| 39 base::DictionaryValue* load_time_data) = 0; | 60 base::DictionaryValue* load_time_data) = 0; |
| 40 | 61 |
| 41 // InterstitialPageDelegate method: | 62 // InterstitialPageDelegate method: |
| 42 std::string GetHTMLContents() override; | 63 std::string GetHTMLContents() override; |
| 43 | 64 |
| 44 // Returns the formatted host name for the request url. | 65 // Returns the formatted host name for the request url. |
| 45 base::string16 GetFormattedHostName() const; | 66 base::string16 GetFormattedHostName() const; |
| 46 | 67 |
| 47 content::InterstitialPage* interstitial_page() const; | 68 content::InterstitialPage* interstitial_page() const; |
| 48 content::WebContents* web_contents() const; | 69 content::WebContents* web_contents() const; |
| 49 GURL request_url() const; | 70 GURL request_url() const; |
| 50 | 71 |
| 72 // Record the user's preference for reporting information about | |
| 73 // malware and SSL errors. | |
| 74 void SetReportingPreference(bool report); | |
| 75 | |
| 76 // Fills the passed dictionary with the values to be passed to the template | |
| 77 // when creating the HTML. | |
| 78 virtual void PopulateExtendedReportingOption( | |
| 79 base::DictionaryValue* load_time_data) = 0; | |
| 80 | |
| 81 // Returns the boolean value of the given |pref| from the PrefService of the | |
| 82 // Profile associated with |web_contents_|. | |
| 83 bool IsPrefEnabled(const char* pref); | |
| 84 | |
| 85 // This callback is run when an extended reporting certificate chain | |
| 86 // report has been sent, or when it is decided that it should not be | |
| 87 // sent (for example, when in incognito mode). | |
| 88 base::Closure certificate_report_callback_for_testing_; | |
| 89 | |
| 51 private: | 90 private: |
| 52 content::WebContents* web_contents_; | 91 content::WebContents* web_contents_; |
| 53 const GURL request_url_; | 92 const GURL request_url_; |
| 54 // Once shown, |interstitial_page| takes ownership of this | 93 // Once shown, |interstitial_page| takes ownership of this |
| 55 // SecurityInterstitialPage instance. | 94 // SecurityInterstitialPage instance. |
| 56 content::InterstitialPage* interstitial_page_; | 95 content::InterstitialPage* interstitial_page_; |
| 57 // Whether the interstitial should create a view. | 96 // Whether the interstitial should create a view. |
| 58 bool create_view_; | 97 bool create_view_; |
| 59 | 98 |
| 60 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); | 99 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); |
| 61 }; | 100 }; |
| 62 | 101 |
| 63 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | 102 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ |
| OLD | NEW |