| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 352 // TODO(noelutz): implement some cache to make sure we don't issue the same | 352 // TODO(noelutz): implement some cache to make sure we don't issue the same |
| 353 // request over and over again if a user downloads the same binary multiple | 353 // request over and over again if a user downloads the same binary multiple |
| 354 // times. | 354 // times. |
| 355 if (info_.download_url_chain.empty()) { | 355 if (info_.download_url_chain.empty()) { |
| 356 RecordImprovedProtectionStats(REASON_EMPTY_URL_CHAIN); | 356 RecordImprovedProtectionStats(REASON_EMPTY_URL_CHAIN); |
| 357 PostFinishTask(SAFE); | 357 PostFinishTask(SAFE); |
| 358 return; | 358 return; |
| 359 } | 359 } |
| 360 const GURL& final_url = info_.download_url_chain.back(); | 360 const GURL& final_url = info_.download_url_chain.back(); |
| 361 if (!final_url.is_valid() || final_url.is_empty()) { | 361 if (!final_url.is_valid() || final_url.is_empty() || |
| 362 !final_url.IsStandard() || final_url.SchemeIsFile()) { |
| 362 RecordImprovedProtectionStats(REASON_INVALID_URL); | 363 RecordImprovedProtectionStats(REASON_INVALID_URL); |
| 363 PostFinishTask(SAFE); | 364 PostFinishTask(SAFE); |
| 364 return; | 365 return; |
| 365 } | 366 } |
| 366 RecordFileExtensionType(info_.target_file); | 367 RecordFileExtensionType(info_.target_file); |
| 367 | 368 |
| 368 if (final_url.SchemeIs("https") || !IsBinaryFile(info_.target_file)) { | 369 if (final_url.SchemeIs("https") || !IsBinaryFile(info_.target_file)) { |
| 369 RecordImprovedProtectionStats(final_url.SchemeIs("https") ? | 370 RecordImprovedProtectionStats(final_url.SchemeIs("https") ? |
| 370 REASON_HTTPS_URL : REASON_NOT_BINARY_FILE); | 371 REASON_HTTPS_URL : REASON_NOT_BINARY_FILE); |
| 371 BrowserThread::PostTask( | 372 BrowserThread::PostTask( |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 | 694 |
| 694 void DownloadProtectionService::RequestFinished( | 695 void DownloadProtectionService::RequestFinished( |
| 695 CheckClientDownloadRequest* request) { | 696 CheckClientDownloadRequest* request) { |
| 696 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 697 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = | 698 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = |
| 698 download_requests_.find(request); | 699 download_requests_.find(request); |
| 699 DCHECK(it != download_requests_.end()); | 700 DCHECK(it != download_requests_.end()); |
| 700 download_requests_.erase(*it); | 701 download_requests_.erase(*it); |
| 701 } | 702 } |
| 702 } // namespace safe_browsing | 703 } // namespace safe_browsing |
| OLD | NEW |