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

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: derp 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 return model; 46 return model;
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();
asanka 2012/05/25 18:28:18 The confusingly named OPEN_WHEN_COMPLETE option me
57 (!Extension::IsExtension(download_item_->GetTargetName()) ||
58 extensions::switch_utils::IsOffStoreInstallEnabled());
59 case ALWAYS_OPEN_TYPE: 57 case ALWAYS_OPEN_TYPE:
60 // For temporary downloads, the target filename might be a temporary 58 // For temporary downloads, the target filename might be a temporary
61 // filename. Don't base an "Always open" decision based on it. Also 59 // filename. Don't base an "Always open" decision based on it. Also
62 // exclude extensions. 60 // exclude extensions.
63 return download_item_->CanOpenDownload() && 61 return download_item_->CanOpenDownload() &&
64 !Extension::IsExtension(download_item_->GetTargetName()) && 62 !download_crx_util::IsExtensionDownload(*download_item_) &&
65 !download_item_->IsTemporary(); 63 !download_item_->IsTemporary();
66 case CANCEL: 64 case CANCEL:
67 return download_item_->IsPartialDownload(); 65 return download_item_->IsPartialDownload();
68 case TOGGLE_PAUSE: 66 case TOGGLE_PAUSE:
69 return download_item_->IsInProgress(); 67 return download_item_->IsInProgress();
70 default: 68 default:
71 return command_id > 0 && command_id < MENU_LAST; 69 return command_id > 0 && command_id < MENU_LAST;
72 } 70 }
73 } 71 }
74 72
75 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const { 73 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const {
76 switch (command_id) { 74 switch (command_id) {
77 case OPEN_WHEN_COMPLETE: 75 case OPEN_WHEN_COMPLETE:
78 return download_item_->GetOpenWhenComplete(); 76 return download_item_->GetOpenWhenComplete();
asanka 2012/05/25 18:28:18 This should ideally also return true for extension
79 case ALWAYS_OPEN_TYPE: 77 case ALWAYS_OPEN_TYPE:
80 return download_item_->ShouldOpenFileBasedOnExtension(); 78 return download_item_->ShouldOpenFileBasedOnExtension();
81 case TOGGLE_PAUSE: 79 case TOGGLE_PAUSE:
82 return download_item_->IsPaused(); 80 return download_item_->IsPaused();
83 } 81 }
84 return false; 82 return false;
85 } 83 }
86 84
87 void DownloadShelfContextMenu::ExecuteCommand(int command_id) { 85 void DownloadShelfContextMenu::ExecuteCommand(int command_id) {
88 switch (command_id) { 86 switch (command_id) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 malicious_download_menu_model_->AddItemWithStringId( 230 malicious_download_menu_model_->AddItemWithStringId(
233 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); 231 DISCARD, IDS_DOWNLOAD_MENU_DISCARD);
234 malicious_download_menu_model_->AddItemWithStringId( 232 malicious_download_menu_model_->AddItemWithStringId(
235 KEEP, IDS_DOWNLOAD_MENU_KEEP); 233 KEEP, IDS_DOWNLOAD_MENU_KEEP);
236 malicious_download_menu_model_->AddSeparator(); 234 malicious_download_menu_model_->AddSeparator();
237 malicious_download_menu_model_->AddItemWithStringId( 235 malicious_download_menu_model_->AddItemWithStringId(
238 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); 236 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE);
239 237
240 return malicious_download_menu_model_.get(); 238 return malicious_download_menu_model_.get();
241 } 239 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/extensions/crx_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698