| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 10 #include <string> | 11 #include <string> |
| 11 #include <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/macros.h" | 14 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | |
| 16 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 16 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
| 17 #include "chrome/browser/safe_browsing/ui_manager.h" | 17 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 18 #include "components/safe_browsing_db/database_manager.h" | 18 #include "components/safe_browsing_db/database_manager.h" |
| 19 #include "content/public/browser/resource_request_details.h" | 19 #include "content/public/browser/resource_request_details.h" |
| 20 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 | 22 |
| 23 namespace safe_browsing { | 23 namespace safe_browsing { |
| 24 class ClientPhishingRequest; | 24 class ClientPhishingRequest; |
| 25 class ClientSideDetectionService; | 25 class ClientSideDetectionService; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // Callback that is called when the malware IP server ping back is | 89 // Callback that is called when the malware IP server ping back is |
| 90 // done. Display an interstitial if |is_malware| is true. | 90 // done. Display an interstitial if |is_malware| is true. |
| 91 // Otherwise, we do nothing. Called in UI thread. | 91 // Otherwise, we do nothing. Called in UI thread. |
| 92 void MaybeShowMalwareWarning(GURL original_url, GURL malware_url, | 92 void MaybeShowMalwareWarning(GURL original_url, GURL malware_url, |
| 93 bool is_malware); | 93 bool is_malware); |
| 94 | 94 |
| 95 // Callback that is called when the browser feature extractor is done. | 95 // Callback that is called when the browser feature extractor is done. |
| 96 // This method is responsible for deleting the request object. Called on | 96 // This method is responsible for deleting the request object. Called on |
| 97 // the UI thread. | 97 // the UI thread. |
| 98 void FeatureExtractionDone(bool success, | 98 void FeatureExtractionDone(bool success, |
| 99 scoped_ptr<ClientPhishingRequest> request); | 99 std::unique_ptr<ClientPhishingRequest> request); |
| 100 | 100 |
| 101 // Start malware classification once the onload handler was called and | 101 // Start malware classification once the onload handler was called and |
| 102 // malware pre-classification checks are done and passed. | 102 // malware pre-classification checks are done and passed. |
| 103 void MaybeStartMalwareFeatureExtraction(); | 103 void MaybeStartMalwareFeatureExtraction(); |
| 104 | 104 |
| 105 // Function to be called when the browser malware feature extractor is done. | 105 // Function to be called when the browser malware feature extractor is done. |
| 106 // Called on the UI thread. | 106 // Called on the UI thread. |
| 107 void MalwareFeatureExtractionDone( | 107 void MalwareFeatureExtractionDone( |
| 108 bool success, scoped_ptr<ClientMalwareRequest> request); | 108 bool success, |
| 109 std::unique_ptr<ClientMalwareRequest> request); |
| 109 | 110 |
| 110 // Update the entries in browse_info_->ips map. | 111 // Update the entries in browse_info_->ips map. |
| 111 void UpdateIPUrlMap(const std::string& ip, | 112 void UpdateIPUrlMap(const std::string& ip, |
| 112 const std::string& url, | 113 const std::string& url, |
| 113 const std::string& method, | 114 const std::string& method, |
| 114 const std::string& referrer, | 115 const std::string& referrer, |
| 115 const content::ResourceType resource_type); | 116 const content::ResourceType resource_type); |
| 116 | 117 |
| 117 // Inherited from WebContentsObserver. This is called once the page is | 118 // Inherited from WebContentsObserver. This is called once the page is |
| 118 // done loading. | 119 // done loading. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 130 | 131 |
| 131 // This pointer may be NULL if client-side phishing detection is disabled. | 132 // This pointer may be NULL if client-side phishing detection is disabled. |
| 132 ClientSideDetectionService* csd_service_; | 133 ClientSideDetectionService* csd_service_; |
| 133 // These pointers may be NULL if SafeBrowsing is disabled. | 134 // These pointers may be NULL if SafeBrowsing is disabled. |
| 134 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; | 135 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; |
| 135 scoped_refptr<SafeBrowsingUIManager> ui_manager_; | 136 scoped_refptr<SafeBrowsingUIManager> ui_manager_; |
| 136 // Keep a handle to the latest classification request so that we can cancel | 137 // Keep a handle to the latest classification request so that we can cancel |
| 137 // it if necessary. | 138 // it if necessary. |
| 138 scoped_refptr<ShouldClassifyUrlRequest> classification_request_; | 139 scoped_refptr<ShouldClassifyUrlRequest> classification_request_; |
| 139 // Browser-side feature extractor. | 140 // Browser-side feature extractor. |
| 140 scoped_ptr<BrowserFeatureExtractor> feature_extractor_; | 141 std::unique_ptr<BrowserFeatureExtractor> feature_extractor_; |
| 141 // Keeps some info about the current page visit while the renderer | 142 // Keeps some info about the current page visit while the renderer |
| 142 // classification is going on. Since we cancel classification on | 143 // classification is going on. Since we cancel classification on |
| 143 // every page load we can simply keep this data around as a member | 144 // every page load we can simply keep this data around as a member |
| 144 // variable. This information will be passed on to the feature extractor. | 145 // variable. This information will be passed on to the feature extractor. |
| 145 scoped_ptr<BrowseInfo> browse_info_; | 146 std::unique_ptr<BrowseInfo> browse_info_; |
| 146 // Redirect chain that leads to the first page of the current host. We keep | 147 // Redirect chain that leads to the first page of the current host. We keep |
| 147 // track of this for browse_info_. | 148 // track of this for browse_info_. |
| 148 std::vector<GURL> cur_host_redirects_; | 149 std::vector<GURL> cur_host_redirects_; |
| 149 // Current host, used to help determine cur_host_redirects_. | 150 // Current host, used to help determine cur_host_redirects_. |
| 150 std::string cur_host_; | 151 std::string cur_host_; |
| 151 | 152 |
| 152 // Max number of ips we save for each browse | 153 // Max number of ips we save for each browse |
| 153 static const size_t kMaxIPsPerBrowse; | 154 static const size_t kMaxIPsPerBrowse; |
| 154 // Max number of urls we report for each malware IP. | 155 // Max number of urls we report for each malware IP. |
| 155 static const size_t kMaxUrlsPerIP; | 156 static const size_t kMaxUrlsPerIP; |
| 156 | 157 |
| 157 bool should_extract_malware_features_; | 158 bool should_extract_malware_features_; |
| 158 bool should_classify_for_malware_; | 159 bool should_classify_for_malware_; |
| 159 bool pageload_complete_; | 160 bool pageload_complete_; |
| 160 | 161 |
| 161 // Unique page ID of the most recent unsafe site that was loaded in this tab | 162 // Unique page ID of the most recent unsafe site that was loaded in this tab |
| 162 // as well as the UnsafeResource. | 163 // as well as the UnsafeResource. |
| 163 int unsafe_unique_page_id_; | 164 int unsafe_unique_page_id_; |
| 164 scoped_ptr<SafeBrowsingUIManager::UnsafeResource> unsafe_resource_; | 165 std::unique_ptr<SafeBrowsingUIManager::UnsafeResource> unsafe_resource_; |
| 165 | 166 |
| 166 base::WeakPtrFactory<ClientSideDetectionHost> weak_factory_; | 167 base::WeakPtrFactory<ClientSideDetectionHost> weak_factory_; |
| 167 | 168 |
| 168 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); | 169 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); |
| 169 }; | 170 }; |
| 170 | 171 |
| 171 } // namespace safe_browsing | 172 } // namespace safe_browsing |
| 172 | 173 |
| 173 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ | 174 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
| OLD | NEW |