| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/wrench_menu/wrench_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 ui::MenuModel::ItemType type = model->GetTypeAt(index); | 115 ui::MenuModel::ItemType type = model->GetTypeAt(index); |
| 116 if (type != ui::MenuModel::TYPE_BUTTON_ITEM) { | 116 if (type != ui::MenuModel::TYPE_BUTTON_ITEM) { |
| 117 [super addItemToMenu:menu | 117 [super addItemToMenu:menu |
| 118 atIndex:index | 118 atIndex:index |
| 119 fromModel:model]; | 119 fromModel:model]; |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Handle the special-cased menu items. | 123 // Handle the special-cased menu items. |
| 124 int command_id = model->GetCommandIdAt(index); | 124 int command_id = model->GetCommandIdAt(index); |
| 125 scoped_nsobject<NSMenuItem> customItem( | 125 base::scoped_nsobject<NSMenuItem> customItem( |
| 126 [[NSMenuItem alloc] initWithTitle:@"" | 126 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); |
| 127 action:nil | |
| 128 keyEquivalent:@""]); | |
| 129 MenuTrackedRootView* view; | 127 MenuTrackedRootView* view; |
| 130 switch (command_id) { | 128 switch (command_id) { |
| 131 case IDC_EDIT_MENU: | 129 case IDC_EDIT_MENU: |
| 132 view = [buttonViewController_ editItem]; | 130 view = [buttonViewController_ editItem]; |
| 133 DCHECK(view); | 131 DCHECK(view); |
| 134 [customItem setView:view]; | 132 [customItem setView:view]; |
| 135 [view setMenuItem:customItem]; | 133 [view setMenuItem:customItem]; |
| 136 break; | 134 break; |
| 137 case IDC_ZOOM_MENU: | 135 case IDC_ZOOM_MENU: |
| 138 view = [buttonViewController_ zoomItem]; | 136 view = [buttonViewController_ zoomItem]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 155 ui::MenuModel* model = | 153 ui::MenuModel* model = |
| 156 static_cast<ui::MenuModel*>( | 154 static_cast<ui::MenuModel*>( |
| 157 [[menuItem representedObject] pointerValue]); | 155 [[menuItem representedObject] pointerValue]); |
| 158 | 156 |
| 159 // The section headers in the recent tabs submenu should be bold and black if | 157 // The section headers in the recent tabs submenu should be bold and black if |
| 160 // a font is specified for the items (bold is already applied in the | 158 // a font is specified for the items (bold is already applied in the |
| 161 // |MenuController| as the font returned by |GetLabelFontAt| is bold). | 159 // |MenuController| as the font returned by |GetLabelFontAt| is bold). |
| 162 if (model && model == [self recentTabsMenuModel] && | 160 if (model && model == [self recentTabsMenuModel] && |
| 163 model->GetLabelFontAt([item tag])) { | 161 model->GetLabelFontAt([item tag])) { |
| 164 DCHECK([menuItem attributedTitle]); | 162 DCHECK([menuItem attributedTitle]); |
| 165 scoped_nsobject<NSMutableAttributedString> title( | 163 base::scoped_nsobject<NSMutableAttributedString> title( |
| 166 [[NSMutableAttributedString alloc] initWithAttributedString: | 164 [[NSMutableAttributedString alloc] |
| 167 [menuItem attributedTitle]]); | 165 initWithAttributedString:[menuItem attributedTitle]]); |
| 168 [title addAttribute:NSForegroundColorAttributeName | 166 [title addAttribute:NSForegroundColorAttributeName |
| 169 value:[NSColor blackColor] | 167 value:[NSColor blackColor] |
| 170 range:NSMakeRange(0, [title length])]; | 168 range:NSMakeRange(0, [title length])]; |
| 171 [menuItem setAttributedTitle:title.get()]; | 169 [menuItem setAttributedTitle:title.get()]; |
| 172 } | 170 } |
| 173 | 171 |
| 174 return enabled; | 172 return enabled; |
| 175 } | 173 } |
| 176 | 174 |
| 177 - (NSMenu*)bookmarkSubMenu { | 175 - (NSMenu*)bookmarkSubMenu { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 controller_ = controller; | 395 controller_ = controller; |
| 398 } | 396 } |
| 399 return self; | 397 return self; |
| 400 } | 398 } |
| 401 | 399 |
| 402 - (IBAction)dispatchWrenchMenuCommand:(id)sender { | 400 - (IBAction)dispatchWrenchMenuCommand:(id)sender { |
| 403 [controller_ dispatchWrenchMenuCommand:sender]; | 401 [controller_ dispatchWrenchMenuCommand:sender]; |
| 404 } | 402 } |
| 405 | 403 |
| 406 @end // @implementation WrenchMenuButtonViewController | 404 @end // @implementation WrenchMenuButtonViewController |
| OLD | NEW |