| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/download/download_shelf_controller.h" | 5 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
| 11 #include "chrome/browser/themes/theme_service_factory.h" | 11 #include "chrome/browser/themes/theme_service_factory.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #import "chrome/browser/ui/cocoa/animatable_view.h" | 13 #import "chrome/browser/ui/cocoa/animatable_view.h" |
| 14 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 14 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 15 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 16 #include "chrome/browser/ui/cocoa/download/download_item_controller.h" | 16 #include "chrome/browser/ui/cocoa/download/download_item_controller.h" |
| 17 #include "chrome/browser/ui/cocoa/download/download_shelf_mac.h" | 17 #include "chrome/browser/ui/cocoa/download/download_shelf_mac.h" |
| 18 #import "chrome/browser/ui/cocoa/download/download_shelf_view.h" | 18 #import "chrome/browser/ui/cocoa/download/download_shelf_view.h" |
| 19 #import "chrome/browser/ui/cocoa/hover_button.h" | 19 #import "chrome/browser/ui/cocoa/hover_button.h" |
| 20 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 20 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
| 21 #include "content/browser/download/download_item.h" | 21 #include "content/browser/download/download_item.h" |
| 22 #include "content/browser/download/download_manager.h" | 22 #include "content/browser/download/download_manager.h" |
| 23 #include "content/browser/download/download_stats.h" |
| 23 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 24 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 25 | 26 |
| 26 // Download shelf autoclose behavior: | 27 // Download shelf autoclose behavior: |
| 27 // | 28 // |
| 28 // The download shelf autocloses if all of this is true: | 29 // The download shelf autocloses if all of this is true: |
| 29 // 1) An item on the shelf has just been opened. | 30 // 1) An item on the shelf has just been opened. |
| 30 // 2) All remaining items on the shelf have been opened in the past. | 31 // 2) All remaining items on the shelf have been opened in the past. |
| 31 // 3) The mouse leaves the shelf and remains off the shelf for 5 seconds. | 32 // 3) The mouse leaves the shelf and remains off the shelf for 5 seconds. |
| 32 // | 33 // |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return barIsVisible_; | 234 return barIsVisible_; |
| 234 } | 235 } |
| 235 | 236 |
| 236 - (void)show:(id)sender { | 237 - (void)show:(id)sender { |
| 237 [self showDownloadShelf:YES]; | 238 [self showDownloadShelf:YES]; |
| 238 } | 239 } |
| 239 | 240 |
| 240 - (void)hide:(id)sender { | 241 - (void)hide:(id)sender { |
| 241 [self cancelAutoCloseAndRemoveTrackingArea]; | 242 [self cancelAutoCloseAndRemoveTrackingArea]; |
| 242 | 243 |
| 244 download_stats::RecordShelfSize([downloadItemControllers_ count]); |
| 245 |
| 243 // If |sender| isn't nil, then we're being closed from the UI by the user and | 246 // If |sender| isn't nil, then we're being closed from the UI by the user and |
| 244 // we need to tell our shelf implementation to close. Otherwise, we're being | 247 // we need to tell our shelf implementation to close. Otherwise, we're being |
| 245 // closed programmatically by our shelf implementation. | 248 // closed programmatically by our shelf implementation. |
| 246 if (sender) | 249 if (sender) |
| 247 bridge_->Close(); | 250 bridge_->Close(); |
| 248 else | 251 else |
| 249 [self showDownloadShelf:NO]; | 252 [self showDownloadShelf:NO]; |
| 250 } | 253 } |
| 251 | 254 |
| 252 - (void)animationDidEnd:(NSAnimation*)animation { | 255 - (void)animationDidEnd:(NSAnimation*)animation { |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 } | 442 } |
| 440 | 443 |
| 441 // Set the tracking off to create a new tracking area for the control. | 444 // Set the tracking off to create a new tracking area for the control. |
| 442 // When changing the bounds/frame on a HoverButton, the tracking isn't updated | 445 // When changing the bounds/frame on a HoverButton, the tracking isn't updated |
| 443 // correctly, it needs to be turned off and back on. | 446 // correctly, it needs to be turned off and back on. |
| 444 [hoverCloseButton_ setTrackingEnabled:NO]; | 447 [hoverCloseButton_ setTrackingEnabled:NO]; |
| 445 [hoverCloseButton_ setFrame:bounds]; | 448 [hoverCloseButton_ setFrame:bounds]; |
| 446 [hoverCloseButton_ setTrackingEnabled:YES]; | 449 [hoverCloseButton_ setTrackingEnabled:YES]; |
| 447 } | 450 } |
| 448 @end | 451 @end |
| OLD | NEW |