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

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

Issue 2035293002: Remove URLRequest::GetResponseCookies and URLRequestJob::GetResponseCookies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments rogerta Created 4 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/client_side_detection_service.h" 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 199
200 return address.IsReserved(); 200 return address.IsReserved();
201 } 201 }
202 202
203 void ClientSideDetectionService::OnURLFetchComplete( 203 void ClientSideDetectionService::OnURLFetchComplete(
204 const net::URLFetcher* source) { 204 const net::URLFetcher* source) {
205 std::string data; 205 std::string data;
206 source->GetResponseAsString(&data); 206 source->GetResponseAsString(&data);
207 207
208 if (client_phishing_reports_.find(source) != client_phishing_reports_.end()) { 208 if (client_phishing_reports_.find(source) != client_phishing_reports_.end()) {
209 HandlePhishingVerdict( 209 HandlePhishingVerdict(source, source->GetURL(), source->GetStatus(),
210 source, source->GetURL(), source->GetStatus(), 210 source->GetResponseCode(), data);
211 source->GetResponseCode(), source->GetCookies(), data);
212 } else if (client_malware_reports_.find(source) != 211 } else if (client_malware_reports_.find(source) !=
213 client_malware_reports_.end()) { 212 client_malware_reports_.end()) {
214 HandleMalwareVerdict( 213 HandleMalwareVerdict(source, source->GetURL(), source->GetStatus(),
215 source, source->GetURL(), source->GetStatus(), 214 source->GetResponseCode(), data);
216 source->GetResponseCode(), source->GetCookies(), data);
217 } else { 215 } else {
218 NOTREACHED(); 216 NOTREACHED();
219 } 217 }
220 } 218 }
221 219
222 void ClientSideDetectionService::Observe( 220 void ClientSideDetectionService::Observe(
223 int type, 221 int type,
224 const content::NotificationSource& source, 222 const content::NotificationSource& source,
225 const content::NotificationDetails& details) { 223 const content::NotificationDetails& details) {
226 DCHECK_CURRENTLY_ON(BrowserThread::UI); 224 DCHECK_CURRENTLY_ON(BrowserThread::UI);
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // Record that we made a malware request 361 // Record that we made a malware request
364 malware_report_times_.push(base::Time::Now()); 362 malware_report_times_.push(base::Time::Now());
365 } 363 }
366 364
367 365
368 void ClientSideDetectionService::HandlePhishingVerdict( 366 void ClientSideDetectionService::HandlePhishingVerdict(
369 const net::URLFetcher* source, 367 const net::URLFetcher* source,
370 const GURL& url, 368 const GURL& url,
371 const net::URLRequestStatus& status, 369 const net::URLRequestStatus& status,
372 int response_code, 370 int response_code,
373 const net::ResponseCookies& cookies,
374 const std::string& data) { 371 const std::string& data) {
375 ClientPhishingResponse response; 372 ClientPhishingResponse response;
376 std::unique_ptr<ClientReportInfo> info(client_phishing_reports_[source]); 373 std::unique_ptr<ClientReportInfo> info(client_phishing_reports_[source]);
377 bool is_phishing = false; 374 bool is_phishing = false;
378 if (status.is_success() && net::HTTP_OK == response_code && 375 if (status.is_success() && net::HTTP_OK == response_code &&
379 response.ParseFromString(data)) { 376 response.ParseFromString(data)) {
380 // Cache response, possibly flushing an old one. 377 // Cache response, possibly flushing an old one.
381 cache_[info->phishing_url] = 378 cache_[info->phishing_url] =
382 make_linked_ptr(new CacheState(response.phishy(), base::Time::Now())); 379 make_linked_ptr(new CacheState(response.phishy(), base::Time::Now()));
383 is_phishing = response.phishy(); 380 is_phishing = response.phishy();
384 } else { 381 } else {
385 DLOG(ERROR) << "Unable to get the server verdict for URL: " 382 DLOG(ERROR) << "Unable to get the server verdict for URL: "
386 << info->phishing_url << " status: " << status.status() << " " 383 << info->phishing_url << " status: " << status.status() << " "
387 << "response_code:" << response_code; 384 << "response_code:" << response_code;
388 } 385 }
389 if (!info->callback.is_null()) 386 if (!info->callback.is_null())
390 info->callback.Run(info->phishing_url, is_phishing); 387 info->callback.Run(info->phishing_url, is_phishing);
391 client_phishing_reports_.erase(source); 388 client_phishing_reports_.erase(source);
392 delete source; 389 delete source;
393 } 390 }
394 391
395 void ClientSideDetectionService::HandleMalwareVerdict( 392 void ClientSideDetectionService::HandleMalwareVerdict(
396 const net::URLFetcher* source, 393 const net::URLFetcher* source,
397 const GURL& url, 394 const GURL& url,
398 const net::URLRequestStatus& status, 395 const net::URLRequestStatus& status,
399 int response_code, 396 int response_code,
400 const net::ResponseCookies& cookies,
401 const std::string& data) { 397 const std::string& data) {
402 if (status.is_success()) { 398 if (status.is_success()) {
403 UMA_HISTOGRAM_SPARSE_SLOWLY( 399 UMA_HISTOGRAM_SPARSE_SLOWLY(
404 "SBClientMalware.IPBlacklistRequestResponseCode", response_code); 400 "SBClientMalware.IPBlacklistRequestResponseCode", response_code);
405 } 401 }
406 // status error is negative, so we put - in front of it. 402 // status error is negative, so we put - in front of it.
407 UMA_HISTOGRAM_SPARSE_SLOWLY( 403 UMA_HISTOGRAM_SPARSE_SLOWLY(
408 "SBClientMalware.IPBlacklistRequestNetError", -status.error()); 404 "SBClientMalware.IPBlacklistRequestNetError", -status.error());
409 405
410 ClientMalwareResponse response; 406 ClientMalwareResponse response;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 const std::string& report_url) { 517 const std::string& report_url) {
522 GURL url(report_url); 518 GURL url(report_url);
523 std::string api_key = google_apis::GetAPIKey(); 519 std::string api_key = google_apis::GetAPIKey();
524 if (!api_key.empty()) 520 if (!api_key.empty())
525 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); 521 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true));
526 522
527 return url; 523 return url;
528 } 524 }
529 525
530 } // namespace safe_browsing 526 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698