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

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

Issue 2209443005: [Mac] Refactor for updating the download item (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_item_controller.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
11 #include "chrome/browser/download/download_stats.h" 11 #include "chrome/browser/download/download_stats.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/themes/theme_service.h" 13 #include "chrome/browser/themes/theme_service.h"
14 #include "chrome/browser/themes/theme_service_factory.h" 14 #include "chrome/browser/themes/theme_service_factory.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/chrome_pages.h" 16 #include "chrome/browser/ui/chrome_pages.h"
17 #import "chrome/browser/ui/cocoa/animatable_view.h" 17 #import "chrome/browser/ui/cocoa/animatable_view.h"
18 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" 18 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h"
19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
20 #include "chrome/browser/ui/cocoa/download/download_item_controller.h" 20 #include "chrome/browser/ui/cocoa/download/download_item_controller.h"
21 #include "chrome/browser/ui/cocoa/download/download_shelf_mac.h" 21 #include "chrome/browser/ui/cocoa/download/download_shelf_mac.h"
22 #import "chrome/browser/ui/cocoa/download/download_shelf_view_cocoa.h" 22 #import "chrome/browser/ui/cocoa/download/download_shelf_view_cocoa.h"
23 #include "content/public/browser/download_item.h" 23 #include "content/public/browser/download_item.h"
24 #include "content/public/browser/download_manager.h" 24 #include "content/public/browser/download_manager.h"
25 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 25 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
26 #import "ui/base/cocoa/hover_button.h" 26 #import "ui/base/cocoa/hover_button.h"
27 #import "ui/base/cocoa/nsview_additions.h"
27 28
28 using content::DownloadItem; 29 using content::DownloadItem;
29 30
30 // Download shelf autoclose behavior: 31 // Download shelf autoclose behavior:
31 // 32 //
32 // The download shelf autocloses if all of this is true: 33 // The download shelf autocloses if all of this is true:
33 // 1) An item on the shelf has just been opened or removed. 34 // 1) An item on the shelf has just been opened or removed.
34 // 2) All remaining items on the shelf have been opened in the past. 35 // 2) All remaining items on the shelf have been opened in the past.
35 // 3) The mouse leaves the shelf and remains off the shelf for 5 seconds. 36 // 3) The mouse leaves the shelf and remains off the shelf for 5 seconds.
36 // 37 //
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 - (void)closed; 77 - (void)closed;
77 - (void)maybeAutoCloseAfterDelay; 78 - (void)maybeAutoCloseAfterDelay;
78 - (void)scheduleAutoClose; 79 - (void)scheduleAutoClose;
79 - (void)cancelAutoClose; 80 - (void)cancelAutoClose;
80 - (void)autoClose; 81 - (void)autoClose;
81 - (void)viewFrameDidChange:(NSNotification*)notification; 82 - (void)viewFrameDidChange:(NSNotification*)notification;
82 - (void)installTrackingArea; 83 - (void)installTrackingArea;
83 - (void)removeTrackingArea; 84 - (void)removeTrackingArea;
84 - (void)willEnterFullscreen; 85 - (void)willEnterFullscreen;
85 - (void)didExitFullscreen; 86 - (void)didExitFullscreen;
86 - (void)updateDownloadItemView;
87 - (void)updateCloseButton; 87 - (void)updateCloseButton;
88 @end 88 @end
89 89
90 90
91 @implementation DownloadShelfController 91 @implementation DownloadShelfController
92 92
93 - (id)initWithBrowser:(Browser*)browser 93 - (id)initWithBrowser:(Browser*)browser
94 resizeDelegate:(id<ViewResizer>)resizeDelegate { 94 resizeDelegate:(id<ViewResizer>)resizeDelegate {
95 if ((self = [super initWithNibName:@"DownloadShelf" 95 if ((self = [super initWithNibName:@"DownloadShelf"
96 bundle:base::mac::FrameworkBundle()])) { 96 bundle:base::mac::FrameworkBundle()])) {
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } 475 }
476 476
477 - (void)willEnterFullscreen { 477 - (void)willEnterFullscreen {
478 isFullscreen_ = YES; 478 isFullscreen_ = YES;
479 [self updateCloseButton]; 479 [self updateCloseButton];
480 } 480 }
481 481
482 - (void)didExitFullscreen { 482 - (void)didExitFullscreen {
483 isFullscreen_ = NO; 483 isFullscreen_ = NO;
484 [self updateCloseButton]; 484 [self updateCloseButton];
485 [self updateDownloadItemView];
486 }
487
488 - (void)updateDownloadItemView {
489 for (DownloadItemController* controller in downloadItemControllers_.get()) 485 for (DownloadItemController* controller in downloadItemControllers_.get())
490 [controller updateDownloadItemView]; 486 [[controller view] cr_recursivelySetNeedsDisplay:YES];
491 } 487 }
492 488
493 - (void)updateCloseButton { 489 - (void)updateCloseButton {
494 if (!barIsVisible_) 490 if (!barIsVisible_)
495 return; 491 return;
496 492
497 NSRect selfBounds = [[self view] bounds]; 493 NSRect selfBounds = [[self view] bounds];
498 NSRect hoverFrame = [hoverCloseButton_ frame]; 494 NSRect hoverFrame = [hoverCloseButton_ frame];
499 NSRect bounds; 495 NSRect bounds;
500 496
501 if (isFullscreen_) { 497 if (isFullscreen_) {
502 bounds = NSMakeRect(NSMinX(hoverFrame), 0, 498 bounds = NSMakeRect(NSMinX(hoverFrame), 0,
503 selfBounds.size.width - NSMinX(hoverFrame), 499 selfBounds.size.width - NSMinX(hoverFrame),
504 selfBounds.size.height); 500 selfBounds.size.height);
505 } else { 501 } else {
506 bounds.origin.x = NSMinX(hoverFrame); 502 bounds.origin.x = NSMinX(hoverFrame);
507 bounds.origin.y = NSMidY(hoverFrame) - 503 bounds.origin.y = NSMidY(hoverFrame) -
508 kHoverCloseButtonDefaultSize.height / 2.0; 504 kHoverCloseButtonDefaultSize.height / 2.0;
509 bounds.size = kHoverCloseButtonDefaultSize; 505 bounds.size = kHoverCloseButtonDefaultSize;
510 } 506 }
511 507
512 // Set the tracking off to create a new tracking area for the control. 508 // Set the tracking off to create a new tracking area for the control.
513 // When changing the bounds/frame on a HoverButton, the tracking isn't updated 509 // When changing the bounds/frame on a HoverButton, the tracking isn't updated
514 // correctly, it needs to be turned off and back on. 510 // correctly, it needs to be turned off and back on.
515 [hoverCloseButton_ setTrackingEnabled:NO]; 511 [hoverCloseButton_ setTrackingEnabled:NO];
516 [hoverCloseButton_ setFrame:bounds]; 512 [hoverCloseButton_ setFrame:bounds];
517 [hoverCloseButton_ setTrackingEnabled:YES]; 513 [hoverCloseButton_ setTrackingEnabled:YES];
518 } 514 }
519 @end 515 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/download/download_item_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698