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

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

Issue 10452009: Improve the UI for disabling off-store extension install. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed comments, fixed tests Created 8 years, 7 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 } 47 }
48 48
49 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const { 49 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const {
50 switch (command_id) { 50 switch (command_id) {
51 case SHOW_IN_FOLDER: 51 case SHOW_IN_FOLDER:
52 return download_item_->CanShowInFolder() && 52 return download_item_->CanShowInFolder() &&
53 !download_item_->IsTemporary(); 53 !download_item_->IsTemporary();
54 case OPEN_WHEN_COMPLETE: 54 case OPEN_WHEN_COMPLETE:
55 return download_item_->CanShowInFolder() && 55 return download_item_->CanShowInFolder() &&
56 !download_item_->IsTemporary() && 56 !download_item_->IsTemporary() &&
57 (!Extension::IsExtension(download_item_->GetTargetName()) || 57 (!download_crx_util::IsExtensionDownload(*download_item_) ||
58 extensions::switch_utils::IsOffStoreInstallEnabled()); 58 download_item_->IsComplete());
59 case ALWAYS_OPEN_TYPE: 59 case ALWAYS_OPEN_TYPE:
60 // For temporary downloads, the target filename might be a temporary 60 // For temporary downloads, the target filename might be a temporary
61 // filename. Don't base an "Always open" decision based on it. Also 61 // filename. Don't base an "Always open" decision based on it. Also
62 // exclude extensions. 62 // exclude extensions.
63 return download_item_->CanOpenDownload() && 63 return download_item_->CanOpenDownload() &&
64 !Extension::IsExtension(download_item_->GetTargetName()) && 64 !download_crx_util::IsExtensionDownload(*download_item_) &&
65 !download_item_->IsTemporary(); 65 !download_item_->IsTemporary();
66 case CANCEL: 66 case CANCEL:
67 return download_item_->IsPartialDownload(); 67 return download_item_->IsPartialDownload();
68 case TOGGLE_PAUSE: 68 case TOGGLE_PAUSE:
69 return download_item_->IsInProgress(); 69 return download_item_->IsInProgress();
70 default: 70 default:
71 return command_id > 0 && command_id < MENU_LAST; 71 return command_id > 0 && command_id < MENU_LAST;
72 } 72 }
73 } 73 }
74 74
75 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const { 75 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const {
76 switch (command_id) { 76 switch (command_id) {
77 case OPEN_WHEN_COMPLETE: 77 case OPEN_WHEN_COMPLETE:
78 return download_item_->GetOpenWhenComplete(); 78 return download_item_->GetOpenWhenComplete() ||
79 download_crx_util::IsExtensionDownload(*download_item_);
79 case ALWAYS_OPEN_TYPE: 80 case ALWAYS_OPEN_TYPE:
80 return download_item_->ShouldOpenFileBasedOnExtension(); 81 return download_item_->ShouldOpenFileBasedOnExtension();
81 case TOGGLE_PAUSE: 82 case TOGGLE_PAUSE:
82 return download_item_->IsPaused(); 83 return download_item_->IsPaused();
83 } 84 }
84 return false; 85 return false;
85 } 86 }
86 87
87 void DownloadShelfContextMenu::ExecuteCommand(int command_id) { 88 void DownloadShelfContextMenu::ExecuteCommand(int command_id) {
88 switch (command_id) { 89 switch (command_id) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 malicious_download_menu_model_->AddItemWithStringId( 233 malicious_download_menu_model_->AddItemWithStringId(
233 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); 234 DISCARD, IDS_DOWNLOAD_MENU_DISCARD);
234 malicious_download_menu_model_->AddItemWithStringId( 235 malicious_download_menu_model_->AddItemWithStringId(
235 KEEP, IDS_DOWNLOAD_MENU_KEEP); 236 KEEP, IDS_DOWNLOAD_MENU_KEEP);
236 malicious_download_menu_model_->AddSeparator(); 237 malicious_download_menu_model_->AddSeparator();
237 malicious_download_menu_model_->AddItemWithStringId( 238 malicious_download_menu_model_->AddItemWithStringId(
238 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); 239 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE);
239 240
240 return malicious_download_menu_model_.get(); 241 return malicious_download_menu_model_.get();
241 } 242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698