| 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 // binaries whose certificate match the whitelist. | 520 // binaries whose certificate match the whitelist. |
| 521 reason = REASON_TRUSTED_EXECUTABLE; | 521 reason = REASON_TRUSTED_EXECUTABLE; |
| 522 } | 522 } |
| 523 if (reason != REASON_MAX) { | 523 if (reason != REASON_MAX) { |
| 524 RecordImprovedProtectionStats(reason); | 524 RecordImprovedProtectionStats(reason); |
| 525 CheckDigestList(); | 525 CheckDigestList(); |
| 526 } else if (!pingback_enabled_) { | 526 } else if (!pingback_enabled_) { |
| 527 RecordImprovedProtectionStats(REASON_PING_DISABLED); | 527 RecordImprovedProtectionStats(REASON_PING_DISABLED); |
| 528 CheckDigestList(); | 528 CheckDigestList(); |
| 529 } else { | 529 } else { |
| 530 // Currently, the UI only works on Windows so we don't even bother |
| 531 // with pinging the server if we're not on Windows. TODO(noelutz): |
| 532 // change this code once the UI is done for Linux and Mac. |
| 533 #if defined(OS_WIN) |
| 530 // The URLFetcher is owned by the UI thread, so post a message to | 534 // The URLFetcher is owned by the UI thread, so post a message to |
| 531 // start the pingback. | 535 // start the pingback. |
| 532 BrowserThread::PostTask( | 536 BrowserThread::PostTask( |
| 533 BrowserThread::UI, | 537 BrowserThread::UI, |
| 534 FROM_HERE, | 538 FROM_HERE, |
| 535 base::Bind(&CheckClientDownloadRequest::SendRequest, this)); | 539 base::Bind(&CheckClientDownloadRequest::SendRequest, this)); |
| 540 #else |
| 541 RecordImprovedProtectionStats(REASON_OS_NOT_SUPPORTED); |
| 542 CheckDigestList(); |
| 543 #endif |
| 536 } | 544 } |
| 537 } | 545 } |
| 538 | 546 |
| 539 void SendRequest() { | 547 void SendRequest() { |
| 540 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 548 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 541 | 549 |
| 542 // This is our last chance to check whether the request has been canceled | 550 // This is our last chance to check whether the request has been canceled |
| 543 // before sending it. | 551 // before sending it. |
| 544 if (!service_) { | 552 if (!service_) { |
| 545 RecordImprovedProtectionStats(REASON_REQUEST_CANCELED); | 553 RecordImprovedProtectionStats(REASON_REQUEST_CANCELED); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 | 706 |
| 699 void DownloadProtectionService::RequestFinished( | 707 void DownloadProtectionService::RequestFinished( |
| 700 CheckClientDownloadRequest* request) { | 708 CheckClientDownloadRequest* request) { |
| 701 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 709 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 702 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = | 710 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = |
| 703 download_requests_.find(request); | 711 download_requests_.find(request); |
| 704 DCHECK(it != download_requests_.end()); | 712 DCHECK(it != download_requests_.end()); |
| 705 download_requests_.erase(*it); | 713 download_requests_.erase(*it); |
| 706 } | 714 } |
| 707 } // namespace safe_browsing | 715 } // namespace safe_browsing |
| OLD | NEW |