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]); | |
Randy Smith (Not in Mondays)
2011/09/30 15:57:21
I believe that on some platforms, but not others,
benjhayden
2011/10/03 20:54:39
I went ahead and split the stat.
| |
245 | |
246 int numPending = 0; | |
247 for (NSUInteger i = 0; i < [downloadItemControllers_ count]; ++i) { | |
248 DownloadItemController* itemController = | |
249 [downloadItemControllers_ objectAtIndex:i]; | |
250 DownloadItem* download = [itemController download]; | |
251 bool isTransferDone = download->IsComplete() || | |
252 download->IsCancelled() || | |
253 download->IsInterrupted(); | |
Randy Smith (Not in Mondays)
2011/09/30 15:57:21
Is there a reason we're not just counting number i
benjhayden
2011/10/03 20:54:39
Done.
| |
254 if (!isTransferDone) | |
255 ++numPending; | |
256 } | |
257 download_stats::RecordShelfPendingSize(numPending); | |
258 | |
243 // If |sender| isn't nil, then we're being closed from the UI by the user and | 259 // 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 | 260 // we need to tell our shelf implementation to close. Otherwise, we're being |
245 // closed programmatically by our shelf implementation. | 261 // closed programmatically by our shelf implementation. |
246 if (sender) | 262 if (sender) |
247 bridge_->Close(); | 263 bridge_->Close(); |
248 else | 264 else |
249 [self showDownloadShelf:NO]; | 265 [self showDownloadShelf:NO]; |
250 } | 266 } |
251 | 267 |
252 - (void)animationDidEnd:(NSAnimation*)animation { | 268 - (void)animationDidEnd:(NSAnimation*)animation { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 } | 455 } |
440 | 456 |
441 // Set the tracking off to create a new tracking area for the control. | 457 // 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 | 458 // When changing the bounds/frame on a HoverButton, the tracking isn't updated |
443 // correctly, it needs to be turned off and back on. | 459 // correctly, it needs to be turned off and back on. |
444 [hoverCloseButton_ setTrackingEnabled:NO]; | 460 [hoverCloseButton_ setTrackingEnabled:NO]; |
445 [hoverCloseButton_ setFrame:bounds]; | 461 [hoverCloseButton_ setFrame:bounds]; |
446 [hoverCloseButton_ setTrackingEnabled:YES]; | 462 [hoverCloseButton_ setTrackingEnabled:YES]; |
447 } | 463 } |
448 @end | 464 @end |
OLD | NEW |