summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 07:25:52 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-25 07:25:52 +0000
commit052c92700b2c71e60ab89e765467b9b0926d0f7c (patch)
treecc5181425481f5728bdcdda9933449007bd64b46 /chrome/browser/tab_contents
parent16f17f5edd89d6b6a41709a9946a0183f5754c35 (diff)
downloadchromium_src-052c92700b2c71e60ab89e765467b9b0926d0f7c.zip
chromium_src-052c92700b2c71e60ab89e765467b9b0926d0f7c.tar.gz
chromium_src-052c92700b2c71e60ab89e765467b9b0926d0f7c.tar.bz2
Revert "Revert "Show extension icons next to their top-level context menu items.""
This reverts r50828 as the error is already suppressed r50793. TBR=asargent Review URL: http://codereview.chromium.org/2844028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc16
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index ef4e6d7..aaed42e 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -41,6 +41,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "gfx/favicon_size.h"
#include "grit/generated_resources.h"
#include "net/base/escape.h"
#include "net/url_request/url_request.h"
@@ -195,6 +196,7 @@ void RenderViewContextMenu::AppendExtensionItems(
menu_model_.AddSubMenu(menu_id, title, submenu);
RecursivelyAppendExtensionItems(submenu_items, submenu, index);
}
+ SetExtensionIcon(extension_id);
}
void RenderViewContextMenu::RecursivelyAppendExtensionItems(
@@ -253,6 +255,20 @@ void RenderViewContextMenu::RecursivelyAppendExtensionItems(
}
}
+void RenderViewContextMenu::SetExtensionIcon(const std::string& extension_id) {
+ ExtensionsService* service = profile_->GetExtensionsService();
+ ExtensionMenuManager* menu_manager = service->menu_manager();
+
+ int index = menu_model_.GetItemCount() - 1;
+ DCHECK(index >= 0);
+
+ const SkBitmap& icon = menu_manager->GetIconForExtension(extension_id);
+ DCHECK(icon.width() == kFavIconSize);
+ DCHECK(icon.height() == kFavIconSize);
+
+ menu_model_.SetIcon(index, icon);
+}
+
void RenderViewContextMenu::AppendAllExtensionItems() {
extension_item_map_.clear();
ExtensionsService* service = profile_->GetExtensionsService();
diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h
index 97d0d5c..2874aee 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.h
+++ b/chrome/browser/tab_contents/render_view_context_menu.h
@@ -91,6 +91,8 @@ class RenderViewContextMenu : public menus::SimpleMenuModel::Delegate {
const std::vector<ExtensionMenuItem*>& items,
menus::SimpleMenuModel* menu_model,
int *index);
+ // This will set the icon on the most recently-added item in the menu_model_.
+ void SetExtensionIcon(const std::string& extension_id);
// Opens the specified URL string in a new tab. If |in_current_window| is
// false, a new window is created to hold the new tab.