| OLD | NEW |
| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/profiler/scoped_profile.h" |
| 17 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/safe_browsing/client_model.pb.h" | 25 #include "chrome/common/safe_browsing/client_model.pb.h" |
| 25 #include "chrome/common/safe_browsing/csd.pb.h" | 26 #include "chrome/common/safe_browsing/csd.pb.h" |
| 26 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 27 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 VLOG(2) << "Unable to parse IP address: '" << ip_address << "'"; | 192 VLOG(2) << "Unable to parse IP address: '" << ip_address << "'"; |
| 192 // Err on the side of safety and assume this might be private. | 193 // Err on the side of safety and assume this might be private. |
| 193 return true; | 194 return true; |
| 194 } | 195 } |
| 195 | 196 |
| 196 return net::IsIPAddressReserved(ip_number); | 197 return net::IsIPAddressReserved(ip_number); |
| 197 } | 198 } |
| 198 | 199 |
| 199 void ClientSideDetectionService::OnURLFetchComplete( | 200 void ClientSideDetectionService::OnURLFetchComplete( |
| 200 const net::URLFetcher* source) { | 201 const net::URLFetcher* source) { |
| 202 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. |
| 203 tracked_objects::ScopedProfile tracking_profile( |
| 204 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 205 "422577 ClientSideDetectionService::OnURLFetchComplete")); |
| 206 |
| 201 std::string data; | 207 std::string data; |
| 202 source->GetResponseAsString(&data); | 208 source->GetResponseAsString(&data); |
| 203 if (source == model_fetcher_.get()) { | 209 if (source == model_fetcher_.get()) { |
| 204 HandleModelResponse( | 210 HandleModelResponse( |
| 205 source, source->GetURL(), source->GetStatus(), | 211 source, source->GetURL(), source->GetStatus(), |
| 206 source->GetResponseCode(), source->GetCookies(), data); | 212 source->GetResponseCode(), source->GetCookies(), data); |
| 207 } else if (client_phishing_reports_.find(source) != | 213 } else if (client_phishing_reports_.find(source) != |
| 208 client_phishing_reports_.end()) { | 214 client_phishing_reports_.end()) { |
| 209 HandlePhishingVerdict( | 215 HandlePhishingVerdict( |
| 210 source, source->GetURL(), source->GetStatus(), | 216 source, source->GetURL(), source->GetStatus(), |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 GURL ClientSideDetectionService::GetClientReportUrl( | 641 GURL ClientSideDetectionService::GetClientReportUrl( |
| 636 const std::string& report_url) { | 642 const std::string& report_url) { |
| 637 GURL url(report_url); | 643 GURL url(report_url); |
| 638 std::string api_key = google_apis::GetAPIKey(); | 644 std::string api_key = google_apis::GetAPIKey(); |
| 639 if (!api_key.empty()) | 645 if (!api_key.empty()) |
| 640 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 646 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 641 | 647 |
| 642 return url; | 648 return url; |
| 643 } | 649 } |
| 644 } // namespace safe_browsing | 650 } // namespace safe_browsing |
| OLD | NEW |