| 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/extensions/browser_actions_controller.h" | 5 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" | 10 #include "chrome/browser/extensions/extension_message_bubble_controller.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // Handles when a menu item within the chevron overflow menu is selected. | 155 // Handles when a menu item within the chevron overflow menu is selected. |
| 156 - (void)chevronItemSelected:(id)menuItem; | 156 - (void)chevronItemSelected:(id)menuItem; |
| 157 | 157 |
| 158 // Updates the container's grippy cursor based on the number of hidden buttons. | 158 // Updates the container's grippy cursor based on the number of hidden buttons. |
| 159 - (void)updateGrippyCursors; | 159 - (void)updateGrippyCursors; |
| 160 | 160 |
| 161 // Returns the associated ToolbarController. | 161 // Returns the associated ToolbarController. |
| 162 - (ToolbarController*)toolbarController; | 162 - (ToolbarController*)toolbarController; |
| 163 | 163 |
| 164 // Creates a message bubble anchored to the given |anchorAction|, or the wrench | 164 // Creates a message bubble anchored to the given |anchorAction|, or the app |
| 165 // menu if no |anchorAction| is null. | 165 // menu if no |anchorAction| is null. |
| 166 - (ToolbarActionsBarBubbleMac*)createMessageBubble: | 166 - (ToolbarActionsBarBubbleMac*)createMessageBubble: |
| 167 (scoped_ptr<ToolbarActionsBarBubbleDelegate>)delegate | 167 (scoped_ptr<ToolbarActionsBarBubbleDelegate>)delegate |
| 168 anchorToSelf:(BOOL)anchorToSelf; | 168 anchorToSelf:(BOOL)anchorToSelf; |
| 169 | 169 |
| 170 // Called when the window for the active bubble is closing, and sets the active | 170 // Called when the window for the active bubble is closing, and sets the active |
| 171 // bubble to nil. | 171 // bubble to nil. |
| 172 - (void)bubbleWindowClosing:(NSNotification*)notification; | 172 - (void)bubbleWindowClosing:(NSNotification*)notification; |
| 173 | 173 |
| 174 // Sets the current focused view. Should only be used for the overflow | 174 // Sets the current focused view. Should only be used for the overflow |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 431 |
| 432 - (NSPoint)popupPointForId:(const std::string&)id { | 432 - (NSPoint)popupPointForId:(const std::string&)id { |
| 433 BrowserActionButton* button = [self buttonForId:id]; | 433 BrowserActionButton* button = [self buttonForId:id]; |
| 434 if (!button) | 434 if (!button) |
| 435 return NSZeroPoint; | 435 return NSZeroPoint; |
| 436 | 436 |
| 437 NSRect bounds; | 437 NSRect bounds; |
| 438 NSView* referenceButton = button; | 438 NSView* referenceButton = button; |
| 439 if ([button superview] != containerView_ || isOverflow_) { | 439 if ([button superview] != containerView_ || isOverflow_) { |
| 440 referenceButton = toolbarActionsBar_->platform_settings().chevron_enabled ? | 440 referenceButton = toolbarActionsBar_->platform_settings().chevron_enabled ? |
| 441 chevronMenuButton_.get() : [[self toolbarController] wrenchButton]; | 441 chevronMenuButton_.get() : [[self toolbarController] appMenuButton]; |
| 442 bounds = [referenceButton bounds]; | 442 bounds = [referenceButton bounds]; |
| 443 } else { | 443 } else { |
| 444 bounds = [button convertRect:[button frameAfterAnimation] | 444 bounds = [button convertRect:[button frameAfterAnimation] |
| 445 fromView:[button superview]]; | 445 fromView:[button superview]]; |
| 446 } | 446 } |
| 447 | 447 |
| 448 return [self popupPointForView:referenceButton withBounds:bounds]; | 448 return [self popupPointForView:referenceButton withBounds:bounds]; |
| 449 } | 449 } |
| 450 | 450 |
| 451 - (BOOL)chevronIsHidden { | 451 - (BOOL)chevronIsHidden { |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 - (ToolbarController*)toolbarController { | 1016 - (ToolbarController*)toolbarController { |
| 1017 return [[BrowserWindowController browserWindowControllerForWindow: | 1017 return [[BrowserWindowController browserWindowControllerForWindow: |
| 1018 browser_->window()->GetNativeWindow()] toolbarController]; | 1018 browser_->window()->GetNativeWindow()] toolbarController]; |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 - (ToolbarActionsBarBubbleMac*)createMessageBubble: | 1021 - (ToolbarActionsBarBubbleMac*)createMessageBubble: |
| 1022 (scoped_ptr<ToolbarActionsBarBubbleDelegate>)delegate | 1022 (scoped_ptr<ToolbarActionsBarBubbleDelegate>)delegate |
| 1023 anchorToSelf:(BOOL)anchorToSelf { | 1023 anchorToSelf:(BOOL)anchorToSelf { |
| 1024 DCHECK_GE([buttons_ count], 0u); | 1024 DCHECK_GE([buttons_ count], 0u); |
| 1025 NSView* anchorView = | 1025 NSView* anchorView = |
| 1026 anchorToSelf ? containerView_ : [[self toolbarController] wrenchButton]; | 1026 anchorToSelf ? containerView_ : [[self toolbarController] appMenuButton]; |
| 1027 NSPoint anchor = [self popupPointForView:anchorView | 1027 NSPoint anchor = [self popupPointForView:anchorView |
| 1028 withBounds:[anchorView bounds]]; | 1028 withBounds:[anchorView bounds]]; |
| 1029 | 1029 |
| 1030 anchor = [[containerView_ window] convertBaseToScreen:anchor]; | 1030 anchor = [[containerView_ window] convertBaseToScreen:anchor]; |
| 1031 activeBubble_ = [[ToolbarActionsBarBubbleMac alloc] | 1031 activeBubble_ = [[ToolbarActionsBarBubbleMac alloc] |
| 1032 initWithParentWindow:[containerView_ window] | 1032 initWithParentWindow:[containerView_ window] |
| 1033 anchorPoint:anchor | 1033 anchorPoint:anchor |
| 1034 delegate:delegate.Pass()]; | 1034 delegate:delegate.Pass()]; |
| 1035 [[NSNotificationCenter defaultCenter] | 1035 [[NSNotificationCenter defaultCenter] |
| 1036 addObserver:self | 1036 addObserver:self |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 #pragma mark - | 1052 #pragma mark - |
| 1053 #pragma mark Testing Methods | 1053 #pragma mark Testing Methods |
| 1054 | 1054 |
| 1055 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { | 1055 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index { |
| 1056 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; | 1056 return index < [buttons_ count] ? [buttons_ objectAtIndex:index] : nil; |
| 1057 } | 1057 } |
| 1058 | 1058 |
| 1059 @end | 1059 @end |
| OLD | NEW |