Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Side by Side Diff: chrome/browser/safe_browsing/browser_feature_extractor.cc

Issue 7189074: Send the referral URL with the client-side phishing detection request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Brian's comments. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 15 matching lines...) Expand all
26 const char kUrlHistoryTypedCount[] = "UrlHistoryTypedCount"; 26 const char kUrlHistoryTypedCount[] = "UrlHistoryTypedCount";
27 const char kUrlHistoryLinkCount[] = "UrlHistoryLinkCount"; 27 const char kUrlHistoryLinkCount[] = "UrlHistoryLinkCount";
28 const char kUrlHistoryVisitCountMoreThan24hAgo[] = 28 const char kUrlHistoryVisitCountMoreThan24hAgo[] =
29 "UrlHistoryVisitCountMoreThan24hAgo"; 29 "UrlHistoryVisitCountMoreThan24hAgo";
30 const char kHttpHostVisitCount[] = "HttpHostVisitCount"; 30 const char kHttpHostVisitCount[] = "HttpHostVisitCount";
31 const char kHttpsHostVisitCount[] = "HttpsHostVisitCount"; 31 const char kHttpsHostVisitCount[] = "HttpsHostVisitCount";
32 const char kFirstHttpHostVisitMoreThan24hAgo[] = 32 const char kFirstHttpHostVisitMoreThan24hAgo[] =
33 "FirstHttpHostVisitMoreThan24hAgo"; 33 "FirstHttpHostVisitMoreThan24hAgo";
34 const char kFirstHttpsHostVisitMoreThan24hAgo[] = 34 const char kFirstHttpsHostVisitMoreThan24hAgo[] =
35 "FirstHttpsHostVisitMoreThan24hAgo"; 35 "FirstHttpsHostVisitMoreThan24hAgo";
36 const char kHasSSLReferrer[] = "HasSSLReferrer";
37 const char kPageTransitionType[] = "PageTransitionType";
36 } // namespace features 38 } // namespace features
37 39
38 static void AddFeature(const std::string& feature_name, 40 static void AddFeature(const std::string& feature_name,
39 double feature_value, 41 double feature_value,
40 ClientPhishingRequest* request) { 42 ClientPhishingRequest* request) {
41 DCHECK(request); 43 DCHECK(request);
42 ClientPhishingRequest::Feature* feature = 44 ClientPhishingRequest::Feature* feature =
43 request->add_non_model_feature_map(); 45 request->add_non_model_feature_map();
44 feature->set_name(feature_name); 46 feature->set_name(feature_name);
45 feature->set_value(feature_value); 47 feature->set_value(feature_value);
(...skipping 21 matching lines...) Expand all
67 if (history) { 69 if (history) {
68 history->CancelRequest(it->first); 70 history->CancelRequest(it->first);
69 } 71 }
70 ExtractionData& extraction = it->second; 72 ExtractionData& extraction = it->second;
71 delete extraction.first; // delete request 73 delete extraction.first; // delete request
72 delete extraction.second; // delete callback 74 delete extraction.second; // delete callback
73 } 75 }
74 pending_queries_.clear(); 76 pending_queries_.clear();
75 } 77 }
76 78
77 void BrowserFeatureExtractor::ExtractFeatures(ClientPhishingRequest* request, 79 void BrowserFeatureExtractor::ExtractFeatures(const BrowseInfo& info,
80 ClientPhishingRequest* request,
78 DoneCallback* callback) { 81 DoneCallback* callback) {
79 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
80 DCHECK(request); 83 DCHECK(request);
81 DCHECK_EQ(0U, request->url().find("http:")); 84 DCHECK_EQ(0U, request->url().find("http:"));
82 DCHECK(callback); 85 DCHECK(callback);
83 if (!callback) { 86 if (!callback) {
84 DLOG(ERROR) << "ExtractFeatures called without a callback object"; 87 DLOG(ERROR) << "ExtractFeatures called without a callback object";
85 return; 88 return;
86 } 89 }
90 bool is_secure_referrer = info.referrer.SchemeIsSecure();
91 if (!is_secure_referrer) {
92 request->set_referrer_url(info.referrer.spec());
93 }
94 AddFeature(features::kHasSSLReferrer,
95 is_secure_referrer ? 1.0 : 0.0,
96 request);
97 AddFeature(features::kPageTransitionType,
98 static_cast<double>(
99 PageTransition::StripQualifier(info.transition)),
100 request);
101
87 pending_extractions_.insert(std::make_pair(request, callback)); 102 pending_extractions_.insert(std::make_pair(request, callback));
88 MessageLoop::current()->PostTask( 103 MessageLoop::current()->PostTask(
89 FROM_HERE, 104 FROM_HERE,
90 method_factory_.NewRunnableMethod( 105 method_factory_.NewRunnableMethod(
91 &BrowserFeatureExtractor::StartExtractFeatures, 106 &BrowserFeatureExtractor::StartExtractFeatures,
92 request, callback)); 107 request, callback));
93 } 108 }
94 109
95 void BrowserFeatureExtractor::StartExtractFeatures( 110 void BrowserFeatureExtractor::StartExtractFeatures(
96 ClientPhishingRequest* request, 111 ClientPhishingRequest* request,
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 if (tab_ && tab_->profile()) { 310 if (tab_ && tab_->profile()) {
296 *history = tab_->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); 311 *history = tab_->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
297 if (*history) { 312 if (*history) {
298 return true; 313 return true;
299 } 314 }
300 } 315 }
301 VLOG(2) << "Unable to query history. No history service available."; 316 VLOG(2) << "Unable to query history. No history service available.";
302 return false; 317 return false;
303 } 318 }
304 }; // namespace safe_browsing 319 }; // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698