OLD | NEW |
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" |
| 11 #include "chrome/browser/profiles/profile.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" |
13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
14 #include "content/public/browser/download_item.h" | 15 #include "content/public/browser/download_item.h" |
15 #include "content/public/browser/download_manager.h" | 16 #include "content/public/browser/download_manager.h" |
16 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 | 19 |
19 using content::DownloadItem; | 20 using content::DownloadItem; |
20 | 21 |
(...skipping 18 matching lines...) Expand all Loading... |
39 else | 40 else |
40 model = GetInProgressMenuModel(); | 41 model = GetInProgressMenuModel(); |
41 return model; | 42 return model; |
42 } | 43 } |
43 | 44 |
44 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const { | 45 bool DownloadShelfContextMenu::IsCommandIdEnabled(int command_id) const { |
45 switch (command_id) { | 46 switch (command_id) { |
46 case SHOW_IN_FOLDER: | 47 case SHOW_IN_FOLDER: |
47 return download_item_->CanShowInFolder() && | 48 return download_item_->CanShowInFolder() && |
48 !download_item_->IsTemporary(); | 49 !download_item_->IsTemporary(); |
49 case OPEN_WHEN_COMPLETE: | 50 case OPEN_WHEN_COMPLETE: { |
| 51 Profile* profile = |
| 52 Profile::FromBrowserContext(download_item_->GetBrowserContext()); |
50 return download_item_->CanShowInFolder() && | 53 return download_item_->CanShowInFolder() && |
51 !download_item_->IsTemporary() && | 54 !download_item_->IsTemporary() && |
52 (!Extension::IsExtension(download_item_->GetTargetName()) || | 55 (!Extension::IsExtension(download_item_->GetTargetName()) || |
53 download_crx_util::ShouldOpenExtensionDownload(*download_item_)); | 56 download_crx_util::ShouldOpenExtensionDownload( |
| 57 profile->GetExtensionService(), *download_item_)); |
| 58 } |
54 case ALWAYS_OPEN_TYPE: | 59 case ALWAYS_OPEN_TYPE: |
55 // For temporary downloads, the target filename might be a temporary | 60 // For temporary downloads, the target filename might be a temporary |
56 // 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 |
57 // exclude extensions. | 62 // exclude extensions. |
58 return download_item_->CanOpenDownload() && | 63 return download_item_->CanOpenDownload() && |
59 !Extension::IsExtension(download_item_->GetTargetName()) && | 64 !Extension::IsExtension(download_item_->GetTargetName()) && |
60 !download_item_->IsTemporary(); | 65 !download_item_->IsTemporary(); |
61 case CANCEL: | 66 case CANCEL: |
62 return download_item_->IsPartialDownload(); | 67 return download_item_->IsPartialDownload(); |
63 case TOGGLE_PAUSE: | 68 case TOGGLE_PAUSE: |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 malicious_download_menu_model_->AddItemWithStringId( | 231 malicious_download_menu_model_->AddItemWithStringId( |
227 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); | 232 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); |
228 malicious_download_menu_model_->AddItemWithStringId( | 233 malicious_download_menu_model_->AddItemWithStringId( |
229 KEEP, IDS_DOWNLOAD_MENU_KEEP); | 234 KEEP, IDS_DOWNLOAD_MENU_KEEP); |
230 malicious_download_menu_model_->AddSeparator(); | 235 malicious_download_menu_model_->AddSeparator(); |
231 malicious_download_menu_model_->AddItemWithStringId( | 236 malicious_download_menu_model_->AddItemWithStringId( |
232 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); | 237 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); |
233 | 238 |
234 return malicious_download_menu_model_.get(); | 239 return malicious_download_menu_model_.get(); |
235 } | 240 } |
OLD | NEW |