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

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

Issue 55063002: Prefer opening PDF downloads in the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Destroy PluginService once we are done with our plugin tests. Created 7 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 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 "base/command_line.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/download/download_crx_util.h" 9 #include "chrome/browser/download/download_crx_util.h"
10 #include "chrome/browser/download/download_item_model.h" 10 #include "chrome/browser/download/download_item_model.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const { 74 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
75 if (!download_item_) 75 if (!download_item_)
76 return false; 76 return false;
77 77
78 switch (static_cast<ContextMenuCommands>(command_id)) { 78 switch (static_cast<ContextMenuCommands>(command_id)) {
79 case SHOW_IN_FOLDER: 79 case SHOW_IN_FOLDER:
80 return download_item_->CanShowInFolder(); 80 return download_item_->CanShowInFolder();
81 case OPEN_WHEN_COMPLETE: 81 case OPEN_WHEN_COMPLETE:
82 case PLATFORM_OPEN:
82 return download_item_->CanOpenDownload() && 83 return download_item_->CanOpenDownload() &&
83 !download_crx_util::IsExtensionDownload(*download_item_); 84 !download_crx_util::IsExtensionDownload(*download_item_);
84 case ALWAYS_OPEN_TYPE: 85 case ALWAYS_OPEN_TYPE:
85 // For temporary downloads, the target filename might be a temporary 86 // For temporary downloads, the target filename might be a temporary
86 // filename. Don't base an "Always open" decision based on it. Also 87 // filename. Don't base an "Always open" decision based on it. Also
87 // exclude extensions. 88 // exclude extensions.
88 return download_item_->CanOpenDownload() && 89 return download_item_->CanOpenDownload() &&
89 !download_crx_util::IsExtensionDownload(*download_item_); 90 !download_crx_util::IsExtensionDownload(*download_item_);
90 case CANCEL: 91 case CANCEL:
91 return !download_item_->IsDone(); 92 return !download_item_->IsDone();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 case ALWAYS_OPEN_TYPE: { 132 case ALWAYS_OPEN_TYPE: {
132 DownloadPrefs* prefs = DownloadPrefs::FromBrowserContext( 133 DownloadPrefs* prefs = DownloadPrefs::FromBrowserContext(
133 download_item_->GetBrowserContext()); 134 download_item_->GetBrowserContext());
134 base::FilePath path = download_item_->GetTargetFilePath(); 135 base::FilePath path = download_item_->GetTargetFilePath();
135 if (!IsCommandIdChecked(ALWAYS_OPEN_TYPE)) 136 if (!IsCommandIdChecked(ALWAYS_OPEN_TYPE))
136 prefs->EnableAutoOpenBasedOnExtension(path); 137 prefs->EnableAutoOpenBasedOnExtension(path);
137 else 138 else
138 prefs->DisableAutoOpenBasedOnExtension(path); 139 prefs->DisableAutoOpenBasedOnExtension(path);
139 break; 140 break;
140 } 141 }
142 case PLATFORM_OPEN:
143 DownloadItemModel(download_item_).OpenUsingPlatformHandler();
144 break;
141 case CANCEL: 145 case CANCEL:
142 download_item_->Cancel(true /* Cancelled by user */); 146 download_item_->Cancel(true /* Cancelled by user */);
143 break; 147 break;
144 case TOGGLE_PAUSE: 148 case TOGGLE_PAUSE:
145 if (download_item_->GetState() == DownloadItem::IN_PROGRESS && 149 if (download_item_->GetState() == DownloadItem::IN_PROGRESS &&
146 !download_item_->IsPaused()) { 150 !download_item_->IsPaused()) {
147 download_item_->Pause(); 151 download_item_->Pause();
148 } else { 152 } else {
149 download_item_->Resume(); 153 download_item_->Resume();
150 } 154 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const { 218 string16 DownloadShelfContextMenu::GetLabelForCommandId(int command_id) const {
215 switch (static_cast<ContextMenuCommands>(command_id)) { 219 switch (static_cast<ContextMenuCommands>(command_id)) {
216 case SHOW_IN_FOLDER: 220 case SHOW_IN_FOLDER:
217 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_SHOW); 221 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_SHOW);
218 case OPEN_WHEN_COMPLETE: 222 case OPEN_WHEN_COMPLETE:
219 if (download_item_ && !download_item_->IsDone()) 223 if (download_item_ && !download_item_->IsDone())
220 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE); 224 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN_WHEN_COMPLETE);
221 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN); 225 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_OPEN);
222 case ALWAYS_OPEN_TYPE: 226 case ALWAYS_OPEN_TYPE:
223 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE); 227 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
228 case PLATFORM_OPEN:
229 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PLATFORM_OPEN);
224 case CANCEL: 230 case CANCEL:
225 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL); 231 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL);
226 case TOGGLE_PAUSE: 232 case TOGGLE_PAUSE:
227 if (download_item_ && 233 if (download_item_ &&
228 download_item_->GetState() == DownloadItem::IN_PROGRESS && 234 download_item_->GetState() == DownloadItem::IN_PROGRESS &&
229 !download_item_->IsPaused()) 235 !download_item_->IsPaused())
230 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM); 236 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM);
231 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM); 237 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM);
232 case DISCARD: 238 case DISCARD:
233 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_DISCARD); 239 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_DISCARD);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 ui::SimpleMenuModel* DownloadShelfContextMenu::GetFinishedMenuModel() { 289 ui::SimpleMenuModel* DownloadShelfContextMenu::GetFinishedMenuModel() {
284 if (finished_download_menu_model_) 290 if (finished_download_menu_model_)
285 return finished_download_menu_model_.get(); 291 return finished_download_menu_model_.get();
286 292
287 finished_download_menu_model_.reset(new ui::SimpleMenuModel(this)); 293 finished_download_menu_model_.reset(new ui::SimpleMenuModel(this));
288 294
289 finished_download_menu_model_->AddItemWithStringId( 295 finished_download_menu_model_->AddItemWithStringId(
290 OPEN_WHEN_COMPLETE, IDS_DOWNLOAD_MENU_OPEN); 296 OPEN_WHEN_COMPLETE, IDS_DOWNLOAD_MENU_OPEN);
291 finished_download_menu_model_->AddCheckItemWithStringId( 297 finished_download_menu_model_->AddCheckItemWithStringId(
292 ALWAYS_OPEN_TYPE, IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE); 298 ALWAYS_OPEN_TYPE, IDS_DOWNLOAD_MENU_ALWAYS_OPEN_TYPE);
299 if (DownloadItemModel(download_item_).ShouldPreferOpeningInBrowser())
300 finished_download_menu_model_->AddItemWithStringId(
301 PLATFORM_OPEN, IDS_DOWNLOAD_MENU_PLATFORM_OPEN);
293 finished_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); 302 finished_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
294 finished_download_menu_model_->AddItemWithStringId( 303 finished_download_menu_model_->AddItemWithStringId(
295 SHOW_IN_FOLDER, IDS_DOWNLOAD_MENU_SHOW); 304 SHOW_IN_FOLDER, IDS_DOWNLOAD_MENU_SHOW);
296 finished_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); 305 finished_download_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
297 finished_download_menu_model_->AddItemWithStringId( 306 finished_download_menu_model_->AddItemWithStringId(
298 CANCEL, IDS_DOWNLOAD_MENU_CANCEL); 307 CANCEL, IDS_DOWNLOAD_MENU_CANCEL);
299 308
300 return finished_download_menu_model_.get(); 309 return finished_download_menu_model_.get();
301 } 310 }
302 311
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 DownloadItemModel download_model(download_item_); 368 DownloadItemModel download_model(download_item_);
360 if (download_model.ShouldAllowDownloadFeedback()) { 369 if (download_model.ShouldAllowDownloadFeedback()) {
361 malicious_download_menu_model_->AddItemWithStringId( 370 malicious_download_menu_model_->AddItemWithStringId(
362 REPORT, IDS_DOWNLOAD_MENU_REPORT); 371 REPORT, IDS_DOWNLOAD_MENU_REPORT);
363 } 372 }
364 malicious_download_menu_model_->AddItemWithStringId( 373 malicious_download_menu_model_->AddItemWithStringId(
365 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING); 374 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING);
366 375
367 return malicious_download_menu_model_.get(); 376 return malicious_download_menu_model_.get();
368 } 377 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_shelf_context_menu.h ('k') | chrome/browser/download/download_stats.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698