diff options
Diffstat (limited to 'chrome/browser')
14 files changed, 110 insertions, 34 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 96456e5..316ccc0 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -351,6 +351,9 @@ DictionaryValue* AutomationProvider::GetDictionaryFromDownloadItem( case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: download_danger_type_string = "DANGEROUS_HOST"; break; + case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: + download_danger_type_string = "POTENTIALLY_UNWANTED"; + break; case content::DOWNLOAD_DANGER_TYPE_MAX: NOTREACHED(); download_danger_type_string = "UNKNOWN"; diff --git a/chrome/browser/download/chrome_download_manager_delegate.cc b/chrome/browser/download/chrome_download_manager_delegate.cc index 70e69a8..e1e1f42 100644 --- a/chrome/browser/download/chrome_download_manager_delegate.cc +++ b/chrome/browser/download/chrome_download_manager_delegate.cc @@ -525,23 +525,28 @@ void ChromeDownloadManagerDelegate::CheckClientDownloadDone( if (item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS || item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT) { + content::DownloadDangerType danger_type = + content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS; switch (result) { case DownloadProtectionService::SAFE: // Do nothing. break; case DownloadProtectionService::DANGEROUS: - item->OnContentCheckCompleted( - content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT); + danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT; break; case DownloadProtectionService::UNCOMMON: - item->OnContentCheckCompleted( - content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT); + danger_type = content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT; break; case DownloadProtectionService::DANGEROUS_HOST: - item->OnContentCheckCompleted( - content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST); + danger_type = content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; + break; + case DownloadProtectionService::POTENTIALLY_UNWANTED: + danger_type = content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; break; } + + if (danger_type != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) + item->OnContentCheckCompleted(danger_type); } SafeBrowsingState* state = static_cast<SafeBrowsingState*>( diff --git a/chrome/browser/download/download_danger_prompt.cc b/chrome/browser/download/download_danger_prompt.cc index d75c6cc..95ec322 100644 --- a/chrome/browser/download/download_danger_prompt.cc +++ b/chrome/browser/download/download_danger_prompt.cc @@ -124,10 +124,18 @@ string16 DownloadDangerPromptImpl::GetMessage() { return l10n_util::GetStringFUTF16( IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, download_->GetFileNameToReportUser().LossyDisplayName()); - default: - NOTREACHED(); - return string16(); + case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: + return l10n_util::GetStringFUTF16( + IDS_PROMPT_POTENTIALLY_UNWANTED_DOWNLOAD, + download_->GetFileNameToReportUser().LossyDisplayName()); + case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: + case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: + case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: + case content::DOWNLOAD_DANGER_TYPE_MAX: + break; } + NOTREACHED(); + return string16(); } string16 DownloadDangerPromptImpl::GetAcceptButtonTitle() { diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc index f8dc3db..22c14ff 100644 --- a/chrome/browser/download/download_item_model.cc +++ b/chrome/browser/download/download_item_model.cc @@ -301,6 +301,8 @@ string16 DownloadItemModel::GetWarningText(const gfx::Font& font, int base_width) const { // Should only be called if IsDangerous(). DCHECK(IsDangerous()); + string16 elided_filename = + ui::ElideFilename(download_->GetFileNameToReportUser(), font, base_width); switch (download_->GetDangerType()) { case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: return l10n_util::GetStringUTF16(IDS_PROMPT_MALICIOUS_DOWNLOAD_URL); @@ -310,31 +312,30 @@ string16 DownloadItemModel::GetWarningText(const gfx::Font& font, return l10n_util::GetStringUTF16( IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); } else { - return l10n_util::GetStringFUTF16( - IDS_PROMPT_DANGEROUS_DOWNLOAD, - ui::ElideFilename(download_->GetFileNameToReportUser(), - font, base_width)); + return l10n_util::GetStringFUTF16(IDS_PROMPT_DANGEROUS_DOWNLOAD, + elided_filename); } case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: - return l10n_util::GetStringFUTF16( - IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, - ui::ElideFilename(download_->GetFileNameToReportUser(), - font, base_width)); + return l10n_util::GetStringFUTF16(IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, + elided_filename); case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: + return l10n_util::GetStringFUTF16(IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, + elided_filename); + + case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: return l10n_util::GetStringFUTF16( - IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, - ui::ElideFilename(download_->GetFileNameToReportUser(), - font, base_width)); + IDS_PROMPT_POTENTIALLY_UNWANTED_DOWNLOAD, elided_filename); case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: case content::DOWNLOAD_DANGER_TYPE_MAX: - NOTREACHED(); + break; } + NOTREACHED(); return string16(); } @@ -378,6 +379,7 @@ bool DownloadItemModel::IsMalicious() const { case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: + case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: return true; case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: diff --git a/chrome/browser/extensions/api/downloads/downloads_api.cc b/chrome/browser/extensions/api/downloads/downloads_api.cc index 0ebe8c5..03d6613 100644 --- a/chrome/browser/extensions/api/downloads/downloads_api.cc +++ b/chrome/browser/extensions/api/downloads/downloads_api.cc @@ -106,6 +106,7 @@ const char kDangerFile[] = "file"; const char kDangerKey[] = "danger"; const char kDangerSafe[] = "safe"; const char kDangerUncommon[] = "uncommon"; +const char kDangerUnwanted[] = "unwanted"; const char kDangerAccepted[] = "accepted"; const char kDangerHost[] = "host"; const char kDangerUrl[] = "url"; @@ -146,6 +147,7 @@ const char* kDangerStrings[] = { kDangerUncommon, kDangerAccepted, kDangerHost, + kDangerUnwanted }; COMPILE_ASSERT(arraysize(kDangerStrings) == content::DOWNLOAD_DANGER_TYPE_MAX, download_danger_type_enum_changed); diff --git a/chrome/browser/history/download_database.cc b/chrome/browser/history/download_database.cc index 5a0dc26..6f7865c 100644 --- a/chrome/browser/history/download_database.cc +++ b/chrome/browser/history/download_database.cc @@ -111,6 +111,7 @@ const int DownloadDatabase::kDangerTypeMaybeDangerousContent = 4; const int DownloadDatabase::kDangerTypeUncommonContent = 5; const int DownloadDatabase::kDangerTypeUserValidated = 6; const int DownloadDatabase::kDangerTypeDangerousHost = 7; +const int DownloadDatabase::kDangerTypePotentiallyUnwanted = 8; int DownloadDatabase::StateToInt(DownloadItem::DownloadState state) { switch (state) { @@ -156,6 +157,8 @@ int DownloadDatabase::DangerTypeToInt(content::DownloadDangerType danger_type) { return DownloadDatabase::kDangerTypeUserValidated; case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: return DownloadDatabase::kDangerTypeDangerousHost; + case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: + return DownloadDatabase::kDangerTypePotentiallyUnwanted; case content::DOWNLOAD_DANGER_TYPE_MAX: NOTREACHED(); return DownloadDatabase::kDangerTypeInvalid; @@ -182,6 +185,8 @@ content::DownloadDangerType DownloadDatabase::IntToDangerType(int danger_type) { return content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED; case DownloadDatabase::kDangerTypeDangerousHost: return content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST; + case DownloadDatabase::kDangerTypePotentiallyUnwanted: + return content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED; default: return content::DOWNLOAD_DANGER_TYPE_MAX; } diff --git a/chrome/browser/history/download_database.h b/chrome/browser/history/download_database.h index 1550a0a..12e5a1e 100644 --- a/chrome/browser/history/download_database.h +++ b/chrome/browser/history/download_database.h @@ -94,6 +94,7 @@ class DownloadDatabase { static const int kDangerTypeUncommonContent; static const int kDangerTypeUserValidated; static const int kDangerTypeDangerousHost; + static const int kDangerTypePotentiallyUnwanted; // Fixes state of the download entries. Sometimes entries with IN_PROGRESS // state are not updated during browser shutdown (particularly when crashing). diff --git a/chrome/browser/resources/downloads/downloads.js b/chrome/browser/resources/downloads/downloads.js index 6d5f311..dd9b457 100644 --- a/chrome/browser/resources/downloads/downloads.js +++ b/chrome/browser/resources/downloads/downloads.js @@ -386,7 +386,8 @@ Download.DangerType = { DANGEROUS_URL: 'DANGEROUS_URL', DANGEROUS_CONTENT: 'DANGEROUS_CONTENT', UNCOMMON_CONTENT: 'UNCOMMON_CONTENT', - DANGEROUS_HOST: 'DANGEROUS_HOST' + DANGEROUS_HOST: 'DANGEROUS_HOST', + POTENTIALLY_UNWANTED: 'POTENTIALLY_UNWANTED', }; /** @@ -442,6 +443,9 @@ Download.prototype.update = function(download) { } else if (this.dangerType_ == Download.DangerType.UNCOMMON_CONTENT) { this.dangerDesc_.textContent = loadTimeData.getStringF( 'danger_uncommon_desc', this.fileName_); + } else if (this.dangerType_ == Download.DangerType.POTENTIALLY_UNWANTED) { + this.dangerDesc_.textContent = loadTimeData.getStringF( + 'danger_potentially_unwanted_desc', this.fileName_); } this.danger_.style.display = 'block'; this.safe_.style.display = 'none'; diff --git a/chrome/browser/safe_browsing/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection_service.cc index 2c5f590..62c12fa 100644 --- a/chrome/browser/safe_browsing/download_protection_service.cc +++ b/chrome/browser/safe_browsing/download_protection_service.cc @@ -417,6 +417,10 @@ class DownloadProtectionService::CheckClientDownloadRequest } else if (response.verdict() == ClientDownloadResponse::DANGEROUS_HOST) { reason = REASON_DOWNLOAD_DANGEROUS_HOST; result = DANGEROUS_HOST; + } else if ( + response.verdict() == ClientDownloadResponse::POTENTIALLY_UNWANTED) { + reason = REASON_DOWNLOAD_POTENTIALLY_UNWANTED; + result = POTENTIALLY_UNWANTED; } else { LOG(DFATAL) << "Unknown download response verdict: " << response.verdict(); @@ -864,8 +868,12 @@ void DownloadProtectionService::RequestFinished( void DownloadProtectionService::ShowDetailsForDownload( const content::DownloadItem& item, content::PageNavigator* navigator) { + GURL learn_more_url(chrome::kDownloadScanningLearnMoreURL); + if (item.GetDangerType() == + content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED) + learn_more_url = GURL(chrome::kDownloadPotentiallyUnwantedLearnMoreURL); navigator->OpenURL( - content::OpenURLParams(GURL(chrome::kDownloadScanningLearnMoreURL), + content::OpenURLParams(learn_more_url, content::Referrer(), NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, diff --git a/chrome/browser/safe_browsing/download_protection_service.h b/chrome/browser/safe_browsing/download_protection_service.h index 48ab04a..0b61b6d 100644 --- a/chrome/browser/safe_browsing/download_protection_service.h +++ b/chrome/browser/safe_browsing/download_protection_service.h @@ -45,6 +45,7 @@ class DownloadProtectionService { DANGEROUS, UNCOMMON, DANGEROUS_HOST, + POTENTIALLY_UNWANTED }; // Callback type which is invoked once the download request is done. @@ -130,6 +131,7 @@ class DownloadProtectionService { REASON_INVALID_RESPONSE_VERDICT, REASON_ARCHIVE_WITHOUT_BINARIES, REASON_DOWNLOAD_DANGEROUS_HOST, + REASON_DOWNLOAD_POTENTIALLY_UNWANTED, REASON_MAX // Always add new values before this one. }; diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc index 6d5bfee..91cf222 100644 --- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc +++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc @@ -455,8 +455,8 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { std::string hash = "hash"; content::MockDownloadItem item; - EXPECT_CALL(item, AddObserver(_)).Times(5); - EXPECT_CALL(item, RemoveObserver(_)).Times(5); + EXPECT_CALL(item, AddObserver(_)).Times(6); + EXPECT_CALL(item, RemoveObserver(_)).Times(6); EXPECT_CALL(item, GetFullPath()).WillRepeatedly(ReturnRef(a_tmp)); EXPECT_CALL(item, GetTargetFilePath()).WillRepeatedly(ReturnRef(a_exe)); EXPECT_CALL(item, GetUrlChain()).WillRepeatedly(ReturnRef(url_chain)); @@ -469,7 +469,7 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { EXPECT_CALL(*sb_service_->mock_database_manager(), MatchDownloadWhitelistUrl(_)) .WillRepeatedly(Return(false)); - EXPECT_CALL(*signature_util_.get(), CheckSignature(a_tmp, _)).Times(5); + EXPECT_CALL(*signature_util_.get(), CheckSignature(a_tmp, _)).Times(6); download_service_->CheckClientDownload( &item, @@ -561,6 +561,25 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { #else EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); #endif + + // If the response is POTENTIALLY_UNWANTED the result should also be marked as + // POTENTIALLY_UNWANTED. + response.set_verdict(ClientDownloadResponse::POTENTIALLY_UNWANTED); + factory.SetFakeResponse( + DownloadProtectionService::GetDownloadRequestUrl(), + response.SerializeAsString(), + true); + + download_service_->CheckClientDownload( + &item, + base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, + base::Unretained(this))); + MessageLoop::current()->Run(); +#if defined(OS_WIN) + EXPECT_TRUE(IsResult(DownloadProtectionService::POTENTIALLY_UNWANTED)); +#else + EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); +#endif } TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) { diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc index 11561a0..1294d04 100644 --- a/chrome/browser/ui/views/download/download_item_view.cc +++ b/chrome/browser/ui/views/download/download_item_view.cc @@ -1085,13 +1085,24 @@ void DownloadItemView::ShowWarningDialog() { AddChildView(discard_button_); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - // The dangerous download label text and icon are different under - // different cases. - if (mode_ == MALICIOUS_MODE) { - warning_icon_ = rb.GetImageSkiaNamed(IDR_SAFEBROWSING_WARNING); - } else { - // The download file has dangerous file type (e.g.: an executable). - warning_icon_ = rb.GetImageSkiaNamed(IDR_WARNING); + switch (download()->GetDangerType()) { + case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: + case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: + case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: + case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: + warning_icon_ = rb.GetImageSkiaNamed(IDR_SAFEBROWSING_WARNING); + break; + + case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: + case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: + case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: + case content::DOWNLOAD_DANGER_TYPE_MAX: + NOTREACHED(); + // fallthrough + + case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: + case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: + warning_icon_ = rb.GetImageSkiaNamed(IDR_WARNING); } string16 dangerous_label = model_.GetWarningText(font_, kTextWidth); dangerous_download_label_ = new views::Label(dangerous_label); diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc index 124b278..72245e1 100644 --- a/chrome/browser/ui/webui/downloads_dom_handler.cc +++ b/chrome/browser/ui/webui/downloads_dom_handler.cc @@ -99,6 +99,8 @@ const char* GetDangerTypeString(content::DownloadDangerType danger_type) { return "UNCOMMON_CONTENT"; case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: return "DANGEROUS_HOST"; + case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: + return "POTENTIALLY_UNWANTED"; default: // Don't return a danger type string if it is NOT_DANGEROUS or // MAYBE_DANGEROUS_CONTENT. @@ -161,7 +163,9 @@ DictionaryValue* CreateDownloadItemValue( download_item->GetDangerType() == content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT || download_item->GetDangerType() == - content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST); + content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST || + download_item->GetDangerType() == + content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED); const char* danger_type_value = GetDangerTypeString(download_item->GetDangerType()); file_value->SetString("danger_type", danger_type_value); diff --git a/chrome/browser/ui/webui/downloads_ui.cc b/chrome/browser/ui/webui/downloads_ui.cc index 2eec32b..b90b28c 100644 --- a/chrome/browser/ui/webui/downloads_ui.cc +++ b/chrome/browser/ui/webui/downloads_ui.cc @@ -59,6 +59,8 @@ content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) { IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT); source->AddLocalizedString("danger_uncommon_desc", IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT); + source->AddLocalizedString("danger_potentially_unwanted_desc", + IDS_PROMPT_POTENTIALLY_UNWANTED_DOWNLOAD); source->AddLocalizedString("danger_save", IDS_CONFIRM_DOWNLOAD); source->AddLocalizedString("danger_discard", IDS_DISCARD_DOWNLOAD); |