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