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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_
6 #define CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_
8 #include "base/strings/string16.h"
9 #include "content/public/browser/interstitial_page_delegate.h"
13 class DictionaryValue
;
17 class InterstitialPage
;
21 namespace interstitials
{
22 // Constants used to communicate with the JavaScript.
23 extern const char kBoxChecked
[];
24 extern const char kDisplayCheckBox
[];
25 extern const char kOptInLink
[];
26 extern const char kPrivacyLinkHtml
[];
29 namespace security_interstitials
{
33 class SecurityInterstitialPage
: public content::InterstitialPageDelegate
{
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
{
42 CMD_TEXT_NOT_FOUND
= -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
52 CMD_OPEN_DATE_SETTINGS
= 6,
54 // Safe Browsing Extended Reporting
57 CMD_OPEN_REPORTING_PRIVACY
= 10,
58 // Report a phishing error
59 CMD_REPORT_PHISHING_ERROR
= 11,
62 SecurityInterstitialPage(content::WebContents
* web_contents
,
64 ~SecurityInterstitialPage() override
;
66 // Creates an interstitial and shows it.
69 // Prevents creating the actual interstitial view for testing.
70 void DontCreateViewForTesting();
73 // Returns true if the interstitial should create a new navigation entry.
74 virtual bool ShouldCreateNewNavigation() const = 0;
76 // Populates the strings used to generate the HTML from the template.
77 virtual void PopulateInterstitialStrings(
78 base::DictionaryValue
* load_time_data
) = 0;
80 // InterstitialPageDelegate method:
81 std::string
GetHTMLContents() override
;
83 // Returns the formatted host name for the request url.
84 base::string16
GetFormattedHostName() const;
86 content::InterstitialPage
* interstitial_page() const;
87 content::WebContents
* web_contents() const;
88 GURL
request_url() const;
90 // Record the user's preference for reporting information about
91 // malware and SSL errors.
92 void SetReportingPreference(bool report
);
94 // Returns the boolean value of the given |pref| from the PrefService of the
95 // Profile associated with |web_contents_|.
96 bool IsPrefEnabled(const char* pref
);
98 void OpenExtendedReportingPrivacyPolicy();
100 security_interstitials::MetricsHelper
* metrics_helper() const;
101 void set_metrics_helper(
102 security_interstitials::MetricsHelper
* metrics_helper
);
105 scoped_ptr
<security_interstitials::MetricsHelper
> metrics_helper_
;
106 // The WebContents with which this interstitial page is
107 // associated. Not available in ~SecurityInterstitialPage, since it
108 // can be destroyed before this class is destroyed.
109 content::WebContents
* web_contents_
;
110 const GURL request_url_
;
111 // Once shown, |interstitial_page| takes ownership of this
112 // SecurityInterstitialPage instance.
113 content::InterstitialPage
* interstitial_page_
;
114 // Whether the interstitial should create a view.
117 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage
);
120 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_