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/safe_browsing/download_protection_service.h" | 11 #include "chrome/browser/safe_browsing/download_protection_service.h" |
12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 12 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/extensions/extension_switch_utils.h" | 14 #include "chrome/common/extensions/extension_switch_utils.h" |
15 #include "content/public/browser/download_item.h" | 15 #include "content/public/browser/download_item.h" |
16 #include "content/public/browser/download_manager.h" | 16 #include "content/public/browser/download_manager.h" |
| 17 #include "content/public/browser/page_navigator.h" |
17 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
18 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
19 | 20 |
20 using content::DownloadItem; | 21 using content::DownloadItem; |
21 using extensions::Extension; | 22 using extensions::Extension; |
22 | 23 |
23 DownloadShelfContextMenu::~DownloadShelfContextMenu() {} | 24 DownloadShelfContextMenu::~DownloadShelfContextMenu() {} |
24 | 25 |
25 DownloadShelfContextMenu::DownloadShelfContextMenu( | 26 DownloadShelfContextMenu::DownloadShelfContextMenu( |
26 BaseDownloadItemModel* download_model) | 27 BaseDownloadItemModel* download_model, |
| 28 content::PageNavigator* navigator) |
27 : download_model_(download_model), | 29 : download_model_(download_model), |
28 download_item_(download_model->download()) { | 30 download_item_(download_model->download()), |
| 31 navigator_(navigator) { |
29 } | 32 } |
30 | 33 |
31 ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() { | 34 ui::SimpleMenuModel* DownloadShelfContextMenu::GetMenuModel() { |
32 ui::SimpleMenuModel* model = NULL; | 35 ui::SimpleMenuModel* model = NULL; |
33 // We shouldn't be opening a context menu for a dangerous download, unless it | 36 // We shouldn't be opening a context menu for a dangerous download, unless it |
34 // is a malicious download. | 37 // is a malicious download. |
35 DCHECK(!download_model_->IsDangerous() || download_model_->IsMalicious()); | 38 DCHECK(!download_model_->IsDangerous() || download_model_->IsMalicious()); |
36 | 39 |
37 if (download_model_->IsMalicious()) | 40 if (download_model_->IsMalicious()) |
38 model = GetMaliciousMenuModel(); | 41 model = GetMaliciousMenuModel(); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 case LEARN_MORE: { | 121 case LEARN_MORE: { |
119 #if defined(ENABLE_SAFE_BROWSING) | 122 #if defined(ENABLE_SAFE_BROWSING) |
120 using safe_browsing::DownloadProtectionService; | 123 using safe_browsing::DownloadProtectionService; |
121 SafeBrowsingService* sb_service = | 124 SafeBrowsingService* sb_service = |
122 g_browser_process->safe_browsing_service(); | 125 g_browser_process->safe_browsing_service(); |
123 DownloadProtectionService* protection_service = | 126 DownloadProtectionService* protection_service = |
124 (sb_service ? sb_service->download_protection_service() : NULL); | 127 (sb_service ? sb_service->download_protection_service() : NULL); |
125 if (protection_service) { | 128 if (protection_service) { |
126 protection_service->ShowDetailsForDownload( | 129 protection_service->ShowDetailsForDownload( |
127 DownloadProtectionService::DownloadInfo::FromDownloadItem( | 130 DownloadProtectionService::DownloadInfo::FromDownloadItem( |
128 *download_item_)); | 131 *download_item_), |
| 132 navigator_); |
129 } | 133 } |
130 #else | 134 #else |
131 // Should only be getting invoked if we are using safe browsing. | 135 // Should only be getting invoked if we are using safe browsing. |
132 NOTREACHED(); | 136 NOTREACHED(); |
133 #endif | 137 #endif |
134 break; | 138 break; |
135 } | 139 } |
136 default: | 140 default: |
137 NOTREACHED(); | 141 NOTREACHED(); |
138 } | 142 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 malicious_download_menu_model_->AddItemWithStringId( | 232 malicious_download_menu_model_->AddItemWithStringId( |
229 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); | 233 DISCARD, IDS_DOWNLOAD_MENU_DISCARD); |
230 malicious_download_menu_model_->AddItemWithStringId( | 234 malicious_download_menu_model_->AddItemWithStringId( |
231 KEEP, IDS_DOWNLOAD_MENU_KEEP); | 235 KEEP, IDS_DOWNLOAD_MENU_KEEP); |
232 malicious_download_menu_model_->AddSeparator(); | 236 malicious_download_menu_model_->AddSeparator(); |
233 malicious_download_menu_model_->AddItemWithStringId( | 237 malicious_download_menu_model_->AddItemWithStringId( |
234 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); | 238 LEARN_MORE, IDS_DOWNLOAD_MENU_LEARN_MORE); |
235 | 239 |
236 return malicious_download_menu_model_.get(); | 240 return malicious_download_menu_model_.get(); |
237 } | 241 } |
OLD | NEW |