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

Unified Diff: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm

Issue 864153003: Added 'Find'/'Paste and Match Style' menu items for hosted apps on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated comments Created 5 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
diff --git a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
index 6b02afd143884f37d3574a24baff44668fec413b..68da7ea816fb3c26f5c4408917f37f66bfe53927 100644
--- a/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
+++ b/chrome/browser/ui/cocoa/apps/app_shim_menu_controller_mac.mm
@@ -75,6 +75,28 @@ void RemoveMenuItemWithTag(NSMenuItem* top_level_item,
[submenu removeItem:nextItem];
}
+void HideMenuItemWithTag(NSMenuItem* top_level_item,
+ NSInteger item_tag,
+ bool hidden) {
+ NSMenu* submenu = [top_level_item submenu];
+ NSMenuItem* menuItem = [submenu itemWithTag:item_tag];
+ NSInteger nextIndex = [submenu indexOfItem:menuItem] + 1;
+
+ // If no menu item proceeds the current one, then hide it and return.
+ if (nextIndex >= [submenu numberOfItems]) {
+ [menuItem setHidden:hidden];
+ return;
+ }
+
+ NSMenuItem* nextMenuItem = [submenu itemAtIndex:nextIndex];
+ if ([nextMenuItem isAlternate]) {
tapted 2015/01/27 01:40:57 Maybe http://stackoverflow.com/questions/11494509/
+ [nextMenuItem setAlternate:!hidden];
+ [nextMenuItem setHidden:hidden];
+ }
+
+ [menuItem setHidden:hidden];
+}
+
} // namespace
// Used by AppShimMenuController to manage menu items that are a copy of a
@@ -270,14 +292,10 @@ void RemoveMenuItemWithTag(NSMenuItem* top_level_item,
[closeWindowMenuItem setKeyEquivalent:@"w"];
[closeWindowMenuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
- // Edit menu. This copies the menu entirely and removes
- // "Paste and Match Style" and "Find". This is because the last two items,
- // "Start Dictation" and "Special Characters" are added by OSX, so we can't
- // copy them explicitly.
+ // Edit menu. We copy the menu because the last two items, "Start Dictation"
+ // and "Special Characters" are added by OSX, so we can't copy them
+ // explicitly.
editMenuItem_.reset([[[NSApp mainMenu] itemWithTag:IDC_EDIT_MENU] copy]);
- RemoveMenuItemWithTag(editMenuItem_,
- IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, NO);
- RemoveMenuItemWithTag(editMenuItem_, IDC_FIND_MENU, NO);
// View menu. Remove "Always Show Bookmark Bar" and separator.
viewMenuItem_.reset([[[NSApp mainMenu] itemWithTag:IDC_VIEW_MENU] copy]);
@@ -379,7 +397,20 @@ void RemoveMenuItemWithTag(NSMenuItem* top_level_item,
[mainMenu addItem:appMenuItem_];
[mainMenu addItem:fileMenuItem_];
+
+ // Hide the "Paste and Match Style" and "Find" menu items for non-hosted
+ // apps from the Edit menu.
+ if (!app->is_hosted_app()) {
+ HideMenuItemWithTag(editMenuItem_,
+ IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, YES);
+ HideMenuItemWithTag(editMenuItem_, IDC_FIND_MENU, YES);
+ } else {
+ HideMenuItemWithTag(editMenuItem_,
+ IDC_CONTENT_CONTEXT_PASTE_AND_MATCH_STYLE, NO);
+ HideMenuItemWithTag(editMenuItem_, IDC_FIND_MENU, NO);
+ }
[mainMenu addItem:editMenuItem_];
+
if (app->is_hosted_app()) {
[mainMenu addItem:viewMenuItem_];
[mainMenu addItem:historyMenuItem_];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698