| 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 26 matching lines...) Expand all Loading... |
| 37 #include "components/safe_browsing/base_blocking_page.h" | 37 #include "components/safe_browsing/base_blocking_page.h" |
| 38 #include "components/safe_browsing/base_ui_manager.h" | 38 #include "components/safe_browsing/base_ui_manager.h" |
| 39 | 39 |
| 40 namespace safe_browsing { | 40 namespace safe_browsing { |
| 41 | 41 |
| 42 class SafeBrowsingBlockingPageFactory; | 42 class SafeBrowsingBlockingPageFactory; |
| 43 class ThreatDetails; | 43 class ThreatDetails; |
| 44 | 44 |
| 45 class SafeBrowsingBlockingPage : public BaseBlockingPage { | 45 class SafeBrowsingBlockingPage : public BaseBlockingPage { |
| 46 public: | 46 public: |
| 47 typedef security_interstitials::BaseSafeBrowsingErrorUI |
| 48 BaseSafeBrowsingErrorUI; |
| 47 // Interstitial type, used in tests. | 49 // Interstitial type, used in tests. |
| 48 static content::InterstitialPageDelegate::TypeID kTypeForTesting; | 50 static content::InterstitialPageDelegate::TypeID kTypeForTesting; |
| 49 | 51 |
| 50 ~SafeBrowsingBlockingPage() override; | 52 ~SafeBrowsingBlockingPage() override; |
| 51 | 53 |
| 52 // Creates a blocking page. Use ShowBlockingPage if you don't need to access | 54 // Creates a blocking page. Use ShowBlockingPage if you don't need to access |
| 53 // the blocking page directly. | 55 // the blocking page directly. |
| 54 static SafeBrowsingBlockingPage* CreateBlockingPage( | 56 static SafeBrowsingBlockingPage* CreateBlockingPage( |
| 55 BaseUIManager* ui_manager, | 57 BaseUIManager* ui_manager, |
| 56 content::WebContents* web_contents, | 58 content::WebContents* web_contents, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 ExtendedReportingNotShownNotAllowExtendedReporting); | 99 ExtendedReportingNotShownNotAllowExtendedReporting); |
| 98 | 100 |
| 99 void UpdateReportingPref(); // Used for the transition from old to new pref. | 101 void UpdateReportingPref(); // Used for the transition from old to new pref. |
| 100 | 102 |
| 101 // Don't instantiate this class directly, use ShowBlockingPage instead. | 103 // Don't instantiate this class directly, use ShowBlockingPage instead. |
| 102 SafeBrowsingBlockingPage( | 104 SafeBrowsingBlockingPage( |
| 103 BaseUIManager* ui_manager, | 105 BaseUIManager* ui_manager, |
| 104 content::WebContents* web_contents, | 106 content::WebContents* web_contents, |
| 105 const GURL& main_frame_url, | 107 const GURL& main_frame_url, |
| 106 const UnsafeResourceList& unsafe_resources, | 108 const UnsafeResourceList& unsafe_resources, |
| 107 const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options); | 109 const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options); |
| 108 | 110 |
| 109 // Called after the user clicks OnProceed(). If the page has malicious | 111 // Called after the user clicks OnProceed(). If the page has malicious |
| 110 // subresources, then we show another interstitial. | 112 // subresources, then we show another interstitial. |
| 111 void HandleSubresourcesAfterProceed() override; | 113 void HandleSubresourcesAfterProceed() override; |
| 112 | 114 |
| 113 // Called when the interstitial is going away. If there is a | 115 // Called when the interstitial is going away. If there is a |
| 114 // pending threat details object, we look at the user's | 116 // pending threat details object, we look at the user's |
| 115 // preferences, and if the option to send threat details is | 117 // preferences, and if the option to send threat details is |
| 116 // enabled, the report is scheduled to be sent on the |ui_manager_|. | 118 // enabled, the report is scheduled to be sent on the |ui_manager_|. |
| 117 void FinishThreatDetails(const base::TimeDelta& delay, | 119 void FinishThreatDetails(const base::TimeDelta& delay, |
| 118 bool did_proceed, | 120 bool did_proceed, |
| 119 int num_visits) override; | 121 int num_visits) override; |
| 120 | 122 |
| 121 // A ThreatDetails object that we start generating when the | 123 // A ThreatDetails object that we start generating when the |
| 122 // blocking page is shown. The object will be sent when the warning | 124 // blocking page is shown. The object will be sent when the warning |
| 123 // is gone (if the user enables the feature). | 125 // is gone (if the user enables the feature). |
| 124 scoped_refptr<ThreatDetails> threat_details_; | 126 scoped_refptr<ThreatDetails> threat_details_; |
| 125 | 127 |
| 126 // The factory used to instantiate SafeBrowsingBlockingPage objects. | 128 // The factory used to instantiate SafeBrowsingBlockingPage objects. |
| 127 // Useful for tests, so they can provide their own implementation of | 129 // Useful for tests, so they can provide their own implementation of |
| 128 // SafeBrowsingBlockingPage. | 130 // SafeBrowsingBlockingPage. |
| 129 static SafeBrowsingBlockingPageFactory* factory_; | 131 static SafeBrowsingBlockingPageFactory* factory_; |
| 130 private: | 132 private: |
| 131 static std::string GetSamplingEventName( | 133 static std::string GetSamplingEventName( |
| 132 SafeBrowsingErrorUI::SBInterstitialReason interstitial_reason); | 134 BaseSafeBrowsingErrorUI::SBInterstitialReason interstitial_reason); |
| 133 | 135 |
| 134 static std::unique_ptr< | 136 static std::unique_ptr< |
| 135 security_interstitials::SecurityInterstitialControllerClient> | 137 security_interstitials::SecurityInterstitialControllerClient> |
| 136 CreateControllerClient(content::WebContents* web_contents, | 138 CreateControllerClient(content::WebContents* web_contents, |
| 137 const UnsafeResourceList& unsafe_resources, | 139 const UnsafeResourceList& unsafe_resources, |
| 138 const BaseUIManager* ui_manager); | 140 const BaseUIManager* ui_manager); |
| 139 | 141 |
| 140 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 142 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
| 141 }; | 143 }; |
| 142 | 144 |
| 143 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. | 145 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. |
| 144 class SafeBrowsingBlockingPageFactory { | 146 class SafeBrowsingBlockingPageFactory { |
| 145 public: | 147 public: |
| 146 virtual ~SafeBrowsingBlockingPageFactory() { } | 148 virtual ~SafeBrowsingBlockingPageFactory() { } |
| 147 | 149 |
| 148 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 150 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 149 BaseUIManager* ui_manager, | 151 BaseUIManager* ui_manager, |
| 150 content::WebContents* web_contents, | 152 content::WebContents* web_contents, |
| 151 const GURL& main_frame_url, | 153 const GURL& main_frame_url, |
| 152 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 154 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
| 153 }; | 155 }; |
| 154 | 156 |
| 155 } // namespace safe_browsing | 157 } // namespace safe_browsing |
| 156 | 158 |
| 157 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 159 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
| OLD | NEW |