| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Classes for managing the SafeBrowsing interstitial pages. | 5 // Classes for managing the SafeBrowsing interstitial pages. |
| 6 // | 6 // |
| 7 // When a user is about to visit a page the SafeBrowsing system has deemed to | 7 // When a user is about to visit a page the SafeBrowsing system has deemed to |
| 8 // be malicious, either as malware or a phishing page, we show an interstitial | 8 // be malicious, either as malware or a phishing page, we show an interstitial |
| 9 // page with some options (go back, continue) to give the user a chance to avoid | 9 // page with some options (go back, continue) to give the user a chance to avoid |
| 10 // the harmful page. | 10 // the harmful page. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 class ExperienceSamplingEvent; | 58 class ExperienceSamplingEvent; |
| 59 } | 59 } |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 class SafeBrowsingBlockingPage : public content::InterstitialPageDelegate { | 62 class SafeBrowsingBlockingPage : public content::InterstitialPageDelegate { |
| 63 public: | 63 public: |
| 64 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; | 64 typedef SafeBrowsingUIManager::UnsafeResource UnsafeResource; |
| 65 typedef std::vector<UnsafeResource> UnsafeResourceList; | 65 typedef std::vector<UnsafeResource> UnsafeResourceList; |
| 66 typedef std::map<content::WebContents*, UnsafeResourceList> UnsafeResourceMap; | 66 typedef std::map<content::WebContents*, UnsafeResourceList> UnsafeResourceMap; |
| 67 | 67 |
| 68 virtual ~SafeBrowsingBlockingPage(); | 68 ~SafeBrowsingBlockingPage() override; |
| 69 | 69 |
| 70 // Creates a blocking page. Use ShowBlockingPage if you don't need to access | 70 // Creates a blocking page. Use ShowBlockingPage if you don't need to access |
| 71 // the blocking page directly. | 71 // the blocking page directly. |
| 72 static SafeBrowsingBlockingPage* CreateBlockingPage( | 72 static SafeBrowsingBlockingPage* CreateBlockingPage( |
| 73 SafeBrowsingUIManager* ui_manager, | 73 SafeBrowsingUIManager* ui_manager, |
| 74 content::WebContents* web_contents, | 74 content::WebContents* web_contents, |
| 75 const UnsafeResource& unsafe_resource); | 75 const UnsafeResource& unsafe_resource); |
| 76 | 76 |
| 77 // Shows a blocking page warning the user about phishing/malware for a | 77 // Shows a blocking page warning the user about phishing/malware for a |
| 78 // specific resource. | 78 // specific resource. |
| 79 // You can call this method several times, if an interstitial is already | 79 // You can call this method several times, if an interstitial is already |
| 80 // showing, the new one will be queued and displayed if the user decides | 80 // showing, the new one will be queued and displayed if the user decides |
| 81 // to proceed on the currently showing interstitial. | 81 // to proceed on the currently showing interstitial. |
| 82 static void ShowBlockingPage( | 82 static void ShowBlockingPage( |
| 83 SafeBrowsingUIManager* ui_manager, const UnsafeResource& resource); | 83 SafeBrowsingUIManager* ui_manager, const UnsafeResource& resource); |
| 84 | 84 |
| 85 // Makes the passed |factory| the factory used to instantiate | 85 // Makes the passed |factory| the factory used to instantiate |
| 86 // SafeBrowsingBlockingPage objects. Useful for tests. | 86 // SafeBrowsingBlockingPage objects. Useful for tests. |
| 87 static void RegisterFactory(SafeBrowsingBlockingPageFactory* factory) { | 87 static void RegisterFactory(SafeBrowsingBlockingPageFactory* factory) { |
| 88 factory_ = factory; | 88 factory_ = factory; |
| 89 } | 89 } |
| 90 | 90 |
| 91 // InterstitialPageDelegate method: | 91 // InterstitialPageDelegate method: |
| 92 virtual std::string GetHTMLContents() override; | 92 std::string GetHTMLContents() override; |
| 93 virtual void OnProceed() override; | 93 void OnProceed() override; |
| 94 virtual void OnDontProceed() override; | 94 void OnDontProceed() override; |
| 95 virtual void CommandReceived(const std::string& command) override; | 95 void CommandReceived(const std::string& command) override; |
| 96 virtual void OverrideRendererPrefs( | 96 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; |
| 97 content::RendererPreferences* prefs) override; | |
| 98 | 97 |
| 99 protected: | 98 protected: |
| 100 friend class SafeBrowsingBlockingPageTest; | 99 friend class SafeBrowsingBlockingPageTest; |
| 101 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, | 100 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, |
| 102 ProceedThenDontProceed); | 101 ProceedThenDontProceed); |
| 103 | 102 |
| 104 void DontCreateViewForTesting(); | 103 void DontCreateViewForTesting(); |
| 105 void Show(); | 104 void Show(); |
| 106 void SetReportingPreference(bool report); | 105 void SetReportingPreference(bool report); |
| 107 void UpdateReportingPref(); // Used for the transition from old to new pref. | 106 void UpdateReportingPref(); // Used for the transition from old to new pref. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 public: | 247 public: |
| 249 virtual ~SafeBrowsingBlockingPageFactory() { } | 248 virtual ~SafeBrowsingBlockingPageFactory() { } |
| 250 | 249 |
| 251 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 250 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 252 SafeBrowsingUIManager* ui_manager, | 251 SafeBrowsingUIManager* ui_manager, |
| 253 content::WebContents* web_contents, | 252 content::WebContents* web_contents, |
| 254 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 253 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
| 255 }; | 254 }; |
| 256 | 255 |
| 257 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 256 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
| OLD | NEW |