summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 23:20:15 +0000
committerasargent@chromium.org <asargent@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-24 23:20:15 +0000
commit06a0c94e817354c8c12afe4748ce68a418b0ed1b (patch)
tree44a301796ccb8a0808eb77b10292de60cf04fcf4 /chrome/browser/tab_contents
parent8ab402196ee4dc510e0162010789d43b96b54243 (diff)
downloadchromium_src-06a0c94e817354c8c12afe4748ce68a418b0ed1b.zip
chromium_src-06a0c94e817354c8c12afe4748ce68a418b0ed1b.tar.gz
chromium_src-06a0c94e817354c8c12afe4748ce68a418b0ed1b.tar.bz2
Show extension icons next to their top-level context menu items.
Also fix a bug in extension icon caching where we weren't keeping track of potential resizing done by ImageLoadingTracker before setting the cached SkBitmap. BUG=39494 TEST=Install an extension that includes an icon and uses the experimental context menu API. You should see the extension's icon in the context menu next to its top-level item. Review URL: http://codereview.chromium.org/2867008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50779 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.