Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/toolbar/toolbar_controller.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 #include "ui/base/l10n/l10n_util_mac.h" | 63 #include "ui/base/l10n/l10n_util_mac.h" |
| 64 #include "ui/gfx/geometry/rect.h" | 64 #include "ui/gfx/geometry/rect.h" |
| 65 #include "ui/gfx/image/image.h" | 65 #include "ui/gfx/image/image.h" |
| 66 | 66 |
| 67 using content::OpenURLParams; | 67 using content::OpenURLParams; |
| 68 using content::Referrer; | 68 using content::Referrer; |
| 69 using content::WebContents; | 69 using content::WebContents; |
| 70 | 70 |
| 71 namespace { | 71 namespace { |
| 72 | 72 |
| 73 // Duration of the toolbar animation. | |
| 74 const NSTimeInterval kToolBarAnimationDuration = 0.12; | |
| 75 | |
| 73 // Height of the toolbar in pixels when the bookmark bar is closed. | 76 // Height of the toolbar in pixels when the bookmark bar is closed. |
| 74 const CGFloat kBaseToolbarHeightNormal = 35.0; | 77 const CGFloat kBaseToolbarHeightNormal = 35.0; |
| 75 | 78 |
| 76 // The padding above the toolbar elements. This is calculated from the values | 79 // The padding above the toolbar elements. This is calculated from the values |
| 77 // in Toolbar.xib: the height of the toolbar (35) minus the height of the child | 80 // in Toolbar.xib: the height of the toolbar (35) minus the height of the child |
| 78 // elements (29) minus the y-origin of the elements (4). | 81 // elements (29) minus the y-origin of the elements (4). |
| 79 const CGFloat kToolbarElementTopPadding = 2.0; | 82 const CGFloat kToolbarElementTopPadding = 2.0; |
| 80 | 83 |
| 81 // The minimum width of the location bar in pixels. | 84 // The minimum width of the location bar in pixels. |
| 82 const CGFloat kMinimumLocationBarWidth = 100.0; | 85 const CGFloat kMinimumLocationBarWidth = 100.0; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 125 |
| 123 } // namespace | 126 } // namespace |
| 124 | 127 |
| 125 @interface ToolbarController() | 128 @interface ToolbarController() |
| 126 @property(assign, nonatomic) Browser* browser; | 129 @property(assign, nonatomic) Browser* browser; |
| 127 - (void)cleanUp; | 130 - (void)cleanUp; |
| 128 - (void)addAccessibilityDescriptions; | 131 - (void)addAccessibilityDescriptions; |
| 129 - (void)initCommandStatus:(CommandUpdater*)commands; | 132 - (void)initCommandStatus:(CommandUpdater*)commands; |
| 130 - (void)prefChanged:(const std::string&)prefName; | 133 - (void)prefChanged:(const std::string&)prefName; |
| 131 - (BackgroundGradientView*)backgroundGradientView; | 134 - (BackgroundGradientView*)backgroundGradientView; |
| 135 - (AnimatableView*)animatableView; | |
| 132 - (void)toolbarFrameChanged; | 136 - (void)toolbarFrameChanged; |
| 133 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; | 137 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; |
| 134 - (void)maintainMinimumLocationBarWidth; | 138 - (void)maintainMinimumLocationBarWidth; |
| 135 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; | 139 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; |
| 136 - (void)browserActionsContainerDragged:(NSNotification*)notification; | 140 - (void)browserActionsContainerDragged:(NSNotification*)notification; |
| 137 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; | 141 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; |
| 138 - (void)browserActionsContainerWillAnimate:(NSNotification*)notification; | 142 - (void)browserActionsContainerWillAnimate:(NSNotification*)notification; |
| 139 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; | 143 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; |
| 140 - (void)updateWrenchButtonSeverity:(WrenchIconPainter::Severity)severity | 144 - (void)updateWrenchButtonSeverity:(WrenchIconPainter::Severity)severity |
| 141 animate:(BOOL)animate; | 145 animate:(BOOL)animate; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 commands->AddCommandObserver(IDC_BOOKMARK_PAGE, commandObserver_.get()); | 234 commands->AddCommandObserver(IDC_BOOKMARK_PAGE, commandObserver_.get()); |
| 231 // NOTE: Don't remove the command observers. ToolbarController is | 235 // NOTE: Don't remove the command observers. ToolbarController is |
| 232 // autoreleased at about the same time as the CommandUpdater (owned by the | 236 // autoreleased at about the same time as the CommandUpdater (owned by the |
| 233 // Browser), so |commands_| may not be valid any more. | 237 // Browser), so |commands_| may not be valid any more. |
| 234 } | 238 } |
| 235 return self; | 239 return self; |
| 236 } | 240 } |
| 237 | 241 |
| 238 - (id)initWithCommands:(CommandUpdater*)commands | 242 - (id)initWithCommands:(CommandUpdater*)commands |
| 239 profile:(Profile*)profile | 243 profile:(Profile*)profile |
| 240 browser:(Browser*)browser { | 244 browser:(Browser*)browser |
| 245 resizeDelegate:(id<ViewResizer>)resizeDelegate { | |
| 241 if ((self = [self initWithCommands:commands | 246 if ((self = [self initWithCommands:commands |
| 242 profile:profile | 247 profile:profile |
| 243 browser:browser | 248 browser:browser |
| 244 nibFileNamed:@"Toolbar"])) { | 249 nibFileNamed:@"Toolbar"])) { |
|
tapted
2015/10/16 00:06:16
shouldn't a resizeDelegate argument be required fo
dominickn
2015/10/20 04:40:21
Done.
| |
| 245 // Start global error services now so we badge the menu correctly. | 250 // Start global error services now so we badge the menu correctly. |
| 246 SyncGlobalErrorFactory::GetForProfile(profile); | 251 SyncGlobalErrorFactory::GetForProfile(profile); |
| 252 | |
| 253 // Set the resize delegate (BWC) so that resizing triggers a layout redraw | |
|
tapted
2015/10/16 00:06:17
nit: this comment doesn't add much, and can be dro
dominickn
2015/10/20 04:40:22
Done.
| |
| 254 // automatically. | |
| 255 [[self animatableView] setResizeDelegate:resizeDelegate]; | |
| 247 } | 256 } |
| 248 return self; | 257 return self; |
| 249 } | 258 } |
| 250 | 259 |
| 251 // Called after the view is done loading and the outlets have been hooked up. | 260 // Called after the view is done loading and the outlets have been hooked up. |
| 252 // Now we can hook up bridges that rely on UI objects such as the location bar | 261 // Now we can hook up bridges that rely on UI objects such as the location bar |
| 253 // and button state. -viewDidLoad is the recommended way to do this in 10.10 | 262 // and button state. -viewDidLoad is the recommended way to do this in 10.10 |
| 254 // SDK. When running on 10.10 or above -awakeFromNib still works but for some | 263 // SDK. When running on 10.10 or above -awakeFromNib still works but for some |
| 255 // reason is not guaranteed to be called (http://crbug.com/526276), so implement | 264 // reason is not guaranteed to be called (http://crbug.com/526276), so implement |
| 256 // both. | 265 // both. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 // Create the controllers for the back/forward menus. | 351 // Create the controllers for the back/forward menus. |
| 343 backMenuController_.reset([[BackForwardMenuController alloc] | 352 backMenuController_.reset([[BackForwardMenuController alloc] |
| 344 initWithBrowser:browser_ | 353 initWithBrowser:browser_ |
| 345 modelType:BACK_FORWARD_MENU_TYPE_BACK | 354 modelType:BACK_FORWARD_MENU_TYPE_BACK |
| 346 button:backButton_]); | 355 button:backButton_]); |
| 347 forwardMenuController_.reset([[BackForwardMenuController alloc] | 356 forwardMenuController_.reset([[BackForwardMenuController alloc] |
| 348 initWithBrowser:browser_ | 357 initWithBrowser:browser_ |
| 349 modelType:BACK_FORWARD_MENU_TYPE_FORWARD | 358 modelType:BACK_FORWARD_MENU_TYPE_FORWARD |
| 350 button:forwardButton_]); | 359 button:forwardButton_]); |
| 351 | 360 |
| 352 // For a popup window, the toolbar is really just a location bar | |
| 353 // (see override for [ToolbarController view], below). When going | |
| 354 // fullscreen, we remove the toolbar controller's view from the view | |
| 355 // hierarchy. Calling [locationBar_ removeFromSuperview] when going | |
| 356 // fullscreen causes it to get released, making us unhappy | |
| 357 // (http://crbug.com/18551). We avoid the problem by incrementing | |
| 358 // the retain count of the location bar; use of the scoped object | |
| 359 // helps us remember to release it. | |
| 360 locationBarRetainer_.reset([locationBar_ retain]); | |
| 361 trackingArea_.reset( | 361 trackingArea_.reset( |
| 362 [[CrTrackingArea alloc] initWithRect:NSZeroRect // Ignored | 362 [[CrTrackingArea alloc] initWithRect:NSZeroRect // Ignored |
| 363 options:NSTrackingMouseMoved | | 363 options:NSTrackingMouseMoved | |
| 364 NSTrackingInVisibleRect | | 364 NSTrackingInVisibleRect | |
| 365 NSTrackingMouseEnteredAndExited | | 365 NSTrackingMouseEnteredAndExited | |
| 366 NSTrackingActiveAlways | 366 NSTrackingActiveAlways |
| 367 owner:self | 367 owner:self |
| 368 userInfo:nil]); | 368 userInfo:nil]); |
| 369 NSView* toolbarView = [self view]; | 369 NSView* toolbarView = [self view]; |
| 370 [toolbarView addTrackingArea:trackingArea_.get()]; | 370 [toolbarView addTrackingArea:trackingArea_.get()]; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 388 | 388 |
| 389 [self addAccessibilityDescriptions]; | 389 [self addAccessibilityDescriptions]; |
| 390 } | 390 } |
| 391 | 391 |
| 392 - (void)dealloc { | 392 - (void)dealloc { |
| 393 [self cleanUp]; | 393 [self cleanUp]; |
| 394 [super dealloc]; | 394 [super dealloc]; |
| 395 } | 395 } |
| 396 | 396 |
| 397 - (void)browserWillBeDestroyed { | 397 - (void)browserWillBeDestroyed { |
| 398 // Clear resize delegate so it doesn't get called during stopAnimation, and | |
| 399 // stop any in-flight animation. | |
| 400 [[self animatableView] setResizeDelegate:nil]; | |
| 401 [[self animatableView] stopAnimation]; | |
| 402 | |
| 398 // Pass this call onto other reference counted objects. | 403 // Pass this call onto other reference counted objects. |
| 399 [backMenuController_ browserWillBeDestroyed]; | 404 [backMenuController_ browserWillBeDestroyed]; |
| 400 [forwardMenuController_ browserWillBeDestroyed]; | 405 [forwardMenuController_ browserWillBeDestroyed]; |
| 401 [browserActionsController_ browserWillBeDestroyed]; | 406 [browserActionsController_ browserWillBeDestroyed]; |
| 402 [wrenchMenuController_ browserWillBeDestroyed]; | 407 [wrenchMenuController_ browserWillBeDestroyed]; |
| 403 | 408 |
| 404 [self cleanUp]; | 409 [self cleanUp]; |
| 405 } | 410 } |
| 406 | 411 |
| 407 - (void)cleanUp { | 412 - (void)cleanUp { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 | 585 |
| 581 hasToolbar_ = toolbar; | 586 hasToolbar_ = toolbar; |
| 582 | 587 |
| 583 // If there's a toolbar, there must be a location bar. | 588 // If there's a toolbar, there must be a location bar. |
| 584 DCHECK((toolbar && locBar) || !toolbar); | 589 DCHECK((toolbar && locBar) || !toolbar); |
| 585 hasLocationBar_ = toolbar ? YES : locBar; | 590 hasLocationBar_ = toolbar ? YES : locBar; |
| 586 | 591 |
| 587 // Decide whether to hide/show based on whether there's a location bar. | 592 // Decide whether to hide/show based on whether there's a location bar. |
| 588 [[self view] setHidden:!hasLocationBar_]; | 593 [[self view] setHidden:!hasLocationBar_]; |
| 589 | 594 |
| 590 // Make location bar not editable when in a pop-up. | 595 // Make location bar not editable when in a pop-up. |
|
tapted
2015/10/16 00:06:16
is this consistent with what views does? (then, up
dominickn
2015/10/20 04:40:22
Done.
| |
| 591 locationBarView_->SetEditable(toolbar); | 596 locationBarView_->SetEditable(toolbar); |
| 597 | |
| 598 // Hide the toolbar buttons and only display the location bar in the view | |
| 599 // if we do not have a toolbar but have a location bar. | |
| 600 [self shouldHideToolbarButtons:(!toolbar && locBar)]; | |
|
tapted
2015/10/16 00:06:16
nit: no parens required
dominickn
2015/10/20 04:40:22
Done.
| |
| 592 } | 601 } |
| 593 | 602 |
| 594 - (NSView*)view { | 603 // (Private) Returns the backdrop to the toolbar as a BackgroundGradientView. |
| 595 if (hasToolbar_) | 604 - (BackgroundGradientView*)backgroundGradientView { |
| 596 return [super view]; | 605 DCHECK([[self view] isKindOfClass:[BackgroundGradientView class]]); |
| 597 return locationBar_; | 606 return (BackgroundGradientView*)[self view]; |
|
tapted
2015/10/16 00:06:17
might as well change this to ObjCCastStrict if dif
dominickn
2015/10/20 04:40:22
Done.
| |
| 598 } | 607 } |
| 599 | 608 |
| 600 // (Private) Returns the backdrop to the toolbar. | 609 // (Private) Returns the backdrop to the toolbar as an AnimatableView. |
| 601 - (BackgroundGradientView*)backgroundGradientView { | 610 - (AnimatableView*)animatableView{ |
| 602 // We really do mean |[super view]|; see our override of |-view|. | 611 DCHECK([[self view] isKindOfClass:[AnimatableView class]]); |
|
tapted
2015/10/16 00:06:16
DCHECK not required (happens in ObjCCastStrict)
dominickn
2015/10/20 04:40:22
Done.
| |
| 603 DCHECK([[super view] isKindOfClass:[BackgroundGradientView class]]); | 612 return base::mac::ObjCCastStrict<AnimatableView>([self view]); |
| 604 return (BackgroundGradientView*)[super view]; | |
| 605 } | 613 } |
| 606 | 614 |
| 607 - (id)customFieldEditorForObject:(id)obj { | 615 - (id)customFieldEditorForObject:(id)obj { |
| 608 if (obj == locationBar_) { | 616 if (obj == locationBar_) { |
| 609 // Lazilly construct Field editor, Cocoa UI code always runs on the | 617 // Lazilly construct Field editor, Cocoa UI code always runs on the |
| 610 // same thread, so there shoudn't be a race condition here. | 618 // same thread, so there shoudn't be a race condition here. |
| 611 if (autocompleteTextFieldEditor_.get() == nil) { | 619 if (autocompleteTextFieldEditor_.get() == nil) { |
| 612 autocompleteTextFieldEditor_.reset( | 620 autocompleteTextFieldEditor_.reset( |
| 613 [[AutocompleteTextFieldEditor alloc] init]); | 621 [[AutocompleteTextFieldEditor alloc] init]); |
| 614 } | 622 } |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 719 [[NSNotificationCenter defaultCenter] | 727 [[NSNotificationCenter defaultCenter] |
| 720 addObserver:self | 728 addObserver:self |
| 721 selector:@selector(adjustBrowserActionsContainerForNewWindow:) | 729 selector:@selector(adjustBrowserActionsContainerForNewWindow:) |
| 722 name:NSWindowDidBecomeKeyNotification | 730 name:NSWindowDidBecomeKeyNotification |
| 723 object:[[self view] window]]; | 731 object:[[self view] window]]; |
| 724 } | 732 } |
| 725 if (![browserActionsContainerView_ isHidden]) | 733 if (![browserActionsContainerView_ isHidden]) |
| 726 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; | 734 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; |
| 727 } | 735 } |
| 728 | 736 |
| 737 - (void)updateVisibility:(BOOL)visible withAnimation:(BOOL)animate { | |
|
tapted
2015/10/16 00:06:17
setToolbarHidden?
dominickn
2015/10/20 04:40:22
This method can set the toolbar to hidden or visib
tapted
2015/10/20 06:31:08
Ah, I meant since Cocoa nomenclature is "[NSView i
| |
| 738 // |visible| being YES is equivalent to [[toolbarController_ view] isHidden] | |
| 739 // being NO, and vice-versa. That is, when |visible| and |isHidden| have the | |
| 740 // same value, a state change is needed. | |
| 741 AnimatableView* view = [self animatableView]; | |
| 742 if ([view isHidden] == visible) { | |
| 743 // Send shouldHideToolbarButtons:YES if there is no toolbar and there is a | |
| 744 // location bar. This has the effect of displaying a toolbar with only the | |
| 745 // location bar inside it. | |
| 746 [self setHasToolbar:hasToolbar_ hasLocationBar:visible]; | |
|
tapted
2015/10/16 00:06:17
DCHECK(hasToolbar_)? (and pass YES) here?
dominickn
2015/10/20 04:40:22
hasToolbar_ isn't usually YES in this case. For bo
| |
| 747 | |
| 748 // updateVisibility is only called when in a hosted app. The bookmark bar is | |
| 749 // never visible in these apps, so the desired height will always be | |
| 750 // kBaseToolbarHeightNormal. | |
| 751 CGFloat newHeight = visible ? kBaseToolbarHeightNormal : 0; | |
| 752 | |
| 753 // Perform the animation, which will cause the BWC to resize this view in | |
|
tapted
2015/10/16 00:06:17
nit: (shouldn't abbreviate in comments): BWC -> Br
dominickn
2015/10/20 04:40:22
Done.
| |
| 754 // the browser layout as required. | |
| 755 if (animate) { | |
| 756 [view animateToNewHeight:newHeight | |
| 757 duration:kToolBarAnimationDuration]; | |
| 758 } else { | |
| 759 [view setHeight:newHeight]; | |
| 760 } | |
| 761 } | |
| 762 } | |
| 763 | |
| 764 - (void)shouldHideToolbarButtons:(BOOL)hide { | |
| 765 // Ignore this message if the toolbar is shown or the location bar is hidden. | |
| 766 if (hasToolbar_ || !hasLocationBar_) | |
|
tapted
2015/10/17 00:44:15
I think the only caller does
[self shouldHideTool
dominickn
2015/10/20 04:40:22
I tried to keep this as general as possible so tha
| |
| 767 return; | |
| 768 | |
| 769 // Work out if we need to show or hide the buttons. Assumes that the back, | |
| 770 // forward, reload, and wrench buttons are either shown or hidden together. | |
| 771 DCHECK([backButton_ isHidden] == [forwardButton_ isHidden] && | |
|
tapted
2015/10/17 00:44:15
perhaps
DCHECK_EQ(NO, [backButton_ isHidden] | [f
dominickn
2015/10/20 04:40:22
Done.
| |
| 772 [forwardButton_ isHidden] == [reloadButton_ isHidden] && | |
| 773 [reloadButton_ isHidden] == [wrenchButton_ isHidden]); | |
| 774 BOOL hidden = [backButton_ isHidden]; | |
|
tapted
2015/10/17 00:44:15
hidden isn't used after this, so I'd move this int
dominickn
2015/10/20 04:40:22
Done.
| |
| 775 | |
| 776 // Don't do anything if the current state matches the desired state. | |
| 777 if (hidden == hide) | |
| 778 return; | |
| 779 | |
| 780 // We need to X-shift the location bar (back, forward, reload buttons are left | |
| 781 // of the bar) and adjust its width (wrench button right of the bar). | |
| 782 // Calculate the necessary X-shift minus three pixels since the frame edges | |
| 783 // of each button are right on top of each other. | |
| 784 CGFloat moveX = [backButton_ frame].size.width + | |
|
tapted
2015/10/16 00:06:17
I think this stuff should be part of the layout fu
tapted
2015/10/17 00:44:15
Hm, since the homeButton hiding is here, I guess h
dominickn
2015/10/20 04:40:22
Done.
| |
| 785 [forwardButton_ frame].size.width + | |
|
tapted
2015/10/17 00:44:15
It's more typical to do NSWidth([forwardButton_ fr
| |
| 786 [reloadButton_ frame].size.width - 3.0; | |
|
tapted
2015/10/17 00:44:15
This "3" feels a bit magic. Is is 3 * kSomeNegativ
tapted
2015/10/17 00:44:15
If these are laid out together already, you can ju
| |
| 787 | |
| 788 // Calculate the necessary width change minus one pixel for the frame edge. | |
| 789 CGFloat dX = [wrenchButton_ frame].size.width - 1.0; | |
| 790 | |
| 791 // Add the home button width to the X-shift if it is currently visible. | |
| 792 BOOL homeButtonEnabled = showHomeButton_.GetValue() ? YES : NO; | |
| 793 if (homeButtonEnabled) | |
| 794 moveX += [homeButton_ frame].size.width - 1.0; | |
| 795 | |
| 796 // If we're hiding, the direction of the shift must be reversed (leftwards). | |
| 797 // Otherwise, the direction of the resize must be reversed (leftwards). | |
| 798 if (hide) | |
| 799 moveX *= -1; | |
| 800 else | |
| 801 dX *= -1; | |
| 802 | |
| 803 // Do the necessary moving and resizing, and update the visibility of the | |
| 804 // buttons appropriately. | |
| 805 [self adjustLocationSizeBy:dX animate:NO]; | |
|
tapted
2015/10/17 00:44:15
since this is being called on `self` and we pass `
| |
| 806 [locationBar_ setFrame:[self adjustRect:[locationBar_ frame] | |
|
tapted
2015/10/17 00:44:15
this clobbers the [locationBar_ setFrame:locationF
dominickn
2015/10/20 04:40:22
It's assumed that adjustLocationSizeBy won't be ca
| |
| 807 byAmount:moveX]]; | |
| 808 [backButton_ setHidden:hide]; | |
| 809 [forwardButton_ setHidden:hide]; | |
| 810 [reloadButton_ setHidden:hide]; | |
| 811 [wrenchButton_ setHidden:hide]; | |
| 812 | |
| 813 if (homeButtonEnabled) | |
| 814 [homeButton_ setHidden:hide]; | |
| 815 } | |
| 816 | |
| 729 - (void)adjustBrowserActionsContainerForNewWindow: | 817 - (void)adjustBrowserActionsContainerForNewWindow: |
| 730 (NSNotification*)notification { | 818 (NSNotification*)notification { |
| 731 [self toolbarFrameChanged]; | 819 [self toolbarFrameChanged]; |
| 732 [[NSNotificationCenter defaultCenter] | 820 [[NSNotificationCenter defaultCenter] |
| 733 removeObserver:self | 821 removeObserver:self |
| 734 name:NSWindowDidBecomeKeyNotification | 822 name:NSWindowDidBecomeKeyNotification |
| 735 object:[[self view] window]]; | 823 object:[[self view] window]]; |
| 736 } | 824 } |
| 737 | 825 |
| 738 - (void)browserActionsContainerDragged:(NSNotification*)notification { | 826 - (void)browserActionsContainerDragged:(NSNotification*)notification { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 if (!hasToolbar_) | 955 if (!hasToolbar_) |
| 868 return NSHeight([locationBar_ frame]); | 956 return NSHeight([locationBar_ frame]); |
| 869 | 957 |
| 870 return kBaseToolbarHeightNormal - compressByHeight; | 958 return kBaseToolbarHeightNormal - compressByHeight; |
| 871 } | 959 } |
| 872 | 960 |
| 873 - (void)setDividerOpacity:(CGFloat)opacity { | 961 - (void)setDividerOpacity:(CGFloat)opacity { |
| 874 BackgroundGradientView* view = [self backgroundGradientView]; | 962 BackgroundGradientView* view = [self backgroundGradientView]; |
| 875 [view setShowsDivider:(opacity > 0 ? YES : NO)]; | 963 [view setShowsDivider:(opacity > 0 ? YES : NO)]; |
| 876 | 964 |
| 877 // We may not have a toolbar view (e.g., popup windows only have a location | 965 ToolbarView* toolbarView = (ToolbarView*)view; |
|
tapted
2015/10/16 00:06:16
ObjCCastStrict
But! actually. Now I see this cod
dominickn
2015/10/20 04:40:21
Done.
| |
| 878 // bar). | 966 [toolbarView setDividerOpacity:opacity]; |
| 879 if ([view isKindOfClass:[ToolbarView class]]) { | |
| 880 ToolbarView* toolbarView = (ToolbarView*)view; | |
| 881 [toolbarView setDividerOpacity:opacity]; | |
| 882 } | |
| 883 | 967 |
| 884 [view setNeedsDisplay:YES]; | 968 [view setNeedsDisplay:YES]; |
| 885 } | 969 } |
| 886 | 970 |
| 887 - (BrowserActionsController*)browserActionsController { | 971 - (BrowserActionsController*)browserActionsController { |
| 888 return browserActionsController_.get(); | 972 return browserActionsController_.get(); |
| 889 } | 973 } |
| 890 | 974 |
| 891 - (NSView*)wrenchButton { | 975 - (NSView*)wrenchButton { |
| 892 return wrenchButton_; | 976 return wrenchButton_; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 950 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 1034 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 951 // Do nothing. | 1035 // Do nothing. |
| 952 } | 1036 } |
| 953 | 1037 |
| 954 // (URLDropTargetController protocol) | 1038 // (URLDropTargetController protocol) |
| 955 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 1039 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 956 return drag_util::IsUnsupportedDropData(profile_, info); | 1040 return drag_util::IsUnsupportedDropData(profile_, info); |
| 957 } | 1041 } |
| 958 | 1042 |
| 959 @end | 1043 @end |
| OLD | NEW |