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

Side by Side Diff: chrome/browser/download/download_shelf_context_menu.cc

Issue 9569011: Refactor dangerous download warning text generation into DownloadItemModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update copyright headers Created 8 years, 9 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/download_shelf_context_menu.h" 5 #include "chrome/browser/download/download_shelf_context_menu.h"
6 6
7 #include "chrome/browser/download/download_item_model.h" 7 #include "chrome/browser/download/download_item_model.h"
8 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/browser/ui/browser_list.h" 9 #include "chrome/browser/ui/browser_list.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 10 matching lines...) Expand all
21 DownloadShelfContextMenu::~DownloadShelfContextMenu() {} 21 DownloadShelfContextMenu::~DownloadShelfContextMenu() {}
22 22
23 DownloadShelfContextMenu::DownloadShelfContextMenu( 23 DownloadShelfContextMenu::DownloadShelfContextMenu(
24 BaseDownloadItemModel* download_model) 24 BaseDownloadItemModel* download_model)
25 : download_model_(download_model), 25 : download_model_(download_model),
26 download_item_(download_model->download()) { 26 download_item_(download_model->download()) {
27 } 27 }
28 28
29 ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() { 29 ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() {
30 ui::SimpleMenuModel* model = NULL; 30 ui::SimpleMenuModel* model = NULL;
31 // We shouldn't be opening a context menu for a dangerous download, unless it
32 // is a malicious download.
33 DCHECK(!download_model_->IsDangerous() || download_model_->IsMalicious());
31 34
32 if (download_item_->GetSafetyState() == DownloadItem::DANGEROUS) { 35 if (download_model_->IsMalicious())
33 if (download_item_->GetDangerType() == 36 model = GetMaliciousMenuModel();
34 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL || 37 else if (download_item_->IsComplete())
35 download_item_->GetDangerType() ==
36 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT) {
37 model = GetMaliciousMenuModel();
38 } else {
39 NOTREACHED();
40 }
41 } else if (download_item_->IsComplete()) {
42 model = GetFinishedMenuModel(); 38 model = GetFinishedMenuModel();
43 } else { 39 else
44 model = GetInProgressMenuModel(); 40 model = GetInProgressMenuModel();
45 }
46 return model; 41 return model;
47 } 42 }
48 43
49 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const { 44 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
50 switch (command_id) { 45 switch (command_id) {
51 case SHOW_IN_FOLDER: 46 case SHOW_IN_FOLDER:
52 case OPEN_WHEN_COMPLETE: 47 case OPEN_WHEN_COMPLETE:
53 return download_item_->CanShowInFolder(); 48 return download_item_->CanShowInFolder();
54 case ALWAYS_OPEN_TYPE: 49 case ALWAYS_OPEN_TYPE:
55 return download_item_->CanOpenDownload() && 50 return download_item_->CanOpenDownload() &&
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 malicious_download_menu_model_->AddItemWithStringId( 208 malicious_download_menu_model_->AddItemWithStringId(
214 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); 209 DISCARD, IDS_DOWNLOAD_MENU_DISCARD);
215 malicious_download_menu_model_->AddItemWithStringId( 210 malicious_download_menu_model_->AddItemWithStringId(
216 KEEP, IDS_DOWNLOAD_MENU_KEEP); 211 KEEP, IDS_DOWNLOAD_MENU_KEEP);
217 malicious_download_menu_model_->AddSeparator(); 212 malicious_download_menu_model_->AddSeparator();
218 malicious_download_menu_model_->AddItemWithStringId( 213 malicious_download_menu_model_->AddItemWithStringId(
219 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); 214 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE);
220 215
221 return malicious_download_menu_model_.get(); 216 return malicious_download_menu_model_.get();
222 } 217 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/ui/cocoa/download/download_item_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698