| 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 <utility> | 16 #include <utility> |
| 17 | 17 |
| 18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
| 19 #include "base/callback_old.h" | 19 #include "base/callback_old.h" |
| 20 #include "base/memory/scoped_ptr.h" |
| 20 #include "base/task.h" | 21 #include "base/task.h" |
| 21 #include "base/time.h" | 22 #include "base/time.h" |
| 22 #include "chrome/browser/history/history_types.h" | 23 #include "chrome/browser/history/history_types.h" |
| 24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 23 #include "content/browser/cancelable_request.h" | 25 #include "content/browser/cancelable_request.h" |
| 24 | 26 |
| 25 class HistoryService; | 27 class HistoryService; |
| 26 class TabContents; | 28 class TabContents; |
| 27 | 29 |
| 28 namespace safe_browsing { | 30 namespace safe_browsing { |
| 29 class ClientPhishingRequest; | 31 class ClientPhishingRequest; |
| 30 class ClientSideDetectionService; | 32 class ClientSideDetectionService; |
| 31 | 33 |
| 32 struct BrowseInfo { | 34 struct BrowseInfo { |
| 33 // List of IPv4 and IPv6 addresses from which content was requested | 35 // List of IPv4 and IPv6 addresses from which content was requested |
| 34 // while browsing to the |url|. | 36 // while browsing to the |url|. |
| 35 std::set<std::string> ips; | 37 std::set<std::string> ips; |
| 36 | 38 |
| 39 // If a SafeBrowsing interstitial was shown for the current URL |
| 40 // this will contain the UnsafeResource struct for that URL. |
| 41 scoped_ptr<SafeBrowsingService::UnsafeResource> unsafe_resource; |
| 42 |
| 37 BrowseInfo(); | 43 BrowseInfo(); |
| 38 ~BrowseInfo(); | 44 ~BrowseInfo(); |
| 39 }; | 45 }; |
| 40 | 46 |
| 41 namespace features { | 47 namespace features { |
| 42 | 48 |
| 43 // TODO(noelutz): move renderer/safe_browsing/features.h to common. | 49 // TODO(noelutz): move renderer/safe_browsing/features.h to common. |
| 44 //////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////// |
| 45 // History features. | 51 // History features. |
| 46 //////////////////////////////////////////////////// | 52 //////////////////////////////////////////////////// |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 extern const char kReferrer[]; | 87 extern const char kReferrer[]; |
| 82 // True if the referrer was stripped because it is an SSL referrer. | 88 // True if the referrer was stripped because it is an SSL referrer. |
| 83 extern const char kHasSSLReferrer[]; | 89 extern const char kHasSSLReferrer[]; |
| 84 // Stores the page transition. See: PageTransition. We strip the qualifier. | 90 // Stores the page transition. See: PageTransition. We strip the qualifier. |
| 85 extern const char kPageTransitionType[]; | 91 extern const char kPageTransitionType[]; |
| 86 // True if this navigation is the first for this tab. | 92 // True if this navigation is the first for this tab. |
| 87 extern const char kIsFirstNavigation[]; | 93 extern const char kIsFirstNavigation[]; |
| 88 | 94 |
| 89 // Resource was fetched from a known bad IP address. | 95 // Resource was fetched from a known bad IP address. |
| 90 extern const char kBadIpFetch[]; | 96 extern const char kBadIpFetch[]; |
| 97 |
| 98 // SafeBrowsing related featues. Fields from the UnsafeResource if there is |
| 99 // any. |
| 100 extern const char kSafeBrowsingMaliciousUrl[]; |
| 101 extern const char kSafeBrowsingOriginalUrl[]; |
| 102 extern const char kSafeBrowsingIsSubresource[]; |
| 103 extern const char kSafeBrowsingThreatType[]; |
| 91 } // namespace features | 104 } // namespace features |
| 92 | 105 |
| 93 // All methods of this class must be called on the UI thread (including | 106 // All methods of this class must be called on the UI thread (including |
| 94 // the constructor). | 107 // the constructor). |
| 95 class BrowserFeatureExtractor { | 108 class BrowserFeatureExtractor { |
| 96 public: | 109 public: |
| 97 // Called when feature extraction is done. The first argument will be | 110 // Called when feature extraction is done. The first argument will be |
| 98 // true iff feature extraction succeeded. The second argument is the | 111 // true iff feature extraction succeeded. The second argument is the |
| 99 // phishing request which was modified by the feature extractor. The | 112 // phishing request which was modified by the feature extractor. The |
| 100 // DoneCallback takes ownership of the request object. | 113 // DoneCallback takes ownership of the request object. |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 std::set<ExtractionData> pending_extractions_; | 203 std::set<ExtractionData> pending_extractions_; |
| 191 | 204 |
| 192 // Set of pending queries (i.e., where history->Query...() was called but | 205 // Set of pending queries (i.e., where history->Query...() was called but |
| 193 // the history callback hasn't been invoked yet). | 206 // the history callback hasn't been invoked yet). |
| 194 PendingQueriesMap pending_queries_; | 207 PendingQueriesMap pending_queries_; |
| 195 | 208 |
| 196 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor); | 209 DISALLOW_COPY_AND_ASSIGN(BrowserFeatureExtractor); |
| 197 }; | 210 }; |
| 198 } // namespace safe_browsing | 211 } // namespace safe_browsing |
| 199 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ | 212 #endif // CHROME_BROWSER_SAFE_BROWSING_BROWSER_FEATURE_EXTRACTOR_H_ |
| OLD | NEW |