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 class SecurityInterstitialMetricsHelper
;
31 class SecurityInterstitialPage
: public content::InterstitialPageDelegate
{
33 // These represent the commands sent from the interstitial JavaScript.
34 // DO NOT reorder or change these without also changing the JavaScript!
35 // See chrome/browser/resources/security_warnings/interstitial_v2.js
36 enum SecurityInterstitialCommands
{
40 CMD_TEXT_NOT_FOUND
= -1,
44 // Ways for user to get more information
45 CMD_SHOW_MORE_SECTION
= 2,
46 CMD_OPEN_HELP_CENTER
= 3,
47 CMD_OPEN_DIAGNOSTIC
= 4,
48 // Primary button actions
50 CMD_OPEN_DATE_SETTINGS
= 6,
52 // Safe Browsing Extended Reporting
55 CMD_OPEN_REPORTING_PRIVACY
= 10,
58 SecurityInterstitialPage(content::WebContents
* web_contents
,
60 ~SecurityInterstitialPage() override
;
62 // Creates an interstitial and shows it.
65 // Prevents creating the actual interstitial view for testing.
66 void DontCreateViewForTesting();
69 // Returns true if the interstitial should create a new navigation entry.
70 virtual bool ShouldCreateNewNavigation() const = 0;
72 // Populates the strings used to generate the HTML from the template.
73 virtual void PopulateInterstitialStrings(
74 base::DictionaryValue
* load_time_data
) = 0;
76 // InterstitialPageDelegate method:
77 std::string
GetHTMLContents() override
;
79 // Returns the formatted host name for the request url.
80 base::string16
GetFormattedHostName() const;
82 content::InterstitialPage
* interstitial_page() const;
83 content::WebContents
* web_contents() const;
84 GURL
request_url() const;
86 // Record the user's preference for reporting information about
87 // malware and SSL errors.
88 void SetReportingPreference(bool report
);
90 // Returns the boolean value of the given |pref| from the PrefService of the
91 // Profile associated with |web_contents_|.
92 bool IsPrefEnabled(const char* pref
);
94 void OpenExtendedReportingPrivacyPolicy();
96 SecurityInterstitialMetricsHelper
* metrics_helper();
97 void set_metrics_helper(SecurityInterstitialMetricsHelper
* metrics_helper
);
100 scoped_ptr
<SecurityInterstitialMetricsHelper
> metrics_helper_
;
101 // The WebContents with which this interstitial page is
102 // associated. Not available in ~SecurityInterstitialPage, since it
103 // can be destroyed before this class is destroyed.
104 content::WebContents
* web_contents_
;
105 const GURL request_url_
;
106 // Once shown, |interstitial_page| takes ownership of this
107 // SecurityInterstitialPage instance.
108 content::InterstitialPage
* interstitial_page_
;
109 // Whether the interstitial should create a view.
112 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage
);
115 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_