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

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

Issue 16007017: [Resumption 10/12] Use DI::IsDone to check for terminal downloads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with r204343 Created 7 years, 6 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/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/download/download_crx_util.h" 8 #include "chrome/browser/download/download_crx_util.h"
9 #include "chrome/browser/download/download_item_model.h" 9 #include "chrome/browser/download/download_item_model.h"
10 #include "chrome/browser/download/download_prefs.h" 10 #include "chrome/browser/download/download_prefs.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 case OPEN_WHEN_COMPLETE: 66 case OPEN_WHEN_COMPLETE:
67 return download_item_->CanOpenDownload() && 67 return download_item_->CanOpenDownload() &&
68 !download_crx_util::IsExtensionDownload(*download_item_); 68 !download_crx_util::IsExtensionDownload(*download_item_);
69 case ALWAYS_OPEN_TYPE: 69 case ALWAYS_OPEN_TYPE:
70 // For temporary downloads, the target filename might be a temporary 70 // For temporary downloads, the target filename might be a temporary
71 // filename. Don't base an "Always open" decision based on it. Also 71 // filename. Don't base an "Always open" decision based on it. Also
72 // exclude extensions. 72 // exclude extensions.
73 return download_item_->CanOpenDownload() && 73 return download_item_->CanOpenDownload() &&
74 !download_crx_util::IsExtensionDownload(*download_item_); 74 !download_crx_util::IsExtensionDownload(*download_item_);
75 case CANCEL: 75 case CANCEL:
76 return download_item_->IsPartialDownload(); 76 return !download_item_->IsDone();
77 case TOGGLE_PAUSE: 77 case TOGGLE_PAUSE:
78 return download_item_->GetState() == DownloadItem::IN_PROGRESS; 78 return download_item_->GetState() == DownloadItem::IN_PROGRESS;
79 case DISCARD: 79 case DISCARD:
80 case KEEP: 80 case KEEP:
81 case LEARN_MORE_SCANNING: 81 case LEARN_MORE_SCANNING:
82 case LEARN_MORE_INTERRUPTED: 82 case LEARN_MORE_INTERRUPTED:
83 return true; 83 return true;
84 } 84 }
85 return false; 85 return false;
86 } 86 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 prefs->DisableAutoOpenBasedOnExtension(path); 122 prefs->DisableAutoOpenBasedOnExtension(path);
123 break; 123 break;
124 } 124 }
125 case CANCEL: 125 case CANCEL:
126 download_item_->Cancel(true /* Cancelled by user */); 126 download_item_->Cancel(true /* Cancelled by user */);
127 break; 127 break;
128 case TOGGLE_PAUSE: 128 case TOGGLE_PAUSE:
129 // It is possible for the download to complete before the user clicks the 129 // It is possible for the download to complete before the user clicks the
130 // menu item, recheck if the download is in progress state before toggling 130 // menu item, recheck if the download is in progress state before toggling
131 // pause. 131 // pause.
132 if (download_item_->IsPartialDownload()) { 132 if (download_item_->GetState() == DownloadItem::IN_PROGRESS) {
133 if (download_item_->IsPaused()) 133 if (download_item_->IsPaused())
134 download_item_->Resume(); 134 download_item_->Resume();
135 else 135 else
136 download_item_->Pause(); 136 download_item_->Pause();
137 } 137 }
138 break; 138 break;
139 case DISCARD: 139 case DISCARD:
140 download_item_->Remove(); 140 download_item_->Remove();
141 break; 141 break;
142 case KEEP: 142 case KEEP:
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 bool DownloadShelfContextMenu::IsItemForCommandIdDynamic(int command_id) const { 177 bool DownloadShelfContextMenu::IsItemForCommandIdDynamic(int command_id) const {
178 return command_id == TOGGLE_PAUSE; 178 return command_id == TOGGLE_PAUSE;
179 } 179 }
180 180
181 string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const { 181 string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const {
182 switch (static_cast<ContextMenuCommands>(command_id)) { 182 switch (static_cast<ContextMenuCommands>(command_id)) {
183 case SHOW_IN_FOLDER: 183 case SHOW_IN_FOLDER:
184 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_SHOW); 184 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_SHOW);
185 case OPEN_WHEN_COMPLETE: 185 case OPEN_WHEN_COMPLETE:
186 if (download_item_ && 186 if (download_item_ && !download_item_->IsDone())
187 download_item_->GetState() == DownloadItem::IN_PROGRESS)
188 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE); 187 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE);
189 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN); 188 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN);
190 case ALWAYS_OPEN_TYPE: 189 case ALWAYS_OPEN_TYPE:
191 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE); 190 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
192 case CANCEL: 191 case CANCEL:
193 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL); 192 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL);
194 case TOGGLE_PAUSE: 193 case TOGGLE_PAUSE:
195 if (download_item_ && download_item_->IsPaused()) 194 if (download_item_ && download_item_->IsPaused())
196 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM); 195 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM);
197 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM); 196 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 malicious_download_menu_model_->AddItemWithStringId( 291 malicious_download_menu_model_->AddItemWithStringId(
293 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); 292 DISCARD, IDS_DOWNLOAD_MENU_DISCARD);
294 malicious_download_menu_model_->AddItemWithStringId( 293 malicious_download_menu_model_->AddItemWithStringId(
295 KEEP, IDS_DOWNLOAD_MENU_KEEP); 294 KEEP, IDS_DOWNLOAD_MENU_KEEP);
296 malicious_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); 295 malicious_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
297 malicious_download_menu_model_->AddItemWithStringId( 296 malicious_download_menu_model_->AddItemWithStringId(
298 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING); 297 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING);
299 298
300 return malicious_download_menu_model_.get(); 299 return malicious_download_menu_model_.get();
301 } 300 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_danger_prompt_browsertest.cc ('k') | chrome/browser/ui/webui/downloads_dom_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698