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" | |
10 #include "content/public/browser/interstitial_page_delegate.h" | 9 #include "content/public/browser/interstitial_page_delegate.h" |
11 #include "url/gurl.h" | 10 #include "url/gurl.h" |
12 | 11 |
13 namespace base { | 12 namespace base { |
14 class DictionaryValue; | 13 class DictionaryValue; |
15 } | 14 } |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 class InterstitialPage; | 17 class InterstitialPage; |
19 class WebContents; | 18 class WebContents; |
20 } | 19 } |
21 | 20 |
22 namespace interstitials { | 21 namespace security_interstitials { |
23 // Constants used to communicate with the JavaScript. | 22 class MetricsHelper; |
24 extern const char kBoxChecked[]; | |
25 extern const char kDisplayCheckBox[]; | |
26 extern const char kOptInLink[]; | |
27 extern const char kPrivacyLinkHtml[]; | |
28 } | 23 } |
29 | 24 |
30 class SecurityInterstitialPage | 25 class ChromeControllerClient; |
31 : public content::InterstitialPageDelegate, | 26 |
32 public security_interstitials::ControllerClient { | 27 class SecurityInterstitialPage : public content::InterstitialPageDelegate { |
33 public: | 28 public: |
34 SecurityInterstitialPage(content::WebContents* web_contents, | 29 SecurityInterstitialPage(content::WebContents* web_contents, |
35 const GURL& url); | 30 const GURL& url); |
36 ~SecurityInterstitialPage() override; | 31 ~SecurityInterstitialPage() override; |
37 | 32 |
38 // Creates an interstitial and shows it. | 33 // Creates an interstitial and shows it. |
39 virtual void Show(); | 34 virtual void Show(); |
40 | 35 |
41 // Prevents creating the actual interstitial view for testing. | 36 // Prevents creating the actual interstitial view for testing. |
42 void DontCreateViewForTesting(); | 37 void DontCreateViewForTesting(); |
(...skipping 13 matching lines...) Expand all Loading... |
56 base::string16 GetFormattedHostName() const; | 51 base::string16 GetFormattedHostName() const; |
57 | 52 |
58 content::InterstitialPage* interstitial_page() const; | 53 content::InterstitialPage* interstitial_page() const; |
59 content::WebContents* web_contents() const; | 54 content::WebContents* web_contents() const; |
60 GURL request_url() const; | 55 GURL request_url() const; |
61 | 56 |
62 // Returns the boolean value of the given |pref| from the PrefService of the | 57 // Returns the boolean value of the given |pref| from the PrefService of the |
63 // Profile associated with |web_contents_|. | 58 // Profile associated with |web_contents_|. |
64 bool IsPrefEnabled(const char* pref); | 59 bool IsPrefEnabled(const char* pref); |
65 | 60 |
66 protected: | 61 // TODO(felt): Remove these. They are temporary methods, used to pass along |
67 // security_interstitials::ControllerClient overrides | 62 // calls to the |controller_| for subclasses that don't yet have their own |
68 void OpenUrlInCurrentTab(const GURL& url) override; | 63 // ChromeControllerClients. crbug.com/488673 |
69 const std::string& GetApplicationLocale() override; | 64 void SetReportingPreference(bool report); |
70 PrefService* GetPrefService() override; | 65 void OpenExtendedReportingPrivacyPolicy(); |
71 const std::string GetExtendedReportingPrefName() override; | 66 security_interstitials::MetricsHelper* metrics_helper(); |
| 67 void set_metrics_helper( |
| 68 scoped_ptr<security_interstitials::MetricsHelper> metrics_helper); |
72 | 69 |
73 private: | 70 private: |
74 // The WebContents with which this interstitial page is | 71 // The WebContents with which this interstitial page is |
75 // associated. Not available in ~SecurityInterstitialPage, since it | 72 // associated. Not available in ~SecurityInterstitialPage, since it |
76 // can be destroyed before this class is destroyed. | 73 // can be destroyed before this class is destroyed. |
77 content::WebContents* web_contents_; | 74 content::WebContents* web_contents_; |
78 const GURL request_url_; | 75 const GURL request_url_; |
79 // Once shown, |interstitial_page| takes ownership of this | 76 // Once shown, |interstitial_page| takes ownership of this |
80 // SecurityInterstitialPage instance. | 77 // SecurityInterstitialPage instance. |
81 content::InterstitialPage* interstitial_page_; | 78 content::InterstitialPage* interstitial_page_; |
82 // Whether the interstitial should create a view. | 79 // Whether the interstitial should create a view. |
83 bool create_view_; | 80 bool create_view_; |
| 81 // For subclasses that don't have their own ChromeControllerClients yet. |
| 82 scoped_ptr<ChromeControllerClient> controller_; |
84 | 83 |
85 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); | 84 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); |
86 }; | 85 }; |
87 | 86 |
88 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | 87 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ |
OLD | NEW |