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/ui/cocoa/menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/menu_controller.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
10 #include "skia/ext/skia_utils_mac.h" | 10 #include "skia/ext/skia_utils_mac.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 static_cast<ui::MenuModel*>( | 168 static_cast<ui::MenuModel*>( |
169 [[sender representedObject] pointerValue]); | 169 [[sender representedObject] pointerValue]); |
170 DCHECK(model); | 170 DCHECK(model); |
171 if (model) | 171 if (model) |
172 model->ActivatedAt(modelIndex); | 172 model->ActivatedAt(modelIndex); |
173 } | 173 } |
174 | 174 |
175 - (NSMenu*)menu { | 175 - (NSMenu*)menu { |
176 if (!menu_ && model_) { | 176 if (!menu_ && model_) { |
177 menu_.reset([[self menuFromModel:model_] retain]); | 177 menu_.reset([[self menuFromModel:model_] retain]); |
| 178 [menu_ setDelegate:self]; |
178 // If this is to be used with a NSPopUpButtonCell, add an item at the 0th | 179 // If this is to be used with a NSPopUpButtonCell, add an item at the 0th |
179 // position that's empty. Doing it after the menu has been constructed won't | 180 // position that's empty. Doing it after the menu has been constructed won't |
180 // complicate creation logic, and since the tags are model indexes, they | 181 // complicate creation logic, and since the tags are model indexes, they |
181 // are unaffected by the extra item. | 182 // are unaffected by the extra item. |
182 if (useWithPopUpButtonCell_) { | 183 if (useWithPopUpButtonCell_) { |
183 scoped_nsobject<NSMenuItem> blankItem( | 184 scoped_nsobject<NSMenuItem> blankItem( |
184 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); | 185 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); |
185 [menu_ insertItem:blankItem atIndex:0]; | 186 [menu_ insertItem:blankItem atIndex:0]; |
186 } | 187 } |
187 } | 188 } |
188 return menu_.get(); | 189 return menu_.get(); |
189 } | 190 } |
190 | 191 |
| 192 - (void)menuDidClose:(NSMenu*)menu { |
| 193 model_->MenuClosed(); |
| 194 } |
| 195 |
191 @end | 196 @end |
OLD | NEW |