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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/metrics/sparse_histogram.h" | 15 #include "base/metrics/sparse_histogram.h" |
16 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
17 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
18 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
23 #include "chrome/common/safe_browsing/client_model.pb.h" | 23 #include "chrome/common/safe_browsing/client_model.pb.h" |
24 #include "chrome/common/safe_browsing/csd.pb.h" | 24 #include "chrome/common/safe_browsing/csd.pb.h" |
25 #include "chrome/common/safe_browsing/safebrowsing_messages.h" | 25 #include "chrome/common/safe_browsing/safebrowsing_messages.h" |
26 #include "components/data_use_measurement/core/data_use_user_data.h" | 26 #include "components/data_use_measurement/core/data_use_user_data.h" |
27 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
| 28 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/notification_types.h" | 31 #include "content/public/browser/notification_types.h" |
31 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
32 #include "crypto/sha2.h" | 33 #include "crypto/sha2.h" |
33 #include "google_apis/google_api_keys.h" | 34 #include "google_apis/google_api_keys.h" |
34 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
35 #include "net/base/ip_address.h" | 36 #include "net/base/ip_address.h" |
36 #include "net/base/load_flags.h" | 37 #include "net/base/load_flags.h" |
37 #include "net/http/http_response_headers.h" | 38 #include "net/http/http_response_headers.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 221 |
221 void ClientSideDetectionService::SendModelToProcess( | 222 void ClientSideDetectionService::SendModelToProcess( |
222 content::RenderProcessHost* process) { | 223 content::RenderProcessHost* process) { |
223 // The ClientSideDetectionService is enabled if _any_ active profile has | 224 // The ClientSideDetectionService is enabled if _any_ active profile has |
224 // SafeBrowsing turned on. Here we check the profile for each renderer | 225 // SafeBrowsing turned on. Here we check the profile for each renderer |
225 // process and only send the model to those that have SafeBrowsing enabled, | 226 // process and only send the model to those that have SafeBrowsing enabled, |
226 // and we select the model based on the extended reporting setting. | 227 // and we select the model based on the extended reporting setting. |
227 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); | 228 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); |
228 std::string model; | 229 std::string model; |
229 if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { | 230 if (profile->GetPrefs()->GetBoolean(prefs::kSafeBrowsingEnabled)) { |
230 if (profile->GetPrefs()->GetBoolean( | 231 if (IsExtendedReportingEnabled(*profile->GetPrefs())) { |
231 prefs::kSafeBrowsingExtendedReportingEnabled)) { | |
232 DVLOG(2) << "Sending phishing model " << model_loader_extended_->name() | 232 DVLOG(2) << "Sending phishing model " << model_loader_extended_->name() |
233 << " to RenderProcessHost @" << process; | 233 << " to RenderProcessHost @" << process; |
234 model = model_loader_extended_->model_str(); | 234 model = model_loader_extended_->model_str(); |
235 } else { | 235 } else { |
236 DVLOG(2) << "Sending phishing model " << model_loader_standard_->name() | 236 DVLOG(2) << "Sending phishing model " << model_loader_standard_->name() |
237 << " to RenderProcessHost @" << process; | 237 << " to RenderProcessHost @" << process; |
238 model = model_loader_standard_->model_str(); | 238 model = model_loader_standard_->model_str(); |
239 } | 239 } |
240 } else { | 240 } else { |
241 DVLOG(2) << "Disabling client-side phishing detection for " | 241 DVLOG(2) << "Disabling client-side phishing detection for " |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 const std::string& report_url) { | 517 const std::string& report_url) { |
518 GURL url(report_url); | 518 GURL url(report_url); |
519 std::string api_key = google_apis::GetAPIKey(); | 519 std::string api_key = google_apis::GetAPIKey(); |
520 if (!api_key.empty()) | 520 if (!api_key.empty()) |
521 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 521 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
522 | 522 |
523 return url; | 523 return url; |
524 } | 524 } |
525 | 525 |
526 } // namespace safe_browsing | 526 } // namespace safe_browsing |
OLD | NEW |