| 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/menu_controller.h" | 5 #import "chrome/browser/cocoa/menu_controller.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "app/menus/accelerator_cocoa.h" | 8 #include "app/menus/accelerator_cocoa.h" |
| 9 #include "app/menus/simple_menu_model.h" | 9 #include "app/menus/simple_menu_model.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 NSInteger modelIndex = [item tag]; | 137 NSInteger modelIndex = [item tag]; |
| 138 menus::MenuModel* model = | 138 menus::MenuModel* model = |
| 139 static_cast<menus::MenuModel*>( | 139 static_cast<menus::MenuModel*>( |
| 140 [[(id)item representedObject] pointerValue]); | 140 [[(id)item representedObject] pointerValue]); |
| 141 DCHECK(model); | 141 DCHECK(model); |
| 142 if (model) { | 142 if (model) { |
| 143 BOOL checked = model->IsItemCheckedAt(modelIndex); | 143 BOOL checked = model->IsItemCheckedAt(modelIndex); |
| 144 DCHECK([(id)item isKindOfClass:[NSMenuItem class]]); | 144 DCHECK([(id)item isKindOfClass:[NSMenuItem class]]); |
| 145 [(id)item setState:(checked ? NSOnState : NSOffState)]; | 145 [(id)item setState:(checked ? NSOnState : NSOffState)]; |
| 146 [(id)item setHidden:(!model->IsVisibleAt(modelIndex))]; |
| 146 if (model->IsLabelDynamicAt(modelIndex)) { | 147 if (model->IsLabelDynamicAt(modelIndex)) { |
| 147 NSString* label = | 148 NSString* label = |
| 148 l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex)); | 149 l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex)); |
| 149 [(id)item setTitle:label]; | 150 [(id)item setTitle:label]; |
| 150 } | 151 } |
| 151 return model->IsEnabledAt(modelIndex); | 152 return model->IsEnabledAt(modelIndex); |
| 152 } | 153 } |
| 153 return NO; | 154 return NO; |
| 154 } | 155 } |
| 155 | 156 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 175 if (useWithPopUpButtonCell_) { | 176 if (useWithPopUpButtonCell_) { |
| 176 scoped_nsobject<NSMenuItem> blankItem( | 177 scoped_nsobject<NSMenuItem> blankItem( |
| 177 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); | 178 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); |
| 178 [menu_ insertItem:blankItem atIndex:0]; | 179 [menu_ insertItem:blankItem atIndex:0]; |
| 179 } | 180 } |
| 180 } | 181 } |
| 181 return menu_.get(); | 182 return menu_.get(); |
| 182 } | 183 } |
| 183 | 184 |
| 184 @end | 185 @end |
| OLD | NEW |