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/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "components/security_interstitials/core/controller_client.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 |
| 21 namespace interstitials { | 22 namespace interstitials { |
| 22 // Constants used to communicate with the JavaScript. | 23 // Constants used to communicate with the JavaScript. |
| 23 extern const char kBoxChecked[]; | 24 extern const char kBoxChecked[]; |
| 24 extern const char kDisplayCheckBox[]; | 25 extern const char kDisplayCheckBox[]; |
| 25 extern const char kOptInLink[]; | 26 extern const char kOptInLink[]; |
| 26 extern const char kPrivacyLinkHtml[]; | 27 extern const char kPrivacyLinkHtml[]; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace security_interstitials { | 30 class SecurityInterstitialPage |
| 30 class MetricsHelper; | 31 : public content::InterstitialPageDelegate, |
| 31 } | 32 public security_interstitials::ControllerClient { |
| 32 | |
| 33 class SecurityInterstitialPage : public content::InterstitialPageDelegate { | |
| 34 public: | 33 public: |
| 35 // These represent the commands sent from the interstitial JavaScript. | |
| 36 // DO NOT reorder or change these without also changing the JavaScript! | |
| 37 // See chrome/browser/resources/security_warnings/interstitial_v2.js | |
| 38 enum SecurityInterstitialCommands { | |
| 39 // Used by tests | |
| 40 CMD_ERROR = -3, | |
| 41 CMD_TEXT_FOUND = -2, | |
| 42 CMD_TEXT_NOT_FOUND = -1, | |
| 43 // Decisions | |
| 44 CMD_DONT_PROCEED = 0, | |
| 45 CMD_PROCEED = 1, | |
| 46 // Ways for user to get more information | |
| 47 CMD_SHOW_MORE_SECTION = 2, | |
| 48 CMD_OPEN_HELP_CENTER = 3, | |
| 49 CMD_OPEN_DIAGNOSTIC = 4, | |
| 50 // Primary button actions | |
| 51 CMD_RELOAD = 5, | |
| 52 CMD_OPEN_DATE_SETTINGS = 6, | |
| 53 CMD_OPEN_LOGIN = 7, | |
| 54 // Safe Browsing Extended Reporting | |
| 55 CMD_DO_REPORT = 8, | |
| 56 CMD_DONT_REPORT = 9, | |
| 57 CMD_OPEN_REPORTING_PRIVACY = 10, | |
| 58 // Report a phishing error | |
| 59 CMD_REPORT_PHISHING_ERROR = 11, | |
| 60 }; | |
| 61 | |
| 62 SecurityInterstitialPage(content::WebContents* web_contents, | 34 SecurityInterstitialPage(content::WebContents* web_contents, |
| 63 const GURL& url); | 35 const GURL& url); |
| 64 ~SecurityInterstitialPage() override; | 36 ~SecurityInterstitialPage() override; |
| 65 | 37 |
| 66 // Creates an interstitial and shows it. | 38 // Creates an interstitial and shows it. |
| 67 virtual void Show(); | 39 virtual void Show(); |
| 68 | 40 |
| 69 // Prevents creating the actual interstitial view for testing. | 41 // Prevents creating the actual interstitial view for testing. |
| 70 void DontCreateViewForTesting(); | 42 void DontCreateViewForTesting(); |
| 71 | 43 |
| 72 protected: | 44 protected: |
| 73 // Returns true if the interstitial should create a new navigation entry. | 45 // Returns true if the interstitial should create a new navigation entry. |
| 74 virtual bool ShouldCreateNewNavigation() const = 0; | 46 virtual bool ShouldCreateNewNavigation() const = 0; |
| 75 | 47 |
| 76 // Populates the strings used to generate the HTML from the template. | 48 // Populates the strings used to generate the HTML from the template. |
| 77 virtual void PopulateInterstitialStrings( | 49 virtual void PopulateInterstitialStrings( |
| 78 base::DictionaryValue* load_time_data) = 0; | 50 base::DictionaryValue* load_time_data) = 0; |
| 79 | 51 |
| 80 // InterstitialPageDelegate method: | 52 // InterstitialPageDelegate method: |
| 81 std::string GetHTMLContents() override; | 53 std::string GetHTMLContents() override; |
| 82 | 54 |
| 83 // Returns the formatted host name for the request url. | 55 // Returns the formatted host name for the request url. |
| 84 base::string16 GetFormattedHostName() const; | 56 base::string16 GetFormattedHostName() const; |
| 85 | 57 |
| 86 content::InterstitialPage* interstitial_page() const; | 58 content::InterstitialPage* interstitial_page() const; |
| 87 content::WebContents* web_contents() const; | 59 content::WebContents* web_contents() const; |
| 88 GURL request_url() const; | 60 GURL request_url() const; |
| 89 | 61 |
| 90 // Record the user's preference for reporting information about | |
| 91 // malware and SSL errors. | |
| 92 void SetReportingPreference(bool report); | |
| 93 | |
| 94 // Returns the boolean value of the given |pref| from the PrefService of the | 62 // Returns the boolean value of the given |pref| from the PrefService of the |
| 95 // Profile associated with |web_contents_|. | 63 // Profile associated with |web_contents_|. |
| 96 bool IsPrefEnabled(const char* pref); | 64 bool IsPrefEnabled(const char* pref); |
| 97 | 65 |
| 98 void OpenExtendedReportingPrivacyPolicy(); | 66 protected: |
| 67 void OpenUrlInCurrentTab(const GURL& url) override; | |
|
estark
2015/11/21 00:46:59
add:
// security_interstitials::ControllerClient
felt
2015/11/21 01:06:48
Done.
| |
| 99 | 68 |
| 100 security_interstitials::MetricsHelper* metrics_helper() const; | 69 const std::string& GetApplicationLocale() override; |
| 101 void set_metrics_helper( | 70 PrefService* GetPrefService() override; |
| 102 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper); | 71 const std::string GetExtendedReportingPrefName() override; |
| 103 | 72 |
| 104 private: | 73 private: |
| 105 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper_; | |
| 106 // The WebContents with which this interstitial page is | 74 // The WebContents with which this interstitial page is |
| 107 // associated. Not available in ~SecurityInterstitialPage, since it | 75 // associated. Not available in ~SecurityInterstitialPage, since it |
| 108 // can be destroyed before this class is destroyed. | 76 // can be destroyed before this class is destroyed. |
| 109 content::WebContents* web_contents_; | 77 content::WebContents* web_contents_; |
| 110 const GURL request_url_; | 78 const GURL request_url_; |
| 111 // Once shown, |interstitial_page| takes ownership of this | 79 // Once shown, |interstitial_page| takes ownership of this |
| 112 // SecurityInterstitialPage instance. | 80 // SecurityInterstitialPage instance. |
| 113 content::InterstitialPage* interstitial_page_; | 81 content::InterstitialPage* interstitial_page_; |
| 114 // Whether the interstitial should create a view. | 82 // Whether the interstitial should create a view. |
| 115 bool create_view_; | 83 bool create_view_; |
| 116 | 84 |
| 117 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); | 85 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); |
| 118 }; | 86 }; |
| 119 | 87 |
| 120 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | 88 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ |
| OLD | NEW |