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 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" | 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "chrome/browser/safe_browsing/browser_features.h" | 21 #include "chrome/browser/safe_browsing/browser_features.h" |
22 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 22 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
23 #include "content/browser/browser_thread.h" | 23 #include "content/browser/browser_thread.h" |
24 #include "content/browser/cancelable_request.h" | 24 #include "content/browser/cancelable_request.h" |
25 #include "content/browser/tab_contents/tab_contents.h" | 25 #include "content/browser/tab_contents/tab_contents.h" |
26 #include "content/public/common/page_transition_types.h" | 26 #include "content/public/common/page_transition_types.h" |
27 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
28 | 28 |
29 namespace safe_browsing { | 29 namespace safe_browsing { |
30 | 30 |
31 BrowseInfo::BrowseInfo() {} | 31 BrowseInfo::BrowseInfo() : http_status_code(0) {} |
32 | 32 |
33 BrowseInfo::~BrowseInfo() {} | 33 BrowseInfo::~BrowseInfo() {} |
34 | 34 |
35 static void AddFeature(const std::string& feature_name, | 35 static void AddFeature(const std::string& feature_name, |
36 double feature_value, | 36 double feature_value, |
37 ClientPhishingRequest* request) { | 37 ClientPhishingRequest* request) { |
38 DCHECK(request); | 38 DCHECK(request); |
39 ClientPhishingRequest::Feature* feature = | 39 ClientPhishingRequest::Feature* feature = |
40 request->add_non_model_feature_map(); | 40 request->add_non_model_feature_map(); |
41 feature->set_name(feature_name); | 41 feature->set_name(feature_name); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 info.unsafe_resource->original_url.spec(), | 225 info.unsafe_resource->original_url.spec(), |
226 1.0, | 226 1.0, |
227 request); | 227 request); |
228 AddFeature(features::kSafeBrowsingIsSubresource, | 228 AddFeature(features::kSafeBrowsingIsSubresource, |
229 info.unsafe_resource->is_subresource ? 1.0 : 0.0, | 229 info.unsafe_resource->is_subresource ? 1.0 : 0.0, |
230 request); | 230 request); |
231 AddFeature(features::kSafeBrowsingThreatType, | 231 AddFeature(features::kSafeBrowsingThreatType, |
232 static_cast<double>(info.unsafe_resource->threat_type), | 232 static_cast<double>(info.unsafe_resource->threat_type), |
233 request); | 233 request); |
234 } | 234 } |
235 | 235 if (info.http_status_code != 0) { |
| 236 AddFeature(features::kHttpStatusCode, info.http_status_code, request); |
| 237 } |
236 } | 238 } |
237 | 239 |
238 void BrowserFeatureExtractor::StartExtractFeatures( | 240 void BrowserFeatureExtractor::StartExtractFeatures( |
239 ClientPhishingRequest* request, | 241 ClientPhishingRequest* request, |
240 DoneCallback* callback) { | 242 DoneCallback* callback) { |
241 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
242 ExtractionData extraction = std::make_pair(request, callback); | 244 ExtractionData extraction = std::make_pair(request, callback); |
243 size_t removed = pending_extractions_.erase(extraction); | 245 size_t removed = pending_extractions_.erase(extraction); |
244 DCHECK_EQ(1U, removed); | 246 DCHECK_EQ(1U, removed); |
245 HistoryService* history; | 247 HistoryService* history; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 *history = profile->GetHistoryService(Profile::EXPLICIT_ACCESS); | 445 *history = profile->GetHistoryService(Profile::EXPLICIT_ACCESS); |
444 if (*history) { | 446 if (*history) { |
445 return true; | 447 return true; |
446 } | 448 } |
447 } | 449 } |
448 VLOG(2) << "Unable to query history. No history service available."; | 450 VLOG(2) << "Unable to query history. No history service available."; |
449 return false; | 451 return false; |
450 } | 452 } |
451 | 453 |
452 } // namespace safe_browsing | 454 } // namespace safe_browsing |
OLD | NEW |