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

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

Issue 11673003: UI changes associated with downloads resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged from DownloadsResumption; includes CanResumeDownload, which was nuked in the original CL. Created 7 years, 11 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 "base/command_line.h"
7 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/download_crx_util.h" 9 #include "chrome/browser/download/download_crx_util.h"
9 #include "chrome/browser/download/download_item_model.h" 10 #include "chrome/browser/download/download_item_model.h"
10 #include "chrome/browser/download/download_prefs.h" 11 #include "chrome/browser/download/download_prefs.h"
11 #include "chrome/browser/safe_browsing/download_protection_service.h" 12 #include "chrome/browser/safe_browsing/download_protection_service.h"
12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
14 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
15 #include "content/public/browser/download_item.h" 17 #include "content/public/browser/download_item.h"
16 #include "content/public/browser/download_manager.h" 18 #include "content/public/browser/download_manager.h"
17 #include "content/public/browser/page_navigator.h" 19 #include "content/public/browser/page_navigator.h"
18 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
20 22
21 using content::DownloadItem; 23 using content::DownloadItem;
22 using extensions::Extension; 24 using extensions::Extension;
(...skipping 19 matching lines...) Expand all
42 else if (download_item_->IsComplete()) 44 else if (download_item_->IsComplete())
43 model = GetFinishedMenuModel(); 45 model = GetFinishedMenuModel();
44 else if (download_item_->IsInterrupted()) 46 else if (download_item_->IsInterrupted())
45 model = GetInterruptedMenuModel(); 47 model = GetInterruptedMenuModel();
46 else 48 else
47 model = GetInProgressMenuModel(); 49 model = GetInProgressMenuModel();
48 return model; 50 return model;
49 } 51 }
50 52
51 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const { 53 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
54 static bool restart_enabled = CommandLine::ForCurrentProcess()->HasSwitch(
55 switches::kEnableDownloadResumption);
52 switch (static_cast<ContextMenuCommands>(command_id)) { 56 switch (static_cast<ContextMenuCommands>(command_id)) {
53 case SHOW_IN_FOLDER: 57 case SHOW_IN_FOLDER:
54 return download_item_->CanShowInFolder(); 58 return download_item_->CanShowInFolder();
55 case OPEN_WHEN_COMPLETE: 59 case OPEN_WHEN_COMPLETE:
56 return download_item_->CanOpenDownload() && 60 return download_item_->CanOpenDownload() &&
57 !download_crx_util::IsExtensionDownload(*download_item_); 61 !download_crx_util::IsExtensionDownload(*download_item_);
58 case ALWAYS_OPEN_TYPE: 62 case ALWAYS_OPEN_TYPE:
59 // For temporary downloads, the target filename might be a temporary 63 // For temporary downloads, the target filename might be a temporary
60 // filename. Don't base an "Always open" decision based on it. Also 64 // filename. Don't base an "Always open" decision based on it. Also
61 // exclude extensions. 65 // exclude extensions.
62 return download_item_->CanOpenDownload() && 66 return download_item_->CanOpenDownload() &&
63 !download_crx_util::IsExtensionDownload(*download_item_); 67 !download_crx_util::IsExtensionDownload(*download_item_);
64 case CANCEL: 68 case CANCEL:
65 return download_item_->IsPartialDownload(); 69 return download_item_->IsPartialDownload();
66 case TOGGLE_PAUSE: 70 case TOGGLE_PAUSE:
67 return download_item_->IsInProgress(); 71 return restart_enabled && download_item_->CanResumeDownload();
68 case DISCARD: 72 case DISCARD:
69 case KEEP: 73 case KEEP:
70 case LEARN_MORE_SCANNING: 74 case LEARN_MORE_SCANNING:
71 case LEARN_MORE_INTERRUPTED: 75 case LEARN_MORE_INTERRUPTED:
72 return true; 76 return true;
73 } 77 }
74 return false; 78 return false;
75 } 79 }
76 80
77 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const { 81 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_SHOW); 170 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_SHOW);
167 case OPEN_WHEN_COMPLETE: 171 case OPEN_WHEN_COMPLETE:
168 if (download_item_->IsInProgress()) 172 if (download_item_->IsInProgress())
169 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE); 173 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE);
170 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN); 174 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN);
171 case ALWAYS_OPEN_TYPE: 175 case ALWAYS_OPEN_TYPE:
172 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE); 176 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
173 case CANCEL: 177 case CANCEL:
174 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL); 178 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL);
175 case TOGGLE_PAUSE: { 179 case TOGGLE_PAUSE: {
176 if (download_item_->IsPaused()) 180 if (download_item_->IsPaused() ||
181 download_item_->CanResumeInterrupted()) {
177 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM); 182 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM);
183 }
178 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM); 184 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM);
179 } 185 }
180 case DISCARD: 186 case DISCARD:
181 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_DISCARD); 187 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_DISCARD);
182 case KEEP: 188 case KEEP:
183 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_KEEP); 189 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_KEEP);
184 case LEARN_MORE_SCANNING: 190 case LEARN_MORE_SCANNING:
185 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING); 191 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING);
186 case LEARN_MORE_INTERRUPTED: 192 case LEARN_MORE_INTERRUPTED:
187 return l10n_util::GetStringUTF16( 193 return l10n_util::GetStringUTF16(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 malicious_download_menu_model_->AddItemWithStringId( 267 malicious_download_menu_model_->AddItemWithStringId(
262 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); 268 DISCARD, IDS_DOWNLOAD_MENU_DISCARD);
263 malicious_download_menu_model_->AddItemWithStringId( 269 malicious_download_menu_model_->AddItemWithStringId(
264 KEEP, IDS_DOWNLOAD_MENU_KEEP); 270 KEEP, IDS_DOWNLOAD_MENU_KEEP);
265 malicious_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); 271 malicious_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
266 malicious_download_menu_model_->AddItemWithStringId( 272 malicious_download_menu_model_->AddItemWithStringId(
267 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING); 273 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING);
268 274
269 return malicious_download_menu_model_.get(); 275 return malicious_download_menu_model_.get();
270 } 276 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model_unittest.cc ('k') | chrome/browser/resources/downloads/downloads.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698