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

Unified Diff: chrome/browser/cocoa/wrench_menu_controller.mm

Issue 3139003: Merge 55568 - [Mac] Insert the Update Chrome item to existing Wrench menus wh... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/wrench_menu_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/wrench_menu_controller.mm
===================================================================
--- chrome/browser/cocoa/wrench_menu_controller.mm (revision 55582)
+++ chrome/browser/cocoa/wrench_menu_controller.mm (working copy)
@@ -4,6 +4,7 @@
#import "chrome/browser/cocoa/wrench_menu_controller.h"
+#include "app/l10n_util.h"
#include "app/menus/menu_model.h"
#include "base/sys_string_conversions.h"
#include "chrome/app/chrome_dll_resource.h"
@@ -11,6 +12,8 @@
#include "chrome/browser/browser_window.h"
#import "chrome/browser/cocoa/toolbar_controller.h"
#include "chrome/browser/wrench_menu_model.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
@interface WrenchMenuController (Private)
- (WrenchMenuModel*)wrenchMenuModel;
@@ -110,6 +113,36 @@
return static_cast<WrenchMenuModel*>(model_);
}
+// Inserts the update available notification menu item.
+- (void)insertUpdateAvailableItem {
+ WrenchMenuModel* model = [self wrenchMenuModel];
+ // Don't insert the item multiple times.
+ if (!model || model->GetIndexOfCommandId(IDC_ABOUT) != -1)
+ return;
+
+ // Update the model manually because the model is static because other
+ // platforms always have an About item.
+ int index = model->GetIndexOfCommandId(IDC_OPTIONS) + 1;
+ model->InsertItemAt(index, IDC_ABOUT,
+ l10n_util::GetStringFUTF16(IDS_ABOUT,
+ l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
+
+ // The model does not broadcast change notifications to its delegate, so
+ // insert the actual menu item ourselves.
+ NSInteger menuIndex = [[self menu] indexOfItemWithTag:index];
+ [self addItemToMenu:[self menu]
+ atIndex:menuIndex
+ fromModel:model
+ modelIndex:index];
+
+ // Since the tag of each menu item is the index within the model, they need
+ // to be adjusted after insertion.
+ for (NSInteger i = menuIndex + 1; i < [[self menu] numberOfItems]; ++i) {
+ NSMenuItem* item = [[self menu] itemAtIndex:i];
+ [item setTag:[item tag] + 1];
+ }
+}
+
// Fit the localized strings into the Cut/Copy/Paste control, then resize the
// whole menu item accordingly.
- (void)adjustPositioning {
« 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