Chromium Code Reviews| Index: chrome/browser/ui/ash/launcher/launcher_context_menu.cc |
| diff --git a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc |
| index ca1b3ca08a92df0052c616e1ac7d73b326c15cb6..11c86bb0204879eb6cc32a1f7a86002518044b37 100644 |
| --- a/chrome/browser/ui/ash/launcher/launcher_context_menu.cc |
| +++ b/chrome/browser/ui/ash/launcher/launcher_context_menu.cc |
| @@ -7,18 +7,31 @@ |
| #include "ash/launcher/launcher_context_menu.h" |
| #include "ash/shell.h" |
| #include "base/command_line.h" |
| +#include "chrome/browser/extensions/context_menu_matcher.h" |
| #include "chrome/browser/extensions/extension_prefs.h" |
| #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| #include "chrome/common/chrome_switches.h" |
| +#include "content/public/common/context_menu_params.h" |
| #include "grit/ash_strings.h" |
| #include "grit/generated_resources.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +namespace { |
| + |
| +bool MenuItemHasLauncherContext(const extensions::MenuItem* item) { |
| + return item->contexts().Contains(extensions::MenuItem::LAUNCHER); |
| +} |
| + |
| +} // namespace |
| + |
| LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, |
| const ash::LauncherItem* item) |
| : ui::SimpleMenuModel(NULL), |
| controller_(controller), |
| - item_(item ? *item : ash::LauncherItem()) { |
| + item_(item ? *item : ash::LauncherItem()), |
| + extension_items_(new extensions::ContextMenuMatcher( |
|
sky
2012/09/21 23:30:01
Having code specific to the item type isn't going
Marijn Kruisselbrink
2012/09/22 01:01:19
A potential problem I see with that is that it see
|
| + controller->profile(), this, this, |
| + base::Bind(MenuItemHasLauncherContext))) { |
| set_delegate(this); |
| if (is_valid_item()) { |
| @@ -56,6 +69,11 @@ LauncherContextMenu::LauncherContextMenu(ChromeLauncherController* controller, |
| } else { |
| AddItem(MENU_OPEN, controller->GetTitle(item_)); |
| if (item_.type == ash::TYPE_PLATFORM_APP) { |
| + int index = 0; |
| + extension_items_->AppendExtensionItems( |
| + controller->GetAppIDForLauncherID(item_.id), string16(), &index); |
| + if (index > 0) |
| + AddSeparator(ui::NORMAL_SEPARATOR); |
| AddItem( |
| MENU_PIN, |
| l10n_util::GetStringUTF16(IDS_LAUNCHER_CONTEXT_MENU_PIN)); |
| @@ -97,7 +115,7 @@ bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { |
| case MENU_AUTO_HIDE: |
| return ash::LauncherContextMenu::IsAutoHideMenuHideChecked(); |
| default: |
| - return false; |
| + return extension_items_->IsCommandIdChecked(command_id); |
| } |
| } |
| @@ -107,7 +125,7 @@ bool LauncherContextMenu::IsCommandIdEnabled(int command_id) const { |
| return item_.type == ash::TYPE_PLATFORM_APP || |
| controller_->IsPinnable(item_.id); |
| default: |
| - return true; |
| + return extension_items_->IsCommandIdEnabled(command_id); |
| } |
| } |
| @@ -156,5 +174,8 @@ void LauncherContextMenu::ExecuteCommand(int command_id) { |
| break; |
| case MENU_ALIGNMENT_MENU: |
| break; |
| + default: |
| + extension_items_->ExecuteCommand(command_id, |
| + content::ContextMenuParams()); |
| } |
| } |