| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | |
| 6 #define CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/strings/string16.h" | |
| 12 #include "content/public/browser/interstitial_page_delegate.h" | |
| 13 #include "url/gurl.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class DictionaryValue; | |
| 17 } | |
| 18 | |
| 19 namespace content { | |
| 20 class InterstitialPage; | |
| 21 class WebContents; | |
| 22 } | |
| 23 | |
| 24 namespace security_interstitials { | |
| 25 class MetricsHelper; | |
| 26 } | |
| 27 | |
| 28 class ChromeControllerClient; | |
| 29 class Profile; | |
| 30 | |
| 31 class SecurityInterstitialPage : public content::InterstitialPageDelegate { | |
| 32 public: | |
| 33 SecurityInterstitialPage( | |
| 34 content::WebContents* web_contents, | |
| 35 const GURL& url, | |
| 36 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper); | |
| 37 ~SecurityInterstitialPage() override; | |
| 38 | |
| 39 // Creates an interstitial and shows it. | |
| 40 virtual void Show(); | |
| 41 | |
| 42 // Prevents creating the actual interstitial view for testing. | |
| 43 void DontCreateViewForTesting(); | |
| 44 | |
| 45 protected: | |
| 46 // Returns true if the interstitial should create a new navigation entry. | |
| 47 virtual bool ShouldCreateNewNavigation() const = 0; | |
| 48 | |
| 49 // Populates the strings used to generate the HTML from the template. | |
| 50 virtual void PopulateInterstitialStrings( | |
| 51 base::DictionaryValue* load_time_data) = 0; | |
| 52 | |
| 53 // Gives an opportunity for child classes to react to Show() having run. The | |
| 54 // interstitial_page_ will now have a value. | |
| 55 virtual void AfterShow() {} | |
| 56 | |
| 57 // InterstitialPageDelegate method: | |
| 58 std::string GetHTMLContents() override; | |
| 59 | |
| 60 // Returns the formatted host name for the request url. | |
| 61 base::string16 GetFormattedHostName() const; | |
| 62 | |
| 63 content::InterstitialPage* interstitial_page() const; | |
| 64 content::WebContents* web_contents() const; | |
| 65 GURL request_url() const; | |
| 66 | |
| 67 // Returns a pointer to the Profile associated with |web_contents_|. | |
| 68 Profile* profile(); | |
| 69 | |
| 70 // Returns the boolean value of the given |pref| from the PrefService of the | |
| 71 // Profile associated with |web_contents_|. | |
| 72 bool IsPrefEnabled(const char* pref); | |
| 73 | |
| 74 ChromeControllerClient* controller(); | |
| 75 | |
| 76 security_interstitials::MetricsHelper* metrics_helper(); | |
| 77 | |
| 78 private: | |
| 79 // The WebContents with which this interstitial page is | |
| 80 // associated. Not available in ~SecurityInterstitialPage, since it | |
| 81 // can be destroyed before this class is destroyed. | |
| 82 content::WebContents* web_contents_; | |
| 83 const GURL request_url_; | |
| 84 // Once shown, |interstitial_page| takes ownership of this | |
| 85 // SecurityInterstitialPage instance. | |
| 86 content::InterstitialPage* interstitial_page_; | |
| 87 // Whether the interstitial should create a view. | |
| 88 bool create_view_; | |
| 89 // For subclasses that don't have their own ChromeControllerClients yet. | |
| 90 std::unique_ptr<ChromeControllerClient> controller_; | |
| 91 | |
| 92 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(SecurityInterstitialPage); | |
| 95 }; | |
| 96 | |
| 97 #endif // CHROME_BROWSER_INTERSTITIALS_SECURITY_INTERSTITIAL_PAGE_H_ | |
| OLD | NEW |