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/profiler/scoped_tracker.h" |
18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/safe_browsing/client_model.pb.h" | 25 #include "chrome/common/safe_browsing/client_model.pb.h" |
26 #include "chrome/common/safe_browsing/csd.pb.h" | 26 #include "chrome/common/safe_browsing/csd.pb.h" |
27 #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... |
192 VLOG(2) << "Unable to parse IP address: '" << ip_address << "'"; | 192 VLOG(2) << "Unable to parse IP address: '" << ip_address << "'"; |
193 // 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. |
194 return true; | 194 return true; |
195 } | 195 } |
196 | 196 |
197 return net::IsIPAddressReserved(ip_number); | 197 return net::IsIPAddressReserved(ip_number); |
198 } | 198 } |
199 | 199 |
200 void ClientSideDetectionService::OnURLFetchComplete( | 200 void ClientSideDetectionService::OnURLFetchComplete( |
201 const net::URLFetcher* source) { | 201 const net::URLFetcher* source) { |
202 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. | 202 // TODO(vadimt): Remove ScopedTracker below once crbug.com/422577 is fixed. |
203 tracked_objects::ScopedProfile tracking_profile( | 203 tracked_objects::ScopedTracker tracking_profile( |
204 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 204 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
205 "422577 ClientSideDetectionService::OnURLFetchComplete")); | 205 "422577 ClientSideDetectionService::OnURLFetchComplete")); |
206 | 206 |
207 std::string data; | 207 std::string data; |
208 source->GetResponseAsString(&data); | 208 source->GetResponseAsString(&data); |
209 if (source == model_fetcher_.get()) { | 209 if (source == model_fetcher_.get()) { |
210 HandleModelResponse( | 210 HandleModelResponse( |
211 source, source->GetURL(), source->GetStatus(), | 211 source, source->GetURL(), source->GetStatus(), |
212 source->GetResponseCode(), source->GetCookies(), data); | 212 source->GetResponseCode(), source->GetCookies(), data); |
213 } else if (client_phishing_reports_.find(source) != | 213 } else if (client_phishing_reports_.find(source) != |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 GURL ClientSideDetectionService::GetClientReportUrl( | 641 GURL ClientSideDetectionService::GetClientReportUrl( |
642 const std::string& report_url) { | 642 const std::string& report_url) { |
643 GURL url(report_url); | 643 GURL url(report_url); |
644 std::string api_key = google_apis::GetAPIKey(); | 644 std::string api_key = google_apis::GetAPIKey(); |
645 if (!api_key.empty()) | 645 if (!api_key.empty()) |
646 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 646 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
647 | 647 |
648 return url; | 648 return url; |
649 } | 649 } |
650 } // namespace safe_browsing | 650 } // namespace safe_browsing |
OLD | NEW |