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

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

Issue 3455027: [Mac] Do not insert an "About Chrome" item when the Wrench menu shows an available update. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 2 months 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
« no previous file with comments | « chrome/browser/cocoa/wrench_menu_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/wrench_menu_controller.h" 5 #import "chrome/browser/cocoa/wrench_menu_controller.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/menus/menu_model.h" 8 #include "app/menus/menu_model.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #include "chrome/app/chrome_dll_resource.h" 10 #include "chrome/app/chrome_dll_resource.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 162
163 // Used to perform the actual dispatch on the outermost runloop. 163 // Used to perform the actual dispatch on the outermost runloop.
164 - (void)performCommandDispatch:(NSNumber*)tag { 164 - (void)performCommandDispatch:(NSNumber*)tag {
165 [self wrenchMenuModel]->ExecuteCommand([tag intValue]); 165 [self wrenchMenuModel]->ExecuteCommand([tag intValue]);
166 } 166 }
167 167
168 - (WrenchMenuModel*)wrenchMenuModel { 168 - (WrenchMenuModel*)wrenchMenuModel {
169 return static_cast<WrenchMenuModel*>(model_); 169 return static_cast<WrenchMenuModel*>(model_);
170 } 170 }
171 171
172 // Inserts the update available notification menu item.
173 - (void)insertUpdateAvailableItem {
174 WrenchMenuModel* model = [self wrenchMenuModel];
175 // Don't insert the item multiple times.
176 if (!model || model->GetIndexOfCommandId(IDC_ABOUT) != -1)
177 return;
178
179 // Update the model manually because the model is static because other
180 // platforms always have an About item.
181 int index = model->GetIndexOfCommandId(IDC_OPTIONS) + 1;
182 model->InsertItemAt(index, IDC_ABOUT,
183 l10n_util::GetStringFUTF16(IDS_ABOUT,
184 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
185
186 // The model does not broadcast change notifications to its delegate, so
187 // insert the actual menu item ourselves.
188 NSInteger menuIndex = [[self menu] indexOfItemWithTag:index];
189 [self addItemToMenu:[self menu]
190 atIndex:menuIndex
191 fromModel:model
192 modelIndex:index];
193
194 // Since the tag of each menu item is the index within the model, they need
195 // to be adjusted after insertion.
196 for (NSInteger i = menuIndex + 1; i < [[self menu] numberOfItems]; ++i) {
197 NSMenuItem* item = [[self menu] itemAtIndex:i];
198 [item setTag:[item tag] + 1];
199 }
200 }
201
202 // Fit the localized strings into the Cut/Copy/Paste control, then resize the 172 // Fit the localized strings into the Cut/Copy/Paste control, then resize the
203 // whole menu item accordingly. 173 // whole menu item accordingly.
204 - (void)adjustPositioning { 174 - (void)adjustPositioning {
205 const CGFloat kButtonPadding = 12; 175 const CGFloat kButtonPadding = 12;
206 CGFloat delta = 0; 176 CGFloat delta = 0;
207 177
208 // Go through the three buttons from right-to-left, adjusting the size to fit 178 // Go through the three buttons from right-to-left, adjusting the size to fit
209 // the localized strings while keeping them all aligned on their horizontal 179 // the localized strings while keeping them all aligned on their horizontal
210 // edges. 180 // edges.
211 const size_t kAdjustViewCount = 3; 181 const size_t kAdjustViewCount = 3;
(...skipping 28 matching lines...) Expand all
240 parentFrame.size.width += delta; 210 parentFrame.size.width += delta;
241 parentFrame.origin.x -= delta; 211 parentFrame.origin.x -= delta;
242 [[editCut_ superview] setFrame:parentFrame]; 212 [[editCut_ superview] setFrame:parentFrame];
243 } 213 }
244 214
245 - (NSButton*)zoomDisplay { 215 - (NSButton*)zoomDisplay {
246 return zoomDisplay_; 216 return zoomDisplay_;
247 } 217 }
248 218
249 @end // @implementation WrenchMenuController 219 @end // @implementation WrenchMenuController
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/wrench_menu_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698