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/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
22 #include "base/threading/thread_restrictions.h" | 22 #include "base/threading/thread_restrictions.h" |
23 #include "base/threading/worker_pool.h" | 23 #include "base/threading/worker_pool.h" |
24 #include "base/trace_event/trace_event.h" | 24 #include "base/trace_event/trace_event.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
28 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h" | |
29 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/profiles/profile_manager.h" | 29 #include "chrome/browser/profiles/profile_manager.h" |
31 #include "chrome/browser/safe_browsing/ping_manager.h" | 30 #include "chrome/browser/safe_browsing/ping_manager.h" |
32 #include "chrome/browser/safe_browsing/ui_manager.h" | 31 #include "chrome/browser/safe_browsing/ui_manager.h" |
33 #include "chrome/common/chrome_constants.h" | 32 #include "chrome/common/chrome_constants.h" |
34 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
35 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
36 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
37 #include "chrome/common/safe_browsing/file_type_policies.h" | 36 #include "chrome/common/safe_browsing/file_type_policies.h" |
38 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 base::Bind(&SafeBrowsingURLRequestContextGetter::ServiceShuttingDown, | 354 base::Bind(&SafeBrowsingURLRequestContextGetter::ServiceShuttingDown, |
356 url_request_context_getter_)); | 355 url_request_context_getter_)); |
357 | 356 |
358 // Release the URLRequestContextGetter after passing it to the IOThread. It | 357 // Release the URLRequestContextGetter after passing it to the IOThread. It |
359 // has to be released now rather than in the destructor because it can only | 358 // has to be released now rather than in the destructor because it can only |
360 // be deleted on the IOThread, and the SafeBrowsingService outlives the IO | 359 // be deleted on the IOThread, and the SafeBrowsingService outlives the IO |
361 // thread. | 360 // thread. |
362 url_request_context_getter_ = nullptr; | 361 url_request_context_getter_ = nullptr; |
363 } | 362 } |
364 | 363 |
365 // Binhash verification is only enabled for UMA users for now. | |
366 bool SafeBrowsingService::DownloadBinHashNeeded() const { | 364 bool SafeBrowsingService::DownloadBinHashNeeded() const { |
367 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 365 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
368 | 366 |
369 #if defined(FULL_SAFE_BROWSING) | 367 #if defined(FULL_SAFE_BROWSING) |
370 return (database_manager_->IsDownloadProtectionEnabled() && | 368 return database_manager_->IsDownloadProtectionEnabled() || |
371 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled()) || | |
372 (download_protection_service() && | 369 (download_protection_service() && |
373 download_protection_service()->enabled()); | 370 download_protection_service()->enabled()); |
374 #else | 371 #else |
375 return false; | 372 return false; |
376 #endif | 373 #endif |
377 } | 374 } |
378 | 375 |
379 net::URLRequestContextGetter* SafeBrowsingService::url_request_context() { | 376 net::URLRequestContextGetter* SafeBrowsingService::url_request_context() { |
380 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 377 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
381 return url_request_context_getter_.get(); | 378 return url_request_context_getter_.get(); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 ping_manager()->ReportThreatDetails(report); | 695 ping_manager()->ReportThreatDetails(report); |
699 } | 696 } |
700 | 697 |
701 void SafeBrowsingService::ProcessResourceRequest( | 698 void SafeBrowsingService::ProcessResourceRequest( |
702 const ResourceRequestInfo& request) { | 699 const ResourceRequestInfo& request) { |
703 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 700 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
704 services_delegate_->ProcessResourceRequest(&request); | 701 services_delegate_->ProcessResourceRequest(&request); |
705 } | 702 } |
706 | 703 |
707 } // namespace safe_browsing | 704 } // namespace safe_browsing |
OLD | NEW |