| 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 "browser_actions_controller.h" | 5 #import "browser_actions_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| (...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 } | 806 } |
| 807 [chevronAnimation_ setViewAnimations: | 807 [chevronAnimation_ setViewAnimations: |
| 808 [NSArray arrayWithObject:animationDictionary]]; | 808 [NSArray arrayWithObject:animationDictionary]]; |
| 809 [chevronAnimation_ startAnimation]; | 809 [chevronAnimation_ startAnimation]; |
| 810 } | 810 } |
| 811 | 811 |
| 812 - (void)chevronItemSelected:(id)menuItem { | 812 - (void)chevronItemSelected:(id)menuItem { |
| 813 [self browserActionClicked:[menuItem representedObject]]; | 813 [self browserActionClicked:[menuItem representedObject]]; |
| 814 } | 814 } |
| 815 | 815 |
| 816 // TODO(yoz): This only gets called when the set of actions in the overflow |
| 817 // menu changes (not for things that would update page actions). |
| 818 // It should instead be called each time the menu is opened. |
| 816 - (void)updateOverflowMenu { | 819 - (void)updateOverflowMenu { |
| 817 overflowMenu_.reset([[NSMenu alloc] initWithTitle:@""]); | 820 overflowMenu_.reset([[NSMenu alloc] initWithTitle:@""]); |
| 818 // See menu_button.h for documentation on why this is needed. | 821 // See menu_button.h for documentation on why this is needed. |
| 819 [overflowMenu_ addItemWithTitle:@"" action:nil keyEquivalent:@""]; | 822 [overflowMenu_ addItemWithTitle:@"" action:nil keyEquivalent:@""]; |
| 823 [overflowMenu_ setAutoenablesItems:NO]; |
| 820 | 824 |
| 821 for (BrowserActionButton* button in hiddenButtons_.get()) { | 825 for (BrowserActionButton* button in hiddenButtons_.get()) { |
| 822 NSString* name = base::SysUTF8ToNSString([button extension]->name()); | 826 NSString* name = base::SysUTF8ToNSString([button extension]->name()); |
| 823 NSMenuItem* item = | 827 NSMenuItem* item = |
| 824 [overflowMenu_ addItemWithTitle:name | 828 [overflowMenu_ addItemWithTitle:name |
| 825 action:@selector(chevronItemSelected:) | 829 action:@selector(chevronItemSelected:) |
| 826 keyEquivalent:@""]; | 830 keyEquivalent:@""]; |
| 827 [item setRepresentedObject:button]; | 831 [item setRepresentedObject:button]; |
| 828 [item setImage:[button compositedImage]]; | 832 [item setImage:[button compositedImage]]; |
| 829 [item setTarget:self]; | 833 [item setTarget:self]; |
| 834 [item setEnabled:[button isEnabled]]; |
| 830 } | 835 } |
| 831 [chevronMenuButton_ setAttachedMenu:overflowMenu_]; | 836 [chevronMenuButton_ setAttachedMenu:overflowMenu_]; |
| 832 } | 837 } |
| 833 | 838 |
| 834 - (void)updateGrippyCursors { | 839 - (void)updateGrippyCursors { |
| 835 [containerView_ setCanDragLeft:[hiddenButtons_ count] > 0]; | 840 [containerView_ setCanDragLeft:[hiddenButtons_ count] > 0]; |
| 836 [containerView_ setCanDragRight:[self visibleButtonCount] > 0]; | 841 [containerView_ setCanDragRight:[self visibleButtonCount] > 0]; |
| 837 [[containerView_ window] invalidateCursorRectsForView:containerView_]; | 842 [[containerView_ window] invalidateCursorRectsForView:containerView_]; |
| 838 } | 843 } |
| 839 | 844 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 852 if (profile_->IsOffTheRecord()) | 857 if (profile_->IsOffTheRecord()) |
| 853 index = toolbarModel_->IncognitoIndexToOriginal(index); | 858 index = toolbarModel_->IncognitoIndexToOriginal(index); |
| 854 if (index < toolbarModel_->size()) { | 859 if (index < toolbarModel_->size()) { |
| 855 const Extension* extension = toolbarModel_->GetExtensionByIndex(index); | 860 const Extension* extension = toolbarModel_->GetExtensionByIndex(index); |
| 856 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; | 861 return [buttons_ objectForKey:base::SysUTF8ToNSString(extension->id())]; |
| 857 } | 862 } |
| 858 return nil; | 863 return nil; |
| 859 } | 864 } |
| 860 | 865 |
| 861 @end | 866 @end |
| OLD | NEW |