ExtensionSyncService cleanup: process uninstalls in one step
[chromium-blink-merge.git] / chrome / browser / interstitials / security_interstitial_page.h
blob6a07dfacd3c6e70ed5f9e956cef8f394bc7d8c65
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_ERROR = -3,
39 CMD_TEXT_FOUND = -2,
40 CMD_TEXT_NOT_FOUND = -1,
41 // Decisions
42 CMD_DONT_PROCEED = 0,
43 CMD_PROCEED = 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
49 CMD_RELOAD = 5,
50 CMD_OPEN_DATE_SETTINGS = 6,
51 CMD_OPEN_LOGIN = 7,
52 // Safe Browsing Extended Reporting
53 CMD_DO_REPORT = 8,
54 CMD_DONT_REPORT = 9,
55 CMD_OPEN_REPORTING_PRIVACY = 10,
56 // Report a phishing error
57 CMD_REPORT_PHISHING_ERROR = 11,
60 SecurityInterstitialPage(content::WebContents* web_contents,
61 const GURL& url);
62 ~SecurityInterstitialPage() override;
64 // Creates an interstitial and shows it.
65 virtual void Show();
67 // Prevents creating the actual interstitial view for testing.
68 void DontCreateViewForTesting();
70 protected:
71 // Returns true if the interstitial should create a new navigation entry.
72 virtual bool ShouldCreateNewNavigation() const = 0;
74 // Populates the strings used to generate the HTML from the template.
75 virtual void PopulateInterstitialStrings(
76 base::DictionaryValue* load_time_data) = 0;
78 // InterstitialPageDelegate method:
79 std::string GetHTMLContents() override;
81 // Returns the formatted host name for the request url.
82 base::string16 GetFormattedHostName() const;
84 content::InterstitialPage* interstitial_page() const;
85 content::WebContents* web_contents() const;
86 GURL request_url() const;
88 // Record the user's preference for reporting information about
89 // malware and SSL errors.
90 void SetReportingPreference(bool report);
92 // Returns the boolean value of the given |pref| from the PrefService of the
93 // Profile associated with |web_contents_|.
94 bool IsPrefEnabled(const char* pref);
96 void OpenExtendedReportingPrivacyPolicy();
98 SecurityInterstitialMetricsHelper* metrics_helper();
99 void set_metrics_helper(SecurityInterstitialMetricsHelper* metrics_helper);
101 private:
102 scoped_ptr<SecurityInterstitialMetricsHelper> metrics_helper_;
103 // The WebContents with which this interstitial page is
104 // associated. Not available in ~SecurityInterstitialPage, since it
105 // can be destroyed before this class is destroyed.
106 content::WebContents* web_contents_;
107 const GURL request_url_;
108 // Once shown, |interstitial_page| takes ownership of this
109 // SecurityInterstitialPage instance.
110 content::InterstitialPage* interstitial_page_;
111 // Whether the interstitial should create a view.
112 bool create_view_;
114 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage);
117 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_