Chromium Code Reviews| Index: chrome/browser/ui/app_list/extension_app_item.cc |
| diff --git a/chrome/browser/ui/app_list/extension_app_item.cc b/chrome/browser/ui/app_list/extension_app_item.cc |
| index 079973fbc16c9a5238e54a0390110ce175e76c9f..eb0cd447873be75a00cc6d84f2802921998ddaf7 100644 |
| --- a/chrome/browser/ui/app_list/extension_app_item.cc |
| +++ b/chrome/browser/ui/app_list/extension_app_item.cc |
| @@ -5,6 +5,8 @@ |
| #include "chrome/browser/ui/app_list/extension_app_item.h" |
| #include "base/utf_string_conversions.h" |
| +#include "chrome/app/chrome_command_ids.h" |
| +#include "chrome/browser/extensions/context_menu_manager.h" |
| #include "chrome/browser/extensions/extension_prefs.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| #include "chrome/browser/extensions/extension_system.h" |
| @@ -19,6 +21,7 @@ |
| #include "chrome/common/extensions/extension.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| #include "chrome/common/extensions/extension_icon_set.h" |
| +#include "content/public/common/context_menu_params.h" |
| #include "grit/chromium_strings.h" |
| #include "grit/generated_resources.h" |
| #include "ui/base/l10n/l10n_util.h" |
| @@ -211,6 +214,9 @@ bool ExtensionAppItem::IsCommandIdChecked(int command_id) const { |
| if (command_id >= LAUNCH_TYPE_START && command_id < LAUNCH_TYPE_LAST) { |
| return static_cast<int>(GetExtensionLaunchType(profile_, extension_id_)) + |
| LAUNCH_TYPE_START == command_id; |
| + } else if (command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| + command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
| + return context_menu_manager_->IsCommandIdChecked(command_id); |
| } |
| return false; |
| } |
| @@ -231,6 +237,9 @@ bool ExtensionAppItem::IsCommandIdEnabled(int command_id) const { |
| } else if (command_id == DETAILS) { |
| const Extension* extension = GetExtension(); |
| return extension && extension->from_webstore(); |
| + } else if (command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| + command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
| + return context_menu_manager_->IsCommandIdEnabled(command_id); |
| } |
| return true; |
| } |
| @@ -261,6 +270,12 @@ void ExtensionAppItem::ExecuteCommand(int command_id) { |
| StartExtensionUninstall(); |
| } else if (command_id == DETAILS) { |
| ShowExtensionDetails(); |
| + } else if (command_id >= IDC_EXTENSIONS_CONTEXT_CUSTOM_FIRST && |
| + command_id <= IDC_EXTENSIONS_CONTEXT_CUSTOM_LAST) { |
| + content::ContextMenuParams params; |
| + // TODO(mek): maybe make page_url not required? |
|
asargent_no_longer_on_chrome
2012/09/10 20:25:20
Yeah, I think it would be good to make page_url be
Marijn Kruisselbrink
2012/09/10 23:16:57
Done.
|
| + params.page_url = GURL("about:blank"); |
| + context_menu_manager_->ExecuteCommand(command_id, params); |
| } |
| } |
| @@ -279,7 +294,16 @@ ui::MenuModel* ExtensionAppItem::GetContextMenuModel() { |
| if (!context_menu_model_.get()) { |
| context_menu_model_.reset(new ui::SimpleMenuModel(this)); |
| + context_menu_manager_.reset(new extensions::ContextMenuManager( |
| + profile_, this, context_menu_model_.get(), |
| + base::Bind(extensions::ContextMenuManager::ContextIsLauncher))); |
| + |
| context_menu_model_->AddItem(LAUNCH, UTF8ToUTF16(title())); |
| + |
| + int index = 0; |
| + context_menu_manager_->AppendExtensionItems(extension_id_, string16(), |
| + &index); |
| + |
| context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); |
| context_menu_model_->AddItemWithStringId( |
| TOGGLE_PIN, |