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

Side by Side Diff: chrome/browser/ui/cocoa/download/download_shelf_controller.mm

Issue 8008021: Add new UMA stats to get a handle on Downloads UI Usage (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix windows auto_closed_ Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
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
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 int numInProgress = 0;
245 for (NSUInteger i = 0; i < [downloadItemControllers_ count]; ++i) {
246 if ([[downloadItemControllers_ objectAtIndex:i]download]->IsInProgress())
247 ++numInProgress;
248 }
249 download_stats::RecordShelfClose(
250 [downloadItemControllers_ count], numInProgress, sender == nil);
Randy Smith (Not in Mondays) 2011/10/09 23:40:17 Would a comment here about why sender == nil impli
benjhayden 2011/10/10 16:27:11 There already was a comment below. I refactored th
251
243 // If |sender| isn't nil, then we're being closed from the UI by the user and 252 // 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 253 // we need to tell our shelf implementation to close. Otherwise, we're being
245 // closed programmatically by our shelf implementation. 254 // closed programmatically by our shelf implementation.
246 if (sender) 255 if (sender)
247 bridge_->Close(); 256 bridge_->Close();
248 else 257 else
249 [self showDownloadShelf:NO]; 258 [self showDownloadShelf:NO];
250 } 259 }
251 260
252 - (void)animationDidEnd:(NSAnimation*)animation { 261 - (void)animationDidEnd:(NSAnimation*)animation {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 } 448 }
440 449
441 // Set the tracking off to create a new tracking area for the control. 450 // 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 451 // When changing the bounds/frame on a HoverButton, the tracking isn't updated
443 // correctly, it needs to be turned off and back on. 452 // correctly, it needs to be turned off and back on.
444 [hoverCloseButton_ setTrackingEnabled:NO]; 453 [hoverCloseButton_ setTrackingEnabled:NO];
445 [hoverCloseButton_ setFrame:bounds]; 454 [hoverCloseButton_ setFrame:bounds];
446 [hoverCloseButton_ setTrackingEnabled:YES]; 455 [hoverCloseButton_ setTrackingEnabled:YES];
447 } 456 }
448 @end 457 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698