OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/download_item_controller.h" | 5 #import "chrome/browser/cocoa/download_item_controller.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "app/text_elider.h" | 9 #include "app/text_elider.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // user did this to detect whether we're being clickjacked. | 315 // user did this to detect whether we're being clickjacked. |
316 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", | 316 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", |
317 base::Time::Now() - creationTime_); | 317 base::Time::Now() - creationTime_); |
318 // This will change the state and notify us. | 318 // This will change the state and notify us. |
319 bridge_->download_model()->download()->DangerousDownloadValidated(); | 319 bridge_->download_model()->download()->DangerousDownloadValidated(); |
320 } | 320 } |
321 | 321 |
322 - (IBAction)discardDownload:(id)sender { | 322 - (IBAction)discardDownload:(id)sender { |
323 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 323 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
324 base::Time::Now() - creationTime_); | 324 base::Time::Now() - creationTime_); |
325 if (bridge_->download_model()->download()->state() == | 325 DownloadItem* download = bridge_->download_model()->download(); |
326 DownloadItem::IN_PROGRESS) | 326 if (download->IsPartialDownload()) |
327 bridge_->download_model()->download()->Cancel(true); | 327 download->Cancel(true); |
328 bridge_->download_model()->download()->Remove(true); | 328 download->Remove(true); |
329 // WARNING: we are deleted at this point. Don't access 'this'. | 329 // WARNING: we are deleted at this point. Don't access 'this'. |
330 } | 330 } |
331 | 331 |
332 | 332 |
333 // Sets the enabled and checked state of a particular menu item for this | 333 // Sets the enabled and checked state of a particular menu item for this |
334 // download. We translate the NSMenuItem selection to menu selections understood | 334 // download. We translate the NSMenuItem selection to menu selections understood |
335 // by the non platform specific download context menu. | 335 // by the non platform specific download context menu. |
336 - (BOOL)validateMenuItem:(NSMenuItem *)item { | 336 - (BOOL)validateMenuItem:(NSMenuItem *)item { |
337 SEL action = [item action]; | 337 SEL action = [item action]; |
338 | 338 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 [sender setTitle:l10n_util::GetNSStringWithFixup( | 383 [sender setTitle:l10n_util::GetNSStringWithFixup( |
384 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; | 384 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; |
385 } else { | 385 } else { |
386 [sender setTitle:l10n_util::GetNSStringWithFixup( | 386 [sender setTitle:l10n_util::GetNSStringWithFixup( |
387 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; | 387 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; |
388 } | 388 } |
389 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); | 389 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); |
390 } | 390 } |
391 | 391 |
392 @end | 392 @end |
OLD | NEW |