OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/toolbar_controller.h" | 5 #import "chrome/browser/cocoa/toolbar_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 - (void)prefChanged:(std::wstring*)prefName { | 585 - (void)prefChanged:(std::wstring*)prefName { |
586 if (!prefName) return; | 586 if (!prefName) return; |
587 if (*prefName == prefs::kShowHomeButton) { | 587 if (*prefName == prefs::kShowHomeButton) { |
588 [self showOptionalHomeButton]; | 588 [self showOptionalHomeButton]; |
589 } else if (*prefName == prefs::kShowPageOptionsButtons) { | 589 } else if (*prefName == prefs::kShowPageOptionsButtons) { |
590 [self showOptionalPageWrenchButtons]; | 590 [self showOptionalPageWrenchButtons]; |
591 } | 591 } |
592 } | 592 } |
593 | 593 |
594 - (void)createBrowserActionButtons { | 594 - (void)createBrowserActionButtons { |
595 if (browserActionsController_.get() == nil) { | 595 if (!browserActionsController_.get()) { |
596 browserActionsController_.reset([[BrowserActionsController alloc] | 596 browserActionsController_.reset([[BrowserActionsController alloc] |
597 initWithBrowser:browser_ | 597 initWithBrowser:browser_ |
598 containerView:browserActionsContainerView_]); | 598 containerView:browserActionsContainerView_]); |
599 [[NSNotificationCenter defaultCenter] | 599 [[NSNotificationCenter defaultCenter] |
600 addObserver:self | 600 addObserver:self |
601 selector:@selector(browserActionsContainerDragged) | 601 selector:@selector(browserActionsContainerDragged) |
602 name:kBrowserActionGrippyDraggingNotification | 602 name:kBrowserActionGrippyDraggingNotification |
603 object:browserActionsController_]; | 603 object:browserActionsController_]; |
604 [[NSNotificationCenter defaultCenter] | 604 [[NSNotificationCenter defaultCenter] |
605 addObserver:self | 605 addObserver:self |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 - (void)maintainMinimumLocationBarWidth { | 655 - (void)maintainMinimumLocationBarWidth { |
656 CGFloat locationBarWidth = NSWidth([locationBar_ frame]); | 656 CGFloat locationBarWidth = NSWidth([locationBar_ frame]); |
657 locationBarAtMinSize_ = locationBarWidth <= kMinimumLocationBarWidth; | 657 locationBarAtMinSize_ = locationBarWidth <= kMinimumLocationBarWidth; |
658 if (locationBarAtMinSize_) { | 658 if (locationBarAtMinSize_) { |
659 CGFloat dX = kMinimumLocationBarWidth - locationBarWidth; | 659 CGFloat dX = kMinimumLocationBarWidth - locationBarWidth; |
660 [self adjustLocationAndGoPositionsBy:dX]; | 660 [self adjustLocationAndGoPositionsBy:dX]; |
661 } | 661 } |
662 } | 662 } |
663 | 663 |
664 - (void)toolbarFrameChanged { | 664 - (void)toolbarFrameChanged { |
| 665 // Do nothing if the frame changes but no Browser Action Controller is |
| 666 // present. |
| 667 if (!browserActionsController_.get()) |
| 668 return; |
| 669 |
665 [self maintainMinimumLocationBarWidth]; | 670 [self maintainMinimumLocationBarWidth]; |
666 | 671 |
667 if (locationBarAtMinSize_) { | 672 if (locationBarAtMinSize_) { |
668 // Once the grippy is pinned, leave it until it is explicity un-pinned. | 673 // Once the grippy is pinned, leave it until it is explicity un-pinned. |
669 [browserActionsContainerView_ setGrippyPinned:YES]; | 674 [browserActionsContainerView_ setGrippyPinned:YES]; |
670 NSRect containerFrame = [browserActionsContainerView_ frame]; | 675 NSRect containerFrame = [browserActionsContainerView_ frame]; |
671 // Determine how much the container needs to move in case it's overlapping | 676 // Determine how much the container needs to move in case it's overlapping |
672 // with the location bar. | 677 // with the location bar. |
673 CGFloat dX = ([goButton_ frame].origin.x + NSWidth([goButton_ frame])) - | 678 CGFloat dX = ([goButton_ frame].origin.x + NSWidth([goButton_ frame])) - |
674 containerFrame.origin.x + kBrowserActionsContainerLeftPadding; | 679 containerFrame.origin.x + kBrowserActionsContainerLeftPadding; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { | 844 - (void)indicateDropURLsInView:(NSView*)view at:(NSPoint)point { |
840 // Do nothing. | 845 // Do nothing. |
841 } | 846 } |
842 | 847 |
843 // (URLDropTargetController protocol) | 848 // (URLDropTargetController protocol) |
844 - (void)hideDropURLsIndicatorInView:(NSView*)view { | 849 - (void)hideDropURLsIndicatorInView:(NSView*)view { |
845 // Do nothing. | 850 // Do nothing. |
846 } | 851 } |
847 | 852 |
848 @end | 853 @end |
OLD | NEW |