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