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

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

Issue 166223002: Removes the old download feedback string from the context menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed git screwup Created 6 years, 10 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
« no previous file with comments | « chrome/browser/download/download_shelf_context_menu.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "chrome/browser/download/download_prefs.h" 11 #include "chrome/browser/download/download_prefs.h"
12 #include "chrome/browser/safe_browsing/download_feedback_service.h"
13 #include "chrome/browser/safe_browsing/download_protection_service.h" 12 #include "chrome/browser/safe_browsing/download_protection_service.h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 13 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
16 #include "content/public/browser/download_item.h" 15 #include "content/public/browser/download_item.h"
17 #include "content/public/browser/download_manager.h" 16 #include "content/public/browser/download_manager.h"
18 #include "content/public/browser/page_navigator.h" 17 #include "content/public/browser/page_navigator.h"
19 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
20 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
21 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // filename. Don't base an "Always open" decision based on it. Also 86 // filename. Don't base an "Always open" decision based on it. Also
88 // exclude extensions. 87 // exclude extensions.
89 return download_item_->CanOpenDownload() && 88 return download_item_->CanOpenDownload() &&
90 !download_crx_util::IsExtensionDownload(*download_item_); 89 !download_crx_util::IsExtensionDownload(*download_item_);
91 case CANCEL: 90 case CANCEL:
92 return !download_item_->IsDone(); 91 return !download_item_->IsDone();
93 case TOGGLE_PAUSE: 92 case TOGGLE_PAUSE:
94 return !download_item_->IsDone(); 93 return !download_item_->IsDone();
95 case DISCARD: 94 case DISCARD:
96 case KEEP: 95 case KEEP:
97 case REPORT:
98 case LEARN_MORE_SCANNING: 96 case LEARN_MORE_SCANNING:
99 case LEARN_MORE_INTERRUPTED: 97 case LEARN_MORE_INTERRUPTED:
100 return true; 98 return true;
101 } 99 }
102 return false; 100 return false;
103 } 101 }
104 102
105 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const { 103 bool DownloadShelfContextMenu::IsCommandIdChecked(int command_id) const {
106 if (!download_item_) 104 if (!download_item_)
107 return false; 105 return false;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 } else { 150 } else {
153 download_item_->Resume(); 151 download_item_->Resume();
154 } 152 }
155 break; 153 break;
156 case DISCARD: 154 case DISCARD:
157 download_item_->Remove(); 155 download_item_->Remove();
158 break; 156 break;
159 case KEEP: 157 case KEEP:
160 download_item_->ValidateDangerousDownload(); 158 download_item_->ValidateDangerousDownload();
161 break; 159 break;
162 case REPORT: {
163 #if defined(FULL_SAFE_BROWSING)
164 using safe_browsing::DownloadProtectionService;
165 DownloadItemModel download_model(download_item_);
166 if (!download_model.ShouldAllowDownloadFeedback())
167 break;
168 SafeBrowsingService* sb_service =
169 g_browser_process->safe_browsing_service();
170 DownloadProtectionService* protection_service =
171 (sb_service ? sb_service->download_protection_service() : NULL);
172 if (protection_service) {
173 protection_service->feedback_service()->BeginFeedbackForDownload(
174 download_item_);
175 }
176 #else
177 // Should only be getting invoked if we are using safe browsing.
178 NOTREACHED();
179 #endif
180 break;
181 }
182 case LEARN_MORE_SCANNING: { 160 case LEARN_MORE_SCANNING: {
183 #if defined(FULL_SAFE_BROWSING) 161 #if defined(FULL_SAFE_BROWSING)
184 using safe_browsing::DownloadProtectionService; 162 using safe_browsing::DownloadProtectionService;
185 SafeBrowsingService* sb_service = 163 SafeBrowsingService* sb_service =
186 g_browser_process->safe_browsing_service(); 164 g_browser_process->safe_browsing_service();
187 DownloadProtectionService* protection_service = 165 DownloadProtectionService* protection_service =
188 (sb_service ? sb_service->download_protection_service() : NULL); 166 (sb_service ? sb_service->download_protection_service() : NULL);
189 if (protection_service) { 167 if (protection_service) {
190 protection_service->ShowDetailsForDownload(*download_item_, navigator_); 168 protection_service->ShowDetailsForDownload(*download_item_, navigator_);
191 } 169 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 case CANCEL: 209 case CANCEL:
232 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL); 210 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_CANCEL);
233 case TOGGLE_PAUSE: 211 case TOGGLE_PAUSE:
234 if (download_item_ && 212 if (download_item_ &&
235 download_item_->GetState() == DownloadItem::IN_PROGRESS && 213 download_item_->GetState() == DownloadItem::IN_PROGRESS &&
236 !download_item_->IsPaused()) 214 !download_item_->IsPaused())
237 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM); 215 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_PAUSE_ITEM);
238 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM); 216 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_RESUME_ITEM);
239 case DISCARD: 217 case DISCARD:
240 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_DISCARD); 218 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_DISCARD);
241 case REPORT:
242 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_REPORT);
243 case KEEP: 219 case KEEP:
244 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_KEEP); 220 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_KEEP);
245 case LEARN_MORE_SCANNING: 221 case LEARN_MORE_SCANNING:
246 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING); 222 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING);
247 case LEARN_MORE_INTERRUPTED: 223 case LEARN_MORE_INTERRUPTED:
248 return l10n_util::GetStringUTF16( 224 return l10n_util::GetStringUTF16(
249 IDS_DOWNLOAD_MENU_LEARN_MORE_INTERRUPTED); 225 IDS_DOWNLOAD_MENU_LEARN_MORE_INTERRUPTED);
250 } 226 }
251 NOTREACHED(); 227 NOTREACHED();
252 return base::string16(); 228 return base::string16();
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 334 }
359 335
360 ui::SimpleMenuModel* 336 ui::SimpleMenuModel*
361 DownloadShelfContextMenu::GetMaliciousMenuModel() { 337 DownloadShelfContextMenu::GetMaliciousMenuModel() {
362 if (malicious_download_menu_model_) 338 if (malicious_download_menu_model_)
363 return malicious_download_menu_model_.get(); 339 return malicious_download_menu_model_.get();
364 340
365 malicious_download_menu_model_.reset(new ui::SimpleMenuModel(this)); 341 malicious_download_menu_model_.reset(new ui::SimpleMenuModel(this));
366 342
367 DownloadItemModel download_model(download_item_); 343 DownloadItemModel download_model(download_item_);
368 if (download_model.ShouldAllowDownloadFeedback()) {
369 malicious_download_menu_model_->AddItemWithStringId(
370 REPORT, IDS_DOWNLOAD_MENU_REPORT);
371 }
372 malicious_download_menu_model_->AddItemWithStringId( 344 malicious_download_menu_model_->AddItemWithStringId(
373 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING); 345 LEARN_MORE_SCANNING, IDS_DOWNLOAD_MENU_LEARN_MORE_SCANNING);
374 346
375 return malicious_download_menu_model_.get(); 347 return malicious_download_menu_model_.get();
376 } 348 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_shelf_context_menu.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698