| 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 15 matching lines...) Expand all Loading... |
| 26 // resources in a new interstitial. | 26 // resources in a new interstitial. |
| 27 | 27 |
| 28 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 28 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
| 29 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 29 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
| 30 | 30 |
| 31 #include <map> | 31 #include <map> |
| 32 #include <string> | 32 #include <string> |
| 33 #include <vector> | 33 #include <vector> |
| 34 | 34 |
| 35 #include "base/gtest_prod_util.h" | 35 #include "base/gtest_prod_util.h" |
| 36 #include "base/task/cancelable_task_tracker.h" |
| 36 #include "base/time/time.h" | 37 #include "base/time/time.h" |
| 37 #include "chrome/browser/history/history_service.h" | 38 #include "chrome/browser/history/history_service.h" |
| 38 #include "chrome/browser/safe_browsing/ui_manager.h" | 39 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 39 #include "content/public/browser/interstitial_page_delegate.h" | 40 #include "content/public/browser/interstitial_page_delegate.h" |
| 40 #include "url/gurl.h" | 41 #include "url/gurl.h" |
| 41 | 42 |
| 42 class MalwareDetails; | 43 class MalwareDetails; |
| 43 class SafeBrowsingBlockingPageFactory; | 44 class SafeBrowsingBlockingPageFactory; |
| 44 | 45 |
| 45 namespace base { | 46 namespace base { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 PROCEED, | 118 PROCEED, |
| 118 DONT_PROCEED, | 119 DONT_PROCEED, |
| 119 SHOW_ADVANCED, | 120 SHOW_ADVANCED, |
| 120 }; | 121 }; |
| 121 | 122 |
| 122 // Records a user action for this interstitial, using the form | 123 // Records a user action for this interstitial, using the form |
| 123 // SBInterstitial[Phishing|Malware|Multiple][Show|Proceed|DontProceed]. | 124 // SBInterstitial[Phishing|Malware|Multiple][Show|Proceed|DontProceed]. |
| 124 void RecordUserAction(BlockingPageEvent event); | 125 void RecordUserAction(BlockingPageEvent event); |
| 125 | 126 |
| 126 // Used to query the HistoryService to see if the URL is in history. For UMA. | 127 // Used to query the HistoryService to see if the URL is in history. For UMA. |
| 127 void OnGotHistoryCount(HistoryService::Handle handle, | 128 void OnGotHistoryCount(bool success, int num_visits, base::Time first_visit); |
| 128 bool success, | |
| 129 int num_visits, | |
| 130 base::Time first_visit); | |
| 131 | 129 |
| 132 // Records the time it took for the user to react to the | 130 // Records the time it took for the user to react to the |
| 133 // interstitial. We won't double-count if this method is called | 131 // interstitial. We won't double-count if this method is called |
| 134 // multiple times. | 132 // multiple times. |
| 135 void RecordUserReactionTime(const std::string& command); | 133 void RecordUserReactionTime(const std::string& command); |
| 136 | 134 |
| 137 // Checks if we should even show the malware details option. For example, we | 135 // Checks if we should even show the malware details option. For example, we |
| 138 // don't show it in incognito mode. | 136 // don't show it in incognito mode. |
| 139 bool CanShowMalwareDetailsOption(); | 137 bool CanShowMalwareDetailsOption(); |
| 140 | 138 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 TYPE_MALWARE_AND_PHISHING, | 212 TYPE_MALWARE_AND_PHISHING, |
| 215 } interstitial_type_; | 213 } interstitial_type_; |
| 216 | 214 |
| 217 // The factory used to instanciate SafeBrowsingBlockingPage objects. | 215 // The factory used to instanciate SafeBrowsingBlockingPage objects. |
| 218 // Usefull for tests, so they can provide their own implementation of | 216 // Usefull for tests, so they can provide their own implementation of |
| 219 // SafeBrowsingBlockingPage. | 217 // SafeBrowsingBlockingPage. |
| 220 static SafeBrowsingBlockingPageFactory* factory_; | 218 static SafeBrowsingBlockingPageFactory* factory_; |
| 221 | 219 |
| 222 // How many times is this same URL in history? Used for histogramming. | 220 // How many times is this same URL in history? Used for histogramming. |
| 223 int num_visits_; | 221 int num_visits_; |
| 224 CancelableRequestConsumer request_consumer_; | 222 base::CancelableTaskTracker request_tracker_; |
| 225 | 223 |
| 226 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 224 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
| 227 }; | 225 }; |
| 228 | 226 |
| 229 class SafeBrowsingBlockingPageV1 : public SafeBrowsingBlockingPage { | 227 class SafeBrowsingBlockingPageV1 : public SafeBrowsingBlockingPage { |
| 230 public: | 228 public: |
| 231 // Don't instanciate this class directly, use ShowBlockingPage instead. | 229 // Don't instanciate this class directly, use ShowBlockingPage instead. |
| 232 SafeBrowsingBlockingPageV1(SafeBrowsingUIManager* ui_manager, | 230 SafeBrowsingBlockingPageV1(SafeBrowsingUIManager* ui_manager, |
| 233 content::WebContents* web_contents, | 231 content::WebContents* web_contents, |
| 234 const UnsafeResourceList& unsafe_resources); | 232 const UnsafeResourceList& unsafe_resources); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 public: | 308 public: |
| 311 virtual ~SafeBrowsingBlockingPageFactory() { } | 309 virtual ~SafeBrowsingBlockingPageFactory() { } |
| 312 | 310 |
| 313 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 311 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 314 SafeBrowsingUIManager* ui_manager, | 312 SafeBrowsingUIManager* ui_manager, |
| 315 content::WebContents* web_contents, | 313 content::WebContents* web_contents, |
| 316 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 314 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
| 317 }; | 315 }; |
| 318 | 316 |
| 319 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 317 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
| OLD | NEW |