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 // BrowserFeatureExtractor computes various browser features for client-side | 5 // BrowserFeatureExtractor computes various browser features for client-side |
6 // phishing detection. For now it does a bunch of lookups in the history | 6 // phishing detection. For now it does a bunch of lookups in the history |
7 // service to see whether a particular URL has been visited before by the | 7 // service to see whether a particular URL has been visited before by the |
8 // user. | 8 // user. |
9 | 9 |
10 #ifndef CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ | 10 #ifndef CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ |
11 #define CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ | 11 #define CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ |
12 | 12 |
13 #include <map> | 13 #include <map> |
14 #include <set> | 14 #include <set> |
15 #include <string> | 15 #include <string> |
16 #include <utility> | 16 #include <utility> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "base/basictypes.h" | 19 #include "base/basictypes.h" |
20 #include "base/callback.h" | 20 #include "base/callback.h" |
21 #include "base/containers/hash_tables.h" | 21 #include "base/containers/hash_tables.h" |
22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
23 #include "base/sequenced_task_runner_helpers.h" | 23 #include "base/sequenced_task_runner_helpers.h" |
24 #include "base/task/cancelable_task_tracker.h" | |
25 #include "base/time/time.h" | 24 #include "base/time/time.h" |
26 #include "chrome/browser/common/cancelable_request.h" | 25 #include "chrome/browser/common/cancelable_request.h" |
27 #include "chrome/browser/history/history_types.h" | 26 #include "chrome/browser/history/history_types.h" |
28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
29 #include "chrome/browser/safe_browsing/ui_manager.h" | 28 #include "chrome/browser/safe_browsing/ui_manager.h" |
30 #include "url/gurl.h" | 29 #include "url/gurl.h" |
31 #include "webkit/common/resource_type.h" | 30 #include "webkit/common/resource_type.h" |
32 | 31 |
33 | 32 |
34 class HistoryService; | 33 class HistoryService; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Synchronous browser feature extraction. | 137 // Synchronous browser feature extraction. |
139 void ExtractBrowseInfoFeatures(const BrowseInfo& info, | 138 void ExtractBrowseInfoFeatures(const BrowseInfo& info, |
140 ClientPhishingRequest* request); | 139 ClientPhishingRequest* request); |
141 | 140 |
142 // Actually starts feature extraction (does the real work). | 141 // Actually starts feature extraction (does the real work). |
143 void StartExtractFeatures(ClientPhishingRequest* request, | 142 void StartExtractFeatures(ClientPhishingRequest* request, |
144 const DoneCallback& callback); | 143 const DoneCallback& callback); |
145 | 144 |
146 // HistoryService callback which is called when we're done querying URL visits | 145 // HistoryService callback which is called when we're done querying URL visits |
147 // in the history. | 146 // in the history. |
148 void QueryUrlHistoryDone(scoped_ptr<ClientPhishingRequest> request, | 147 void QueryUrlHistoryDone(CancelableRequestProvider::Handle handle, |
149 const DoneCallback& callback, | |
150 bool success, | 148 bool success, |
151 const history::URLRow& row, | 149 const history::URLRow* row, |
152 const history::VisitVector& visits); | 150 history::VisitVector* visits); |
153 | 151 |
154 // HistoryService callback which is called when we're done querying HTTP host | 152 // HistoryService callback which is called when we're done querying HTTP host |
155 // visits in the history. | 153 // visits in the history. |
156 void QueryHttpHostVisitsDone(CancelableRequestProvider::Handle handle, | 154 void QueryHttpHostVisitsDone(CancelableRequestProvider::Handle handle, |
157 bool success, | 155 bool success, |
158 int num_visits, | 156 int num_visits, |
159 base::Time first_visit); | 157 base::Time first_visit); |
160 | 158 |
161 // HistoryService callback which is called when we're done querying HTTPS host | 159 // HistoryService callback which is called when we're done querying HTTPS host |
162 // visits in the history. | 160 // visits in the history. |
(...skipping 30 matching lines...) Expand all Loading... |
193 | 191 |
194 // Helper function which is called when we're done filtering out benign IPs | 192 // Helper function which is called when we're done filtering out benign IPs |
195 // on the IO thread. This function is called on the UI thread. | 193 // on the IO thread. This function is called on the UI thread. |
196 void FinishExtractMalwareFeatures(scoped_ptr<IPUrlMap> bad_ips, | 194 void FinishExtractMalwareFeatures(scoped_ptr<IPUrlMap> bad_ips, |
197 MalwareDoneCallback callback, | 195 MalwareDoneCallback callback, |
198 scoped_ptr<ClientMalwareRequest> request); | 196 scoped_ptr<ClientMalwareRequest> request); |
199 | 197 |
200 content::WebContents* tab_; | 198 content::WebContents* tab_; |
201 ClientSideDetectionHost* host_; | 199 ClientSideDetectionHost* host_; |
202 CancelableRequestConsumer request_consumer_; | 200 CancelableRequestConsumer request_consumer_; |
203 base::CancelableTaskTracker cancelable_task_tracker_; | |
204 base::WeakPtrFactory<BrowserFeatureExtractor> weak_factory_; | 201 base::WeakPtrFactory<BrowserFeatureExtractor> weak_factory_; |
205 | 202 |
206 // Set of pending extractions (i.e. extractions for which ExtractFeatures was | 203 // Set of pending extractions (i.e. extractions for which ExtractFeatures was |
207 // called but not StartExtractFeatures). | 204 // called but not StartExtractFeatures). |
208 std::map<ClientPhishingRequest*, DoneCallback> pending_extractions_; | 205 std::map<ClientPhishingRequest*, DoneCallback> pending_extractions_; |
209 | 206 |
210 // Set of pending queries (i.e., where history->Query...() was called but | 207 // Set of pending queries (i.e., where history->Query...() was called but |
211 // the history callback hasn't been invoked yet). | 208 // the history callback hasn't been invoked yet). |
212 PendingQueriesMap pending_queries_; | 209 PendingQueriesMap pending_queries_; |
213 | 210 |
214 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor); | 211 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor); |
215 }; | 212 }; |
216 | 213 |
217 } // namespace safe_browsing | 214 } // namespace safe_browsing |
218 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ | 215 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ |
OLD | NEW |