Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: chrome/browser/cocoa/menu_controller.mm

Issue 500030: Factor tab context menu into a shared model and fix mac and win to use it. Im... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // 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/simple_menu_model.h" 8 #include "app/menus/simple_menu_model.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 [item setTarget:nil]; 89 [item setTarget:nil];
90 [item setAction:nil]; 90 [item setAction:nil];
91 menus::MenuModel* submenuModel = model->GetSubmenuModelAt(modelIndex); 91 menus::MenuModel* submenuModel = model->GetSubmenuModelAt(modelIndex);
92 NSMenu* submenu = 92 NSMenu* submenu =
93 [self menuFromModel:(menus::SimpleMenuModel*)submenuModel]; 93 [self menuFromModel:(menus::SimpleMenuModel*)submenuModel];
94 [item setSubmenu:submenu]; 94 [item setSubmenu:submenu];
95 } else { 95 } else {
96 // The MenuModel works on indexes so we can't just set the command id as the 96 // The MenuModel works on indexes so we can't just set the command id as the
97 // tag like we do in other menus. Also set the represented object to be 97 // tag like we do in other menus. Also set the represented object to be
98 // the model so hierarchical menus check the correct index in the correct 98 // the model so hierarchical menus check the correct index in the correct
99 // model. 99 // model. Setting the target to |self| allows this class to participate
100 // in validation of the menu items.
100 [item setTag:modelIndex]; 101 [item setTag:modelIndex];
101 [item setTarget:self]; 102 [item setTarget:self];
102 NSValue* modelObject = [NSValue valueWithPointer:model]; 103 NSValue* modelObject = [NSValue valueWithPointer:model];
103 [item setRepresentedObject:modelObject]; // Retains |modelObject|. 104 [item setRepresentedObject:modelObject]; // Retains |modelObject|.
104 } 105 }
105 [menu insertItem:item atIndex:index]; 106 [menu insertItem:item atIndex:index];
106 } 107 }
107 108
108 // Called before the menu is to be displayed to update the state (enabled, 109 // Called before the menu is to be displayed to update the state (enabled,
109 // radio, etc) of each item in the menu. 110 // radio, etc) of each item in the menu.
(...skipping 26 matching lines...) Expand all
136 DCHECK(model); 137 DCHECK(model);
137 if (model); 138 if (model);
138 model->ActivatedAt(modelIndex); 139 model->ActivatedAt(modelIndex);
139 } 140 }
140 141
141 - (NSMenu*)menu { 142 - (NSMenu*)menu {
142 return menu_.get(); 143 return menu_.get();
143 } 144 }
144 145
145 @end 146 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698