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

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: Add DCHECKs Created 9 years, 1 month 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..73cca42642271fce1622f0c3dba451dbe6eb7b0e 100644
--- a/chrome/browser/download/download_shelf_context_menu.cc
+++ b/chrome/browser/download/download_shelf_context_menu.cc
@@ -6,9 +6,11 @@
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_prefs.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/extensions/extension.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 +23,17 @@ DownloadShelfContextMenu::DownloadShelfContextMenu(
}
ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() {
- return download_item_->IsComplete() ? GetFinishedMenuModel()
- : GetInProgressMenuModel();
+ ui::SimpleMenuModel* model;
+
+ if (download_item_->GetSafetyState() == DownloadItem::DANGEROUS &&
dmazzoni 2011/12/01 19:49:22 What does it mean if GetSafetyState() == DANGEROUS
asanka 2011/12/02 00:05:04 Done. Went with your 'if' suggestion.
+ (download_item_->GetDangerType() == DownloadStateInfo::DANGEROUS_URL ||
+ download_item_->GetDangerType() == DownloadStateInfo::DANGEROUS_CONTENT))
+ model = GetMaliciousMenuModel();
+ else if (download_item_->IsComplete())
+ model = GetFinishedMenuModel();
+ else
+ model = GetInProgressMenuModel();
+ return model;
}
bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
@@ -82,6 +93,25 @@ void DownloadShelfContextMenu::ExecuteCommand(int command_id) {
if (download_item_->IsPartialDownload())
download_item_->TogglePause();
break;
+ case DISCARD:
+ if (download_item_->IsPartialDownload())
+ download_item_->Cancel(true);
dmazzoni 2011/12/01 19:49:22 Does Cancel take effect immediately, does it close
asanka 2011/12/02 00:05:04 Calling Delete() results in a task posted to the F
+ download_item_->Delete(DownloadItem::DELETE_DUE_TO_USER_DISCARD);
Randy Smith (Not in Mondays) 2011/12/01 19:50:46 Remove (which Delete() calls) does a Cancel unilat
asanka 2011/12/02 00:05:04 Done.
+ // We have been deleted!
dmazzoni 2011/12/01 19:49:22 Get rid of this comment
Randy Smith (Not in Mondays) 2011/12/01 19:50:46 Have you looked over the callers to this routine,
asanka 2011/12/02 00:05:04 Done.
asanka 2011/12/02 00:05:04 Done. In general, any time we run a message loop w
+ break;
+ case KEEP:
+ download_item_->DangerousDownloadValidated();
+ break;
+ case LEARN_MORE: {
+ Browser* browser = BrowserList::GetLastActive();
+ DCHECK(browser && browser->is_type_tabbed());
+ GURL learn_more_url(
+ l10n_util::GetStringUTF8(IDS_DOWNLOAD_SAFE_BROWSING_LEARN_MORE_URL));
+ OpenURLParams params(learn_more_url, GURL(), NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_TYPED, false);
+ browser->OpenURL(params);
+ break;
+ }
default:
NOTREACHED();
}
@@ -113,6 +143,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 +197,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();
+}

Powered by Google App Engine
This is Rietveld 408576698