Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / interstitials / security_interstitial_page.h
blob2f1520ed3a9e819e3dd630b71cece40a1fa5a5ca
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"
10 #include "url/gurl.h"
12 namespace base {
13 class DictionaryValue;
16 namespace content {
17 class InterstitialPage;
18 class WebContents;
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 {
32 public:
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 {
37 // Used by tests
38 CMD_TEXT_FOUND = -2,
39 CMD_TEXT_NOT_FOUND = -1,
40 // Decisions
41 CMD_DONT_PROCEED = 0,
42 CMD_PROCEED = 1,
43 // Ways for user to get more information
44 CMD_SHOW_MORE_SECTION = 2,
45 CMD_OPEN_HELP_CENTER = 3,
46 CMD_OPEN_DIAGNOSTIC = 4,
47 // Primary button actions
48 CMD_RELOAD = 5,
49 CMD_OPEN_DATE_SETTINGS = 6,
50 CMD_OPEN_LOGIN = 7,
51 // Safe Browsing Extended Reporting
52 CMD_DO_REPORT = 8,
53 CMD_DONT_REPORT = 9,
54 CMD_OPEN_REPORTING_PRIVACY = 10,
57 SecurityInterstitialPage(content::WebContents* web_contents,
58 const GURL& url);
59 ~SecurityInterstitialPage() override;
61 // Creates an interstitial and shows it.
62 virtual void Show();
64 // Prevents creating the actual interstitial view for testing.
65 void DontCreateViewForTesting();
67 protected:
68 // Returns true if the interstitial should create a new navigation entry.
69 virtual bool ShouldCreateNewNavigation() const = 0;
71 // Populates the strings used to generate the HTML from the template.
72 virtual void PopulateInterstitialStrings(
73 base::DictionaryValue* load_time_data) = 0;
75 // InterstitialPageDelegate method:
76 std::string GetHTMLContents() override;
78 // Returns the formatted host name for the request url.
79 base::string16 GetFormattedHostName() const;
81 content::InterstitialPage* interstitial_page() const;
82 content::WebContents* web_contents() const;
83 GURL request_url() const;
85 // Record the user's preference for reporting information about
86 // malware and SSL errors.
87 void SetReportingPreference(bool report);
89 // Returns the boolean value of the given |pref| from the PrefService of the
90 // Profile associated with |web_contents_|.
91 bool IsPrefEnabled(const char* pref);
93 void OpenExtendedReportingPrivacyPolicy();
95 SecurityInterstitialMetricsHelper* metrics_helper();
96 void set_metrics_helper(SecurityInterstitialMetricsHelper* metrics_helper);
98 private:
99 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_;
100 content::WebContents* web_contents_;
101 const GURL request_url_;
102 // Once shown, |interstitial_page| takes ownership of this
103 // SecurityInterstitialPage instance.
104 content::InterstitialPage* interstitial_page_;
105 // Whether the interstitial should create a view.
106 bool create_view_;
108 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage);
111 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_