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/download/chrome_download_manager_delegate.h" | 5 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 if (!item || (item->GetState() != DownloadItem::IN_PROGRESS)) | 518 if (!item || (item->GetState() != DownloadItem::IN_PROGRESS)) |
519 return; | 519 return; |
520 | 520 |
521 VLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false) | 521 VLOG(2) << __FUNCTION__ << "() download = " << item->DebugString(false) |
522 << " verdict = " << result; | 522 << " verdict = " << result; |
523 // We only mark the content as being dangerous if the download's safety state | 523 // We only mark the content as being dangerous if the download's safety state |
524 // has not been set to DANGEROUS yet. We don't want to show two warnings. | 524 // has not been set to DANGEROUS yet. We don't want to show two warnings. |
525 if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || | 525 if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || |
526 item->GetDangerType() == | 526 item->GetDangerType() == |
527 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT) { | 527 content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT) { |
| 528 content::DownloadDangerType danger_type = |
| 529 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; |
528 switch (result) { | 530 switch (result) { |
529 case DownloadProtectionService::SAFE: | 531 case DownloadProtectionService::SAFE: |
530 // Do nothing. | 532 // Do nothing. |
531 break; | 533 break; |
532 case DownloadProtectionService::DANGEROUS: | 534 case DownloadProtectionService::DANGEROUS: |
533 item->OnContentCheckCompleted( | 535 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; |
534 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT); | |
535 break; | 536 break; |
536 case DownloadProtectionService::UNCOMMON: | 537 case DownloadProtectionService::UNCOMMON: |
537 item->OnContentCheckCompleted( | 538 danger_type = content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; |
538 content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); | |
539 break; | 539 break; |
540 case DownloadProtectionService::DANGEROUS_HOST: | 540 case DownloadProtectionService::DANGEROUS_HOST: |
541 item->OnContentCheckCompleted( | 541 danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; |
542 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST); | 542 break; |
| 543 case DownloadProtectionService::POTENTIALLY_UNWANTED: |
| 544 danger_type = content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; |
543 break; | 545 break; |
544 } | 546 } |
| 547 |
| 548 if (danger_type != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) |
| 549 item->OnContentCheckCompleted(danger_type); |
545 } | 550 } |
546 | 551 |
547 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( | 552 SafeBrowsingState* state = static_cast<SafeBrowsingState*>( |
548 item->GetUserData(&safe_browsing_id)); | 553 item->GetUserData(&safe_browsing_id)); |
549 state->SetVerdict(result); | 554 state->SetVerdict(result); |
550 } | 555 } |
551 | 556 |
552 // content::NotificationObserver implementation. | 557 // content::NotificationObserver implementation. |
553 void ChromeDownloadManagerDelegate::Observe( | 558 void ChromeDownloadManagerDelegate::Observe( |
554 int type, | 559 int type, |
555 const content::NotificationSource& source, | 560 const content::NotificationSource& source, |
556 const content::NotificationDetails& details) { | 561 const content::NotificationDetails& details) { |
557 DCHECK(type == chrome::NOTIFICATION_CRX_INSTALLER_DONE); | 562 DCHECK(type == chrome::NOTIFICATION_CRX_INSTALLER_DONE); |
558 | 563 |
559 registrar_.Remove(this, | 564 registrar_.Remove(this, |
560 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 565 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
561 source); | 566 source); |
562 | 567 |
563 scoped_refptr<extensions::CrxInstaller> installer = | 568 scoped_refptr<extensions::CrxInstaller> installer = |
564 content::Source<extensions::CrxInstaller>(source).ptr(); | 569 content::Source<extensions::CrxInstaller>(source).ptr(); |
565 content::DownloadOpenDelayedCallback callback = | 570 content::DownloadOpenDelayedCallback callback = |
566 crx_installers_[installer.get()]; | 571 crx_installers_[installer.get()]; |
567 crx_installers_.erase(installer.get()); | 572 crx_installers_.erase(installer.get()); |
568 callback.Run(installer->did_handle_successfully()); | 573 callback.Run(installer->did_handle_successfully()); |
569 } | 574 } |
OLD | NEW |