| 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/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 @interface ToolbarController() | 83 @interface ToolbarController() |
| 84 @property(assign, nonatomic) Browser* browser; | 84 @property(assign, nonatomic) Browser* browser; |
| 85 - (void)addAccessibilityDescriptions; | 85 - (void)addAccessibilityDescriptions; |
| 86 - (void)initCommandStatus:(CommandUpdater*)commands; | 86 - (void)initCommandStatus:(CommandUpdater*)commands; |
| 87 - (void)prefChanged:(const std::string&)prefName; | 87 - (void)prefChanged:(const std::string&)prefName; |
| 88 - (BackgroundGradientView*)backgroundGradientView; | 88 - (BackgroundGradientView*)backgroundGradientView; |
| 89 - (void)toolbarFrameChanged; | 89 - (void)toolbarFrameChanged; |
| 90 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; | 90 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate; |
| 91 - (void)maintainMinimumLocationBarWidth; | 91 - (void)maintainMinimumLocationBarWidth; |
| 92 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; | 92 - (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification; |
| 93 - (void)browserActionsContainerWillDrag:(NSNotification*)notification; |
| 93 - (void)browserActionsContainerDragged:(NSNotification*)notification; | 94 - (void)browserActionsContainerDragged:(NSNotification*)notification; |
| 94 - (void)browserActionsContainerDragFinished:(NSNotification*)notification; | 95 - (void)browserActionsContainerDragFinished:(NSNotification*)notification; |
| 95 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; | 96 - (void)browserActionsVisibilityChanged:(NSNotification*)notification; |
| 96 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; | 97 - (void)adjustLocationSizeBy:(CGFloat)dX animate:(BOOL)animate; |
| 97 - (void)updateWrenchButtonSeverity:(WrenchIconPainter::Severity)severity | 98 - (void)updateWrenchButtonSeverity:(WrenchIconPainter::Severity)severity |
| 98 animate:(BOOL)animate; | 99 animate:(BOOL)animate; |
| 99 @end | 100 @end |
| 100 | 101 |
| 101 namespace ToolbarControllerInternal { | 102 namespace ToolbarControllerInternal { |
| 102 | 103 |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 } | 585 } |
| 585 } | 586 } |
| 586 | 587 |
| 587 - (void)createBrowserActionButtons { | 588 - (void)createBrowserActionButtons { |
| 588 if (!browserActionsController_.get()) { | 589 if (!browserActionsController_.get()) { |
| 589 browserActionsController_.reset([[BrowserActionsController alloc] | 590 browserActionsController_.reset([[BrowserActionsController alloc] |
| 590 initWithBrowser:browser_ | 591 initWithBrowser:browser_ |
| 591 containerView:browserActionsContainerView_]); | 592 containerView:browserActionsContainerView_]); |
| 592 [[NSNotificationCenter defaultCenter] | 593 [[NSNotificationCenter defaultCenter] |
| 593 addObserver:self | 594 addObserver:self |
| 595 selector:@selector(browserActionsContainerWillDrag:) |
| 596 name:kBrowserActionGrippyWillDragNotification |
| 597 object:browserActionsController_]; |
| 598 [[NSNotificationCenter defaultCenter] |
| 599 addObserver:self |
| 594 selector:@selector(browserActionsContainerDragged:) | 600 selector:@selector(browserActionsContainerDragged:) |
| 595 name:kBrowserActionGrippyDraggingNotification | 601 name:kBrowserActionGrippyDraggingNotification |
| 596 object:browserActionsController_]; | 602 object:browserActionsController_]; |
| 597 [[NSNotificationCenter defaultCenter] | 603 [[NSNotificationCenter defaultCenter] |
| 598 addObserver:self | 604 addObserver:self |
| 599 selector:@selector(browserActionsContainerDragFinished:) | 605 selector:@selector(browserActionsContainerDragFinished:) |
| 600 name:kBrowserActionGrippyDragFinishedNotification | 606 name:kBrowserActionGrippyDragFinishedNotification |
| 601 object:browserActionsController_]; | 607 object:browserActionsController_]; |
| 602 [[NSNotificationCenter defaultCenter] | 608 [[NSNotificationCenter defaultCenter] |
| 603 addObserver:self | 609 addObserver:self |
| (...skipping 28 matching lines...) Expand all Loading... |
| 632 [browserActionsContainerView_ setGrippyPinned:locationBarAtMinSize_]; | 638 [browserActionsContainerView_ setGrippyPinned:locationBarAtMinSize_]; |
| 633 [self adjustLocationSizeBy: | 639 [self adjustLocationSizeBy: |
| 634 [browserActionsContainerView_ resizeDeltaX] animate:NO]; | 640 [browserActionsContainerView_ resizeDeltaX] animate:NO]; |
| 635 } | 641 } |
| 636 | 642 |
| 637 - (void)browserActionsContainerDragFinished:(NSNotification*)notification { | 643 - (void)browserActionsContainerDragFinished:(NSNotification*)notification { |
| 638 [browserActionsController_ resizeContainerAndAnimate:YES]; | 644 [browserActionsController_ resizeContainerAndAnimate:YES]; |
| 639 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:YES]; | 645 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:YES]; |
| 640 } | 646 } |
| 641 | 647 |
| 648 - (void)browserActionsContainerWillDrag:(NSNotification*)notification { |
| 649 CGFloat deltaX = [[notification.userInfo objectForKey:kTranslationWithDelta] |
| 650 floatValue]; |
| 651 CGFloat locationBarWidth = NSWidth([locationBar_ frame]); |
| 652 BOOL locationBarWillBeAtMinSize = |
| 653 (locationBarWidth + deltaX) <= kMinimumLocationBarWidth; |
| 654 |
| 655 // Prevent the |browserActionsContainerView_| from dragging if the width of |
| 656 // location bar will reach the minimum. |
| 657 [browserActionsContainerView_ setCanDragLeft:!locationBarWillBeAtMinSize]; |
| 658 } |
| 659 |
| 642 - (void)browserActionsVisibilityChanged:(NSNotification*)notification { | 660 - (void)browserActionsVisibilityChanged:(NSNotification*)notification { |
| 643 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; | 661 [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO]; |
| 644 } | 662 } |
| 645 | 663 |
| 646 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { | 664 - (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate { |
| 647 CGFloat locationBarXPos = NSMaxX([locationBar_ frame]); | 665 CGFloat locationBarXPos = NSMaxX([locationBar_ frame]); |
| 648 CGFloat leftDistance; | 666 CGFloat leftDistance; |
| 649 | 667 |
| 650 if ([browserActionsContainerView_ isHidden]) { | 668 if ([browserActionsContainerView_ isHidden]) { |
| 651 CGFloat edgeXPos = [wrenchButton_ frame].origin.x; | 669 CGFloat edgeXPos = [wrenchButton_ frame].origin.x; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 848 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
| 831 // Do nothing. | 849 // Do nothing. |
| 832 } | 850 } |
| 833 | 851 |
| 834 // (URLDropTargetController protocol) | 852 // (URLDropTargetController protocol) |
| 835 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { | 853 - (BOOL)isUnsupportedDropData:(id<NSDraggingInfo>)info { |
| 836 return drag_util::IsUnsupportedDropData(profile_, info); | 854 return drag_util::IsUnsupportedDropData(profile_, info); |
| 837 } | 855 } |
| 838 | 856 |
| 839 @end | 857 @end |
| OLD | NEW |