| 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 #pragma once | 12 #pragma once |
| 13 | 13 |
| 14 #include <map> | 14 #include <map> |
| 15 #include <set> | 15 #include <set> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <utility> | 17 #include <utility> |
| 18 #include <vector> | 18 #include <vector> |
| 19 | 19 |
| 20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
| 21 #include "base/callback.h" | 21 #include "base/callback.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/task.h" | 23 #include "base/message_loop_helpers.h" |
| 24 #include "base/time.h" | 24 #include "base/time.h" |
| 25 #include "chrome/browser/cancelable_request.h" | 25 #include "chrome/browser/cancelable_request.h" |
| 26 #include "chrome/browser/history/history_types.h" | 26 #include "chrome/browser/history/history_types.h" |
| 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 28 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
| 29 | 29 |
| 30 class HistoryService; | 30 class HistoryService; |
| 31 | 31 |
| 32 namespace content { | 32 namespace content { |
| 33 class WebContents; | 33 class WebContents; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 // of the request object until |callback| is called (see DoneCallback above) | 82 // of the request object until |callback| is called (see DoneCallback above) |
| 83 // and will write the extracted features to the feature map. Once the | 83 // and will write the extracted features to the feature map. Once the |
| 84 // feature extraction is complete, |callback| is run on the UI thread. We | 84 // feature extraction is complete, |callback| is run on the UI thread. We |
| 85 // take ownership of the |callback| object. |info| may not be valid after | 85 // take ownership of the |callback| object. |info| may not be valid after |
| 86 // ExtractFeatures returns. This method must run on the UI thread. | 86 // ExtractFeatures returns. This method must run on the UI thread. |
| 87 virtual void ExtractFeatures(const BrowseInfo* info, | 87 virtual void ExtractFeatures(const BrowseInfo* info, |
| 88 ClientPhishingRequest* request, | 88 ClientPhishingRequest* request, |
| 89 const DoneCallback& callback); | 89 const DoneCallback& callback); |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 friend class DeleteTask<BrowserFeatureExtractor>; | 92 friend class base::DeleteHelper<BrowserFeatureExtractor>; |
| 93 typedef std::pair<ClientPhishingRequest*, DoneCallback> ExtractionData; | 93 typedef std::pair<ClientPhishingRequest*, DoneCallback> ExtractionData; |
| 94 typedef std::map<CancelableRequestProvider::Handle, | 94 typedef std::map<CancelableRequestProvider::Handle, |
| 95 ExtractionData> PendingQueriesMap; | 95 ExtractionData> PendingQueriesMap; |
| 96 | 96 |
| 97 // Synchronous browser feature extraction. | 97 // Synchronous browser feature extraction. |
| 98 void ExtractBrowseInfoFeatures(const BrowseInfo& info, | 98 void ExtractBrowseInfoFeatures(const BrowseInfo& info, |
| 99 ClientPhishingRequest* request); | 99 ClientPhishingRequest* request); |
| 100 | 100 |
| 101 // Actually starts feature extraction (does the real work). | 101 // Actually starts feature extraction (does the real work). |
| 102 void StartExtractFeatures(ClientPhishingRequest* request, | 102 void StartExtractFeatures(ClientPhishingRequest* request, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 // Set of pending queries (i.e., where history->Query...() was called but | 161 // Set of pending queries (i.e., where history->Query...() was called but |
| 162 // the history callback hasn't been invoked yet). | 162 // the history callback hasn't been invoked yet). |
| 163 PendingQueriesMap pending_queries_; | 163 PendingQueriesMap pending_queries_; |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor); | 165 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 } // namespace safe_browsing | 168 } // namespace safe_browsing |
| 169 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ | 169 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ |
| OLD | NEW |