| 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/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/metrics/sparse_histogram.h" | 14 #include "base/metrics/sparse_histogram.h" |
| 15 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.h" |
| 16 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
| 20 #include "base/task/cancelable_task_tracker.h" | 20 #include "base/task/cancelable_task_tracker.h" |
| 21 #include "base/threading/sequenced_worker_pool.h" | 21 #include "base/threading/sequenced_worker_pool.h" |
| 22 #include "base/time/time.h" | 22 #include "base/time/time.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/history/history_service.h" | 24 #include "chrome/browser/history/history_service.h" |
| 25 #include "chrome/browser/history/history_service_factory.h" | 25 #include "chrome/browser/history/history_service_factory.h" |
| 26 #include "chrome/browser/profiles/profile.h" |
| 26 #include "chrome/browser/safe_browsing/binary_feature_extractor.h" | 27 #include "chrome/browser/safe_browsing/binary_feature_extractor.h" |
| 27 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 28 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
| 28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 29 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 29 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" | 30 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" |
| 30 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
| 32 #include "chrome/common/safe_browsing/csd.pb.h" | 33 #include "chrome/common/safe_browsing/csd.pb.h" |
| 33 #include "chrome/common/safe_browsing/download_protection_util.h" | 34 #include "chrome/common/safe_browsing/download_protection_util.h" |
| 34 #include "chrome/common/safe_browsing/zip_analyzer.h" | 35 #include "chrome/common/safe_browsing/zip_analyzer.h" |
| 35 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 670 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 670 if (!service_) | 671 if (!service_) |
| 671 return; | 672 return; |
| 672 | 673 |
| 673 if (!tab_url_.is_valid()) { | 674 if (!tab_url_.is_valid()) { |
| 674 SendRequest(); | 675 SendRequest(); |
| 675 return; | 676 return; |
| 676 } | 677 } |
| 677 | 678 |
| 678 Profile* profile = Profile::FromBrowserContext(item_->GetBrowserContext()); | 679 Profile* profile = Profile::FromBrowserContext(item_->GetBrowserContext()); |
| 679 HistoryService* history = | 680 HistoryService* history = HistoryServiceFactory::GetForProfile( |
| 680 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); | 681 profile, ServiceAccessType::EXPLICIT_ACCESS); |
| 681 if (!history) { | 682 if (!history) { |
| 682 SendRequest(); | 683 SendRequest(); |
| 683 return; | 684 return; |
| 684 } | 685 } |
| 685 | 686 |
| 686 history->QueryRedirectsTo( | 687 history->QueryRedirectsTo( |
| 687 tab_url_, | 688 tab_url_, |
| 688 base::Bind(&CheckClientDownloadRequest::OnGotTabRedirects, | 689 base::Bind(&CheckClientDownloadRequest::OnGotTabRedirects, |
| 689 base::Unretained(this), | 690 base::Unretained(this), |
| 690 tab_url_), | 691 tab_url_), |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1128 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1129 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1129 GURL url(kDownloadRequestUrl); | 1130 GURL url(kDownloadRequestUrl); |
| 1130 std::string api_key = google_apis::GetAPIKey(); | 1131 std::string api_key = google_apis::GetAPIKey(); |
| 1131 if (!api_key.empty()) | 1132 if (!api_key.empty()) |
| 1132 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1133 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1133 | 1134 |
| 1134 return url; | 1135 return url; |
| 1135 } | 1136 } |
| 1136 | 1137 |
| 1137 } // namespace safe_browsing | 1138 } // namespace safe_browsing |
| OLD | NEW |