Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5129)

Unified Diff: chrome/browser/download/download_shelf_context_menu.cc

Issue 8757007: Implement additional UI changes for dangerous download warnings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: " Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/download/download_shelf_context_menu.cc
diff --git a/chrome/browser/download/download_shelf_context_menu.cc b/chrome/browser/download/download_shelf_context_menu.cc
index 33be97bde5a2c16ffb56d0943df35447826e05b1..65807aac74660da78946e2a31bf953712e5ecd7b 100644
--- a/chrome/browser/download/download_shelf_context_menu.cc
+++ b/chrome/browser/download/download_shelf_context_menu.cc
@@ -6,9 +6,13 @@
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_prefs.h"
+#include "chrome/browser/google/google_util.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/extensions/extension.h"
+#include "chrome/common/url_constants.h"
#include "content/browser/download/download_item.h"
#include "content/browser/download/download_manager.h"
+#include "content/browser/tab_contents/page_navigator.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -21,8 +25,22 @@ DownloadShelfContextMenu::DownloadShelfContextMenu(
}
ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() {
- return download_item_->IsComplete() ? GetFinishedMenuModel()
- : GetInProgressMenuModel();
+ ui::SimpleMenuModel* model = NULL;
+
+ if (download_item_->GetSafetyState() == DownloadItem::DANGEROUS) {
+ if (download_item_->GetDangerType() == DownloadStateInfo::DANGEROUS_URL ||
+ download_item_->GetDangerType() ==
+ DownloadStateInfo::DANGEROUS_CONTENT) {
+ model = GetMaliciousMenuModel();
+ } else {
+ NOTREACHED();
+ }
+ } else if (download_item_->IsComplete()) {
+ model = GetFinishedMenuModel();
+ } else {
+ model = GetInProgressMenuModel();
+ }
+ return model;
}
bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
@@ -82,6 +100,22 @@ void DownloadShelfContextMenu::ExecuteCommand(int command_id) {
if (download_item_->IsPartialDownload())
download_item_->TogglePause();
break;
+ case DISCARD:
+ download_item_->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
+ break;
+ case KEEP:
+ download_item_->DangerousDownloadValidated();
+ break;
+ case LEARN_MORE: {
+ Browser* browser = BrowserList::GetLastActive();
+ DCHECK(browser && browser->is_type_tabbed());
+ GURL learn_more_url(chrome::kDownloadScanningLearnMoreURL);
+ OpenURLParams params(google_util::AppendGoogleLocaleParam(learn_more_url),
+ GURL(), NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_TYPED, false);
+ browser->OpenURL(params);
+ break;
+ }
default:
NOTREACHED();
}
@@ -113,6 +147,12 @@ string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const {
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM);
return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM);
}
+ case DISCARD:
+ return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_DISCARD);
+ case KEEP:
+ return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_KEEP);
+ case LEARN_MORE:
+ return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_LEARN_MORE);
default:
NOTREACHED();
break;
@@ -161,3 +201,20 @@ ui::SimpleMenuModel* DownloadShelfContextMenu::GetFinishedMenuModel() {
return finished_download_menu_model_.get();
}
+
+ui::SimpleMenuModel* DownloadShelfContextMenu::GetMaliciousMenuModel() {
+ if (malicious_download_menu_model_.get())
+ return malicious_download_menu_model_.get();
+
+ malicious_download_menu_model_.reset(new ui::SimpleMenuModel(this));
+
+ malicious_download_menu_model_->AddItemWithStringId(
+ DISCARD, IDS_DOWNLOAD_MENU_DISCARD);
+ malicious_download_menu_model_->AddItemWithStringId(
+ KEEP, IDS_DOWNLOAD_MENU_KEEP);
+ malicious_download_menu_model_->AddSeparator();
+ malicious_download_menu_model_->AddItemWithStringId(
+ LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE);
+
+ return malicious_download_menu_model_.get();
+}
« no previous file with comments | « chrome/browser/download/download_shelf_context_menu.h ('k') | chrome/browser/ui/views/download/download_item_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698