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 |
16 namespace content { | 17 namespace content { |
17 class InterstitialPage; | 18 class InterstitialPage; |
18 class WebContents; | 19 class WebContents; |
19 } | 20 } |
20 | 21 |
22 namespace interstitials { | |
23 // Constants used to communicate with the JavaScript. | |
24 extern const char kBoxChecked[]; | |
25 extern const char kDisplayCheckBox[]; | |
26 extern const char kOptInLink[]; | |
27 extern const char kPrivacyLinkHtml[]; | |
28 } | |
29 | |
30 class SecurityInterstitialMetricsHelper; | |
31 | |
21 class SecurityInterstitialPage : public content::InterstitialPageDelegate { | 32 class SecurityInterstitialPage : public content::InterstitialPageDelegate { |
22 public: | 33 public: |
23 // These represent the commands sent from the interstitial JavaScript. | 34 // These represent the commands sent from the interstitial JavaScript. |
24 // DO NOT reorder or change these without also changing the JavaScript! | 35 // DO NOT reorder or change these without also changing the JavaScript! |
25 // See chrome/browser/resources/security_warnings/interstitial_v2.js | 36 // See chrome/browser/resources/security_warnings/interstitial_v2.js |
26 enum SecurityInterstitialCommands { | 37 enum SecurityInterstitialCommands { |
27 // Decisions | 38 // Decisions |
28 CMD_DONT_PROCEED = 0, | 39 CMD_DONT_PROCEED = 0, |
29 CMD_PROCEED = 1, | 40 CMD_PROCEED = 1, |
30 // Ways for user to get more information | 41 // Ways for user to get more information |
(...skipping 13 matching lines...) Expand all Loading... | |
44 SecurityInterstitialPage(content::WebContents* web_contents, | 55 SecurityInterstitialPage(content::WebContents* web_contents, |
45 const GURL& url); | 56 const GURL& url); |
46 ~SecurityInterstitialPage() override; | 57 ~SecurityInterstitialPage() override; |
47 | 58 |
48 // Creates an interstitial and shows it. | 59 // Creates an interstitial and shows it. |
49 virtual void Show(); | 60 virtual void Show(); |
50 | 61 |
51 // Prevents creating the actual interstitial view for testing. | 62 // Prevents creating the actual interstitial view for testing. |
52 void DontCreateViewForTesting(); | 63 void DontCreateViewForTesting(); |
53 | 64 |
65 // Allows tests to be notified when an invalid cert chain report has | |
66 // been sent (or not sent). | |
67 void SetCertificateReportCallbackForTesting(const base::Closure& callback); | |
mattm
2015/03/23 05:31:17
Should be on SSLBlockingPage instead of SecurityIn
estark
2015/03/23 16:42:13
Done.
| |
68 | |
54 protected: | 69 protected: |
55 // Returns true if the interstitial should create a new navigation entry. | 70 // Returns true if the interstitial should create a new navigation entry. |
56 virtual bool ShouldCreateNewNavigation() const = 0; | 71 virtual bool ShouldCreateNewNavigation() const = 0; |
57 | 72 |
58 // Populates the strings used to generate the HTML from the template. | 73 // Populates the strings used to generate the HTML from the template. |
59 virtual void PopulateInterstitialStrings( | 74 virtual void PopulateInterstitialStrings( |
60 base::DictionaryValue* load_time_data) = 0; | 75 base::DictionaryValue* load_time_data) = 0; |
61 | 76 |
62 // InterstitialPageDelegate method: | 77 // InterstitialPageDelegate method: |
63 std::string GetHTMLContents() override; | 78 std::string GetHTMLContents() override; |
64 | 79 |
65 // Returns the formatted host name for the request url. | 80 // Returns the formatted host name for the request url. |
66 base::string16 GetFormattedHostName() const; | 81 base::string16 GetFormattedHostName() const; |
67 | 82 |
68 content::InterstitialPage* interstitial_page() const; | 83 content::InterstitialPage* interstitial_page() const; |
69 content::WebContents* web_contents() const; | 84 content::WebContents* web_contents() const; |
70 GURL request_url() const; | 85 GURL request_url() const; |
71 | 86 |
87 // Record the user's preference for reporting information about | |
88 // malware and SSL errors. | |
89 void SetReportingPreference(bool report); | |
90 | |
91 // Returns the boolean value of the given |pref| from the PrefService of the | |
92 // Profile associated with |web_contents_|. | |
93 bool IsPrefEnabled(const char* pref); | |
94 | |
95 // This callback is run when an extended reporting certificate chain | |
96 // report has been sent, or when it is decided that it should not be | |
97 // sent (for example, when in incognito mode). | |
98 base::Closure certificate_report_callback_for_testing_; | |
99 | |
100 protected: | |
101 void OpenExtendedReportingPrivacyPolicy(); | |
102 | |
103 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_; | |
104 | |
72 private: | 105 private: |
73 content::WebContents* web_contents_; | 106 content::WebContents* web_contents_; |
74 const GURL request_url_; | 107 const GURL request_url_; |
75 // Once shown, |interstitial_page| takes ownership of this | 108 // Once shown, |interstitial_page| takes ownership of this |
76 // SecurityInterstitialPage instance. | 109 // SecurityInterstitialPage instance. |
77 content::InterstitialPage* interstitial_page_; | 110 content::InterstitialPage* interstitial_page_; |
78 // Whether the interstitial should create a view. | 111 // Whether the interstitial should create a view. |
79 bool create_view_; | 112 bool create_view_; |
80 | 113 |
81 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); | 114 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); |
82 }; | 115 }; |
83 | 116 |
84 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | 117 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ |
OLD | NEW |