Commit 8c549104 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Fix icon size for Sharing context menu entries

Before crrev.com/c/2232978 the icon size was hardcoded in MenuItemView,
but that CL changed it to respect the incoming vector icon size. We
can't modify the vector source so we need to set a size when using it.
This also cleans up the duplicated *WithIcon methods and unifies them to
a single one taking a ui::ImageModel instead.

Bug: 1109643
Change-Id: Ib78f683ffee672668c79397122a0e3f5725f58f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2369181Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801441}
parent 153f3a5a
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/context_menu_params.h" #include "content/public/browser/context_menu_params.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
namespace arc { namespace arc {
...@@ -101,7 +102,8 @@ void OpenWithMenu::ModelChanged(const std::vector<LinkHandlerInfo>& handlers) { ...@@ -101,7 +102,8 @@ void OpenWithMenu::ModelChanged(const std::vector<LinkHandlerInfo>& handlers) {
IDS_CONTENT_CONTEXT_OPEN_WITH_APP, it->second.name); IDS_CONTENT_CONTEXT_OPEN_WITH_APP, it->second.name);
proxy_->UpdateMenuItem(command_id, true, false, label); proxy_->UpdateMenuItem(command_id, true, false, label);
if (!it->second.icon.IsEmpty()) if (!it->second.icon.IsEmpty())
proxy_->UpdateMenuIcon(command_id, it->second.icon); proxy_->UpdateMenuIcon(command_id,
ui::ImageModel::FromImage(it->second.icon));
} }
} }
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "components/arc/session/arc_bridge_service.h" #include "components/arc/session/arc_bridge_service.h"
#include "components/renderer_context_menu/render_view_context_menu_proxy.h" #include "components/renderer_context_menu/render_view_context_menu_proxy.h"
#include "content/public/browser/context_menu_params.h" #include "content/public/browser/context_menu_params.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/image/image_skia_operations.h"
namespace arc { namespace arc {
...@@ -179,7 +180,7 @@ void StartSmartSelectionActionMenu::UpdateMenuIcon( ...@@ -179,7 +180,7 @@ void StartSmartSelectionActionMenu::UpdateMenuIcon(
void StartSmartSelectionActionMenu::SetMenuIcon(int command_id, void StartSmartSelectionActionMenu::SetMenuIcon(int command_id,
const gfx::ImageSkia& image) { const gfx::ImageSkia& image) {
proxy_->UpdateMenuIcon(command_id, gfx::Image(image)); proxy_->UpdateMenuIcon(command_id, ui::ImageModel::FromImageSkia(image));
} }
} // namespace arc } // namespace arc
...@@ -413,7 +413,8 @@ void DownloadShelfContextMenu::AddAutoOpenToMenu(ui::SimpleMenuModel* menu) { ...@@ -413,7 +413,8 @@ void DownloadShelfContextMenu::AddAutoOpenToMenu(ui::SimpleMenuModel* menu) {
DownloadCommands::ALWAYS_OPEN_TYPE, DownloadCommands::ALWAYS_OPEN_TYPE,
GetLabelForCommandId(DownloadCommands::ALWAYS_OPEN_TYPE), GetLabelForCommandId(DownloadCommands::ALWAYS_OPEN_TYPE),
ui::ImageModel::FromVectorIcon(vector_icons::kBusinessIcon, ui::ImageModel::FromVectorIcon(vector_icons::kBusinessIcon,
gfx::kChromeIconGrey, 16)); gfx::kChromeIconGrey,
ui::SimpleMenuModel::kDefaultIconSize));
} else { } else {
menu->AddCheckItem( menu->AddCheckItem(
DownloadCommands::ALWAYS_OPEN_TYPE, DownloadCommands::ALWAYS_OPEN_TYPE,
......
...@@ -63,25 +63,17 @@ void MockRenderViewContextMenu::AddMenuItem(int command_id, ...@@ -63,25 +63,17 @@ void MockRenderViewContextMenu::AddMenuItem(int command_id,
void MockRenderViewContextMenu::AddMenuItemWithIcon( void MockRenderViewContextMenu::AddMenuItemWithIcon(
int command_id, int command_id,
const base::string16& title, const base::string16& title,
const gfx::ImageSkia& image) { const ui::ImageModel& icon) {
MockMenuItem item; MockMenuItem item;
item.command_id = command_id; item.command_id = command_id;
item.enabled = observer_->IsCommandIdEnabled(command_id); item.enabled = observer_->IsCommandIdEnabled(command_id);
item.checked = false; item.checked = false;
item.hidden = false; item.hidden = false;
item.title = title; item.title = title;
item.icon = gfx::Image(image); item.icon = icon;
items_.push_back(item); items_.push_back(item);
} }
void MockRenderViewContextMenu::AddMenuItemWithIcon(
int command_id,
const base::string16& title,
const gfx::VectorIcon& icon) {
AddMenuItemWithIcon(command_id, title,
gfx::CreateVectorIcon(icon, gfx::kPlaceholderColor));
}
void MockRenderViewContextMenu::AddCheckItem(int command_id, void MockRenderViewContextMenu::AddCheckItem(int command_id,
const base::string16& title) { const base::string16& title) {
MockMenuItem item; MockMenuItem item;
...@@ -120,29 +112,19 @@ void MockRenderViewContextMenu::AddSubMenuWithStringIdAndIcon( ...@@ -120,29 +112,19 @@ void MockRenderViewContextMenu::AddSubMenuWithStringIdAndIcon(
int command_id, int command_id,
int message_id, int message_id,
ui::MenuModel* model, ui::MenuModel* model,
const gfx::ImageSkia& image) { const ui::ImageModel& icon) {
MockMenuItem item; MockMenuItem item;
item.command_id = command_id; item.command_id = command_id;
item.enabled = observer_->IsCommandIdEnabled(command_id); item.enabled = observer_->IsCommandIdEnabled(command_id);
item.checked = observer_->IsCommandIdChecked(command_id); item.checked = observer_->IsCommandIdChecked(command_id);
item.hidden = false; item.hidden = false;
item.title = l10n_util::GetStringUTF16(message_id); item.title = l10n_util::GetStringUTF16(message_id);
item.icon = gfx::Image(image); item.icon = icon;
items_.push_back(item); items_.push_back(item);
AppendSubMenuItems(model); AppendSubMenuItems(model);
} }
void MockRenderViewContextMenu::AddSubMenuWithStringIdAndIcon(
int command_id,
int message_id,
ui::MenuModel* model,
const gfx::VectorIcon& icon) {
AddSubMenuWithStringIdAndIcon(
command_id, message_id, model,
gfx::CreateVectorIcon(icon, gfx::kPlaceholderColor));
}
void MockRenderViewContextMenu::AppendSubMenuItems(ui::MenuModel* model) { void MockRenderViewContextMenu::AppendSubMenuItems(ui::MenuModel* model) {
// Add items in the submenu |model| to |items_| so that the items can be // Add items in the submenu |model| to |items_| so that the items can be
// updated later via the RenderViewContextMenuProxy interface. // updated later via the RenderViewContextMenuProxy interface.
...@@ -180,10 +162,10 @@ void MockRenderViewContextMenu::UpdateMenuItem(int command_id, ...@@ -180,10 +162,10 @@ void MockRenderViewContextMenu::UpdateMenuItem(int command_id,
} }
void MockRenderViewContextMenu::UpdateMenuIcon(int command_id, void MockRenderViewContextMenu::UpdateMenuIcon(int command_id,
const gfx::Image& image) { const ui::ImageModel& icon) {
for (auto& item : items_) { for (auto& item : items_) {
if (item.command_id == command_id) { if (item.command_id == command_id) {
item.icon = image; item.icon = icon;
return; return;
} }
} }
......
...@@ -12,8 +12,8 @@ ...@@ -12,8 +12,8 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/renderer_context_menu/render_view_context_menu_proxy.h" #include "components/renderer_context_menu/render_view_context_menu_proxy.h"
#include "ui/base/models/image_model.h"
#include "ui/base/models/simple_menu_model.h" #include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/image/image.h"
class PrefService; class PrefService;
class Profile; class Profile;
...@@ -39,7 +39,7 @@ class MockRenderViewContextMenu : public ui::SimpleMenuModel::Delegate, ...@@ -39,7 +39,7 @@ class MockRenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
bool checked; bool checked;
bool hidden; bool hidden;
base::string16 title; base::string16 title;
gfx::Image icon; ui::ImageModel icon;
}; };
explicit MockRenderViewContextMenu(bool incognito); explicit MockRenderViewContextMenu(bool incognito);
...@@ -54,10 +54,7 @@ class MockRenderViewContextMenu : public ui::SimpleMenuModel::Delegate, ...@@ -54,10 +54,7 @@ class MockRenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
void AddMenuItem(int command_id, const base::string16& title) override; void AddMenuItem(int command_id, const base::string16& title) override;
void AddMenuItemWithIcon(int command_id, void AddMenuItemWithIcon(int command_id,
const base::string16& title, const base::string16& title,
const gfx::ImageSkia& image) override; const ui::ImageModel& icon) override;
void AddMenuItemWithIcon(int command_id,
const base::string16& title,
const gfx::VectorIcon& icon) override;
void AddCheckItem(int command_id, const base::string16& title) override; void AddCheckItem(int command_id, const base::string16& title) override;
void AddSeparator() override; void AddSeparator() override;
void AddSubMenu(int command_id, void AddSubMenu(int command_id,
...@@ -66,16 +63,12 @@ class MockRenderViewContextMenu : public ui::SimpleMenuModel::Delegate, ...@@ -66,16 +63,12 @@ class MockRenderViewContextMenu : public ui::SimpleMenuModel::Delegate,
void AddSubMenuWithStringIdAndIcon(int command_id, void AddSubMenuWithStringIdAndIcon(int command_id,
int message_id, int message_id,
ui::MenuModel* model, ui::MenuModel* model,
const gfx::ImageSkia& image) override; const ui::ImageModel& icon) override;
void AddSubMenuWithStringIdAndIcon(int command_id,
int message_id,
ui::MenuModel* model,
const gfx::VectorIcon& icon) override;
void UpdateMenuItem(int command_id, void UpdateMenuItem(int command_id,
bool enabled, bool enabled,
bool hidden, bool hidden,
const base::string16& title) override; const base::string16& title) override;
void UpdateMenuIcon(int command_id, const gfx::Image& image) override; void UpdateMenuIcon(int command_id, const ui::ImageModel& icon) override;
void RemoveMenuItem(int command_id) override; void RemoveMenuItem(int command_id) override;
void RemoveAdjacentSeparators() override; void RemoveAdjacentSeparators() override;
void AddSpellCheckServiceItem(bool is_checked) override; void AddSpellCheckServiceItem(bool is_checked) override;
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "content/public/browser/storage_partition.h" #include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/gfx/text_constants.h" #include "ui/gfx/text_constants.h"
#include "ui/gfx/text_elider.h" #include "ui/gfx/text_elider.h"
...@@ -113,8 +115,10 @@ void QuickAnswersMenuObserver::InitMenu( ...@@ -113,8 +115,10 @@ void QuickAnswersMenuObserver::InitMenu(
// TODO(llin): Update the menu item after finalizing on the design. // TODO(llin): Update the menu item after finalizing on the design.
auto truncated_text = TruncateString(selected_text); auto truncated_text = TruncateString(selected_text);
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
proxy_->AddMenuItemWithIcon(IDC_CONTENT_CONTEXT_QUICK_ANSWERS_INLINE_QUERY, proxy_->AddMenuItemWithIcon(
truncated_text, kAssistantIcon); IDC_CONTENT_CONTEXT_QUICK_ANSWERS_INLINE_QUERY, truncated_text,
ui::ImageModel::FromVectorIcon(kAssistantIcon, /*color_id=*/-1,
ui::SimpleMenuModel::kDefaultIconSize));
#else #else
proxy_->AddMenuItem(IDC_CONTENT_CONTEXT_QUICK_ANSWERS_INLINE_QUERY, proxy_->AddMenuItem(IDC_CONTENT_CONTEXT_QUICK_ANSWERS_INLINE_QUERY,
truncated_text); truncated_text);
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "chrome/browser/sharing/sharing_constants.h" #include "chrome/browser/sharing/sharing_constants.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/sync_device_info/device_info.h" #include "components/sync_device_info/device_info.h"
#include "components/vector_icons/vector_icons.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
...@@ -78,7 +78,9 @@ void ClickToCallContextMenuObserver::BuildMenu( ...@@ -78,7 +78,9 @@ void ClickToCallContextMenuObserver::BuildMenu(
l10n_util::GetStringFUTF16( l10n_util::GetStringFUTF16(
IDS_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE, IDS_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_SINGLE_DEVICE,
base::UTF8ToUTF16(devices_[0]->client_name())), base::UTF8ToUTF16(devices_[0]->client_name())),
vector_icons::kCallIcon); ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::SimpleMenuModel::kDefaultIconSize));
#endif #endif
} else { } else {
BuildSubMenu(); BuildSubMenu();
...@@ -92,7 +94,10 @@ void ClickToCallContextMenuObserver::BuildMenu( ...@@ -92,7 +94,10 @@ void ClickToCallContextMenuObserver::BuildMenu(
proxy_->AddSubMenuWithStringIdAndIcon( proxy_->AddSubMenuWithStringIdAndIcon(
IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_MULTIPLE_DEVICES, IDC_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_MULTIPLE_DEVICES,
IDS_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_MULTIPLE_DEVICES, IDS_CONTENT_CONTEXT_SHARING_CLICK_TO_CALL_MULTIPLE_DEVICES,
sub_menu_model_.get(), vector_icons::kCallIcon); sub_menu_model_.get(),
ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::SimpleMenuModel::kDefaultIconSize));
#endif #endif
} }
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/sync_device_info/device_info.h" #include "components/sync_device_info/device_info.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/gfx/color_palette.h" #include "ui/gfx/color_palette.h"
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
...@@ -73,7 +74,9 @@ void SharedClipboardContextMenuObserver::InitMenu( ...@@ -73,7 +74,9 @@ void SharedClipboardContextMenuObserver::InitMenu(
l10n_util::GetStringFUTF16( l10n_util::GetStringFUTF16(
IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE, IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_SINGLE_DEVICE,
base::UTF8ToUTF16(devices_[0]->client_name())), base::UTF8ToUTF16(devices_[0]->client_name())),
controller_->GetVectorIcon()); ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::SimpleMenuModel::kDefaultIconSize));
#endif #endif
} else { } else {
BuildSubMenu(); BuildSubMenu();
...@@ -87,7 +90,10 @@ void SharedClipboardContextMenuObserver::InitMenu( ...@@ -87,7 +90,10 @@ void SharedClipboardContextMenuObserver::InitMenu(
proxy_->AddSubMenuWithStringIdAndIcon( proxy_->AddSubMenuWithStringIdAndIcon(
IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES, IDC_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES,
IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES, IDS_CONTENT_CONTEXT_SHARING_SHARED_CLIPBOARD_MULTIPLE_DEVICES,
sub_menu_model_.get(), controller_->GetVectorIcon()); sub_menu_model_.get(),
ui::ImageModel::FromVectorIcon(controller_->GetVectorIcon(),
/*color_id=*/-1,
ui::SimpleMenuModel::kDefaultIconSize));
#endif #endif
} }
} }
......
...@@ -209,17 +209,8 @@ void RenderViewContextMenuBase::AddMenuItem(int command_id, ...@@ -209,17 +209,8 @@ void RenderViewContextMenuBase::AddMenuItem(int command_id,
void RenderViewContextMenuBase::AddMenuItemWithIcon( void RenderViewContextMenuBase::AddMenuItemWithIcon(
int command_id, int command_id,
const base::string16& title, const base::string16& title,
const gfx::ImageSkia& image) { const ui::ImageModel& icon) {
menu_model_.AddItemWithIcon(command_id, title, menu_model_.AddItemWithIcon(command_id, title, icon);
ui::ImageModel::FromImageSkia(image));
}
void RenderViewContextMenuBase::AddMenuItemWithIcon(
int command_id,
const base::string16& title,
const gfx::VectorIcon& icon) {
menu_model_.AddItemWithIcon(command_id, title,
ui::ImageModel::FromVectorIcon(icon));
} }
void RenderViewContextMenuBase::AddCheckItem(int command_id, void RenderViewContextMenuBase::AddCheckItem(int command_id,
...@@ -241,18 +232,9 @@ void RenderViewContextMenuBase::AddSubMenuWithStringIdAndIcon( ...@@ -241,18 +232,9 @@ void RenderViewContextMenuBase::AddSubMenuWithStringIdAndIcon(
int command_id, int command_id,
int message_id, int message_id,
ui::MenuModel* model, ui::MenuModel* model,
const gfx::ImageSkia& image) { const ui::ImageModel& icon) {
menu_model_.AddSubMenuWithStringIdAndIcon( menu_model_.AddSubMenuWithStringIdAndIcon(command_id, message_id, model,
command_id, message_id, model, ui::ImageModel::FromImageSkia(image)); icon);
}
void RenderViewContextMenuBase::AddSubMenuWithStringIdAndIcon(
int command_id,
int message_id,
ui::MenuModel* model,
const gfx::VectorIcon& icon) {
menu_model_.AddSubMenuWithStringIdAndIcon(
command_id, message_id, model, ui::ImageModel::FromVectorIcon(icon));
} }
void RenderViewContextMenuBase::UpdateMenuItem(int command_id, void RenderViewContextMenuBase::UpdateMenuItem(int command_id,
...@@ -271,12 +253,12 @@ void RenderViewContextMenuBase::UpdateMenuItem(int command_id, ...@@ -271,12 +253,12 @@ void RenderViewContextMenuBase::UpdateMenuItem(int command_id,
} }
void RenderViewContextMenuBase::UpdateMenuIcon(int command_id, void RenderViewContextMenuBase::UpdateMenuIcon(int command_id,
const gfx::Image& image) { const ui::ImageModel& icon) {
int index = menu_model_.GetIndexOfCommandId(command_id); int index = menu_model_.GetIndexOfCommandId(command_id);
if (index == -1) if (index == -1)
return; return;
menu_model_.SetIcon(index, ui::ImageModel::FromImage(image)); menu_model_.SetIcon(index, icon);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
if (toolkit_delegate_) if (toolkit_delegate_)
toolkit_delegate_->RebuildMenu(); toolkit_delegate_->RebuildMenu();
......
...@@ -97,10 +97,7 @@ class RenderViewContextMenuBase : public ui::SimpleMenuModel::Delegate, ...@@ -97,10 +97,7 @@ class RenderViewContextMenuBase : public ui::SimpleMenuModel::Delegate,
void AddMenuItem(int command_id, const base::string16& title) override; void AddMenuItem(int command_id, const base::string16& title) override;
void AddMenuItemWithIcon(int command_id, void AddMenuItemWithIcon(int command_id,
const base::string16& title, const base::string16& title,
const gfx::ImageSkia& image) override; const ui::ImageModel& icon) override;
void AddMenuItemWithIcon(int command_id,
const base::string16& title,
const gfx::VectorIcon& icon) override;
void AddCheckItem(int command_id, const base::string16& title) override; void AddCheckItem(int command_id, const base::string16& title) override;
void AddSeparator() override; void AddSeparator() override;
void AddSubMenu(int command_id, void AddSubMenu(int command_id,
...@@ -109,16 +106,12 @@ class RenderViewContextMenuBase : public ui::SimpleMenuModel::Delegate, ...@@ -109,16 +106,12 @@ class RenderViewContextMenuBase : public ui::SimpleMenuModel::Delegate,
void AddSubMenuWithStringIdAndIcon(int command_id, void AddSubMenuWithStringIdAndIcon(int command_id,
int message_id, int message_id,
ui::MenuModel* model, ui::MenuModel* model,
const gfx::ImageSkia& image) override; const ui::ImageModel& icon) override;
void AddSubMenuWithStringIdAndIcon(int command_id,
int message_id,
ui::MenuModel* model,
const gfx::VectorIcon& icon) override;
void UpdateMenuItem(int command_id, void UpdateMenuItem(int command_id,
bool enabled, bool enabled,
bool hidden, bool hidden,
const base::string16& title) override; const base::string16& title) override;
void UpdateMenuIcon(int command_id, const gfx::Image& image) override; void UpdateMenuIcon(int command_id, const ui::ImageModel& icon) override;
void RemoveMenuItem(int command_id) override; void RemoveMenuItem(int command_id) override;
void RemoveAdjacentSeparators() override; void RemoveAdjacentSeparators() override;
content::RenderViewHost* GetRenderViewHost() const override; content::RenderViewHost* GetRenderViewHost() const override;
......
...@@ -13,13 +13,8 @@ class RenderViewHost; ...@@ -13,13 +13,8 @@ class RenderViewHost;
class WebContents; class WebContents;
} }
namespace gfx {
class Image;
class ImageSkia;
struct VectorIcon;
}
namespace ui { namespace ui {
class ImageModel;
class MenuModel; class MenuModel;
} }
...@@ -84,10 +79,7 @@ class RenderViewContextMenuProxy { ...@@ -84,10 +79,7 @@ class RenderViewContextMenuProxy {
virtual void AddMenuItem(int command_id, const base::string16& title) = 0; virtual void AddMenuItem(int command_id, const base::string16& title) = 0;
virtual void AddMenuItemWithIcon(int command_id, virtual void AddMenuItemWithIcon(int command_id,
const base::string16& title, const base::string16& title,
const gfx::ImageSkia& image) = 0; const ui::ImageModel& icon) = 0;
virtual void AddMenuItemWithIcon(int command_id,
const base::string16& title,
const gfx::VectorIcon& image) = 0;
virtual void AddCheckItem(int command_id, const base::string16& title) = 0; virtual void AddCheckItem(int command_id, const base::string16& title) = 0;
virtual void AddSeparator() = 0; virtual void AddSeparator() = 0;
...@@ -98,11 +90,7 @@ class RenderViewContextMenuProxy { ...@@ -98,11 +90,7 @@ class RenderViewContextMenuProxy {
virtual void AddSubMenuWithStringIdAndIcon(int command_id, virtual void AddSubMenuWithStringIdAndIcon(int command_id,
int message_id, int message_id,
ui::MenuModel* model, ui::MenuModel* model,
const gfx::ImageSkia& image) = 0; const ui::ImageModel& icon) = 0;
virtual void AddSubMenuWithStringIdAndIcon(int command_id,
int message_id,
ui::MenuModel* model,
const gfx::VectorIcon& image) = 0;
// Update the status and text of the specified context-menu item. // Update the status and text of the specified context-menu item.
virtual void UpdateMenuItem(int command_id, virtual void UpdateMenuItem(int command_id,
...@@ -111,7 +99,7 @@ class RenderViewContextMenuProxy { ...@@ -111,7 +99,7 @@ class RenderViewContextMenuProxy {
const base::string16& title) = 0; const base::string16& title) = 0;
// Update the icon of the specified context-menu item. // Update the icon of the specified context-menu item.
virtual void UpdateMenuIcon(int command_id, const gfx::Image& image) = 0; virtual void UpdateMenuIcon(int command_id, const ui::ImageModel& icon) = 0;
// Remove the specified context-menu item. // Remove the specified context-menu item.
virtual void RemoveMenuItem(int command_id) = 0; virtual void RemoveMenuItem(int command_id) = 0;
......
...@@ -27,6 +27,9 @@ class ButtonMenuItemModel; ...@@ -27,6 +27,9 @@ class ButtonMenuItemModel;
// The breadth of MenuModel is not exposed through this API. // The breadth of MenuModel is not exposed through this API.
class COMPONENT_EXPORT(UI_BASE) SimpleMenuModel : public MenuModel { class COMPONENT_EXPORT(UI_BASE) SimpleMenuModel : public MenuModel {
public: public:
// Default icon size to be used for context menus.
static constexpr int kDefaultIconSize = 16;
class COMPONENT_EXPORT(UI_BASE) Delegate : public AcceleratorProvider { class COMPONENT_EXPORT(UI_BASE) Delegate : public AcceleratorProvider {
public: public:
~Delegate() override {} ~Delegate() override {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment