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

Unified Diff: chrome/browser/extensions/context_menu_matcher.cc

Issue 12299013: Fix top-level context menus sorting by name (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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
Index: chrome/browser/extensions/context_menu_matcher.cc
===================================================================
--- chrome/browser/extensions/context_menu_matcher.cc (revision 182231)
+++ chrome/browser/extensions/context_menu_matcher.cc (working copy)
@@ -98,6 +98,35 @@
extension_menu_models_.clear();
}
+std::string ContextMenuMatcher::GetTopLevelContextMenuTitle(
Yoyo Zhou 2013/02/19 19:00:50 This duplicates code in AppendExtensionItems. Can
François Beaufort 2013/02/20 11:32:06 I'm not sure about how to implement the private fu
Yoyo Zhou 2013/03/06 20:18:58 I was thinking it should take an extension_id as i
+ const std::string& extension_id,
+ const string16& selection_text) {
+ ExtensionService* service =
+ extensions::ExtensionSystem::Get(profile_)->extension_service();
+ MenuManager* manager = service->menu_manager();
+ const Extension* extension = service->GetExtensionById(extension_id, false);
+
+ // Find matching items.
+ const MenuItem::List* all_items = manager->MenuItems(extension_id);
+ if (!all_items || all_items->empty())
+ // Return extension name if there are no items
Yoyo Zhou 2013/02/19 19:00:50 Shouldn't this function never be called for extens
François Beaufort 2013/02/20 11:32:06 Done.
+ return extension->name();
+ bool can_cross_incognito = service->CanCrossIncognito(extension);
+ MenuItem::List items = GetRelevantExtensionItems(*all_items,
+ can_cross_incognito);
+
+ std::string title;
+
+ if (items.size() > 1 || items[0]->type() != MenuItem::NORMAL) {
+ title = extension->name();
+ } else {
+ MenuItem* item = items[0];
+ title = UTF16ToUTF8(item->TitleWithReplacement(selection_text,
+ kMaxExtensionItemTitleLength));
Yoyo Zhou 2013/02/19 19:00:50 nit: if you continue function arguments onto the n
François Beaufort 2013/02/20 11:32:06 Done.
+ }
+ return title;
+}
+
bool ContextMenuMatcher::IsCommandIdChecked(int command_id) const {
MenuItem* item = GetExtensionMenuItem(command_id);
if (!item)

Powered by Google App Engine
This is Rietveld 408576698