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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 // TODO(thakis): Make this prettier, by fading the items out or overlaying | 238 // TODO(thakis): Make this prettier, by fading the items out or overlaying |
239 // the partial visible one with a horizontal alpha gradient -- crbug.com/17830 | 239 // the partial visible one with a horizontal alpha gradient -- crbug.com/17830 |
240 NSView* view = [self view]; | 240 NSView* view = [self view]; |
241 NSRect containerFrame = [[view superview] frame]; | 241 NSRect containerFrame = [[view superview] frame]; |
242 [view setHidden:(NSMaxX([view frame]) > NSWidth(containerFrame))]; | 242 [view setHidden:(NSMaxX([view frame]) > NSWidth(containerFrame))]; |
243 } | 243 } |
244 | 244 |
245 - (IBAction)handleButtonClick:(id)sender { | 245 - (IBAction)handleButtonClick:(id)sender { |
246 DownloadItem* download = bridge_->download_model()->download(); | 246 DownloadItem* download = bridge_->download_model()->download(); |
247 if (download->state() == DownloadItem::IN_PROGRESS) | 247 download->OpenDownload(); |
248 download->set_open_when_complete(!download->open_when_complete()); | |
249 else if (download->state() == DownloadItem::COMPLETE) | |
250 download_util::OpenDownload(download); | |
251 } | 248 } |
252 | 249 |
253 - (NSSize)preferredSize { | 250 - (NSSize)preferredSize { |
254 if (state_ == kNormal) | 251 if (state_ == kNormal) |
255 return [progressView_ frame].size; | 252 return [progressView_ frame].size; |
256 DCHECK_EQ(kDangerous, state_); | 253 DCHECK_EQ(kDangerous, state_); |
257 return [dangerousDownloadView_ frame].size; | 254 return [dangerousDownloadView_ frame].size; |
258 } | 255 } |
259 | 256 |
260 - (DownloadItem*)download { | 257 - (DownloadItem*)download { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, true); | 308 themeProvider->GetNSColor(BrowserThemeProvider::COLOR_TAB_TEXT, true); |
312 [dangerousDownloadLabel_ setTextColor:color]; | 309 [dangerousDownloadLabel_ setTextColor:color]; |
313 } | 310 } |
314 | 311 |
315 - (IBAction)saveDownload:(id)sender { | 312 - (IBAction)saveDownload:(id)sender { |
316 // The user has confirmed a dangerous download. We record how quickly the | 313 // The user has confirmed a dangerous download. We record how quickly the |
317 // user did this to detect whether we're being clickjacked. | 314 // user did this to detect whether we're being clickjacked. |
318 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", | 315 UMA_HISTOGRAM_LONG_TIMES("clickjacking.save_download", |
319 base::Time::Now() - creationTime_); | 316 base::Time::Now() - creationTime_); |
320 // This will change the state and notify us. | 317 // This will change the state and notify us. |
321 bridge_->download_model()->download()->manager()->DangerousDownloadValidated( | 318 bridge_->download_model()->download()->DangerousDownloadValidated(); |
322 bridge_->download_model()->download()); | |
323 } | 319 } |
324 | 320 |
325 - (IBAction)discardDownload:(id)sender { | 321 - (IBAction)discardDownload:(id)sender { |
326 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", | 322 UMA_HISTOGRAM_LONG_TIMES("clickjacking.discard_download", |
327 base::Time::Now() - creationTime_); | 323 base::Time::Now() - creationTime_); |
328 if (bridge_->download_model()->download()->state() == | 324 if (bridge_->download_model()->download()->state() == |
329 DownloadItem::IN_PROGRESS) | 325 DownloadItem::IN_PROGRESS) |
330 bridge_->download_model()->download()->Cancel(true); | 326 bridge_->download_model()->download()->Cancel(true); |
331 bridge_->download_model()->download()->Remove(true); | 327 bridge_->download_model()->download()->Remove(true); |
332 // WARNING: we are deleted at this point. Don't access 'this'. | 328 // WARNING: we are deleted at this point. Don't access 'this'. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 [sender setTitle:l10n_util::GetNSStringWithFixup( | 382 [sender setTitle:l10n_util::GetNSStringWithFixup( |
387 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; | 383 IDS_DOWNLOAD_MENU_PAUSE_ITEM)]; |
388 } else { | 384 } else { |
389 [sender setTitle:l10n_util::GetNSStringWithFixup( | 385 [sender setTitle:l10n_util::GetNSStringWithFixup( |
390 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; | 386 IDS_DOWNLOAD_MENU_RESUME_ITEM)]; |
391 } | 387 } |
392 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); | 388 menuBridge_->ExecuteCommand(DownloadShelfContextMenuMac::TOGGLE_PAUSE); |
393 } | 389 } |
394 | 390 |
395 @end | 391 @end |
OLD | NEW |