Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Unified Diff: chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc

Issue 10806058: Move icon fallbacks into ExtensionAction. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Windows support Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
diff --git a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
index 5760d33e7eee1475c89ae81903a804f69812ca89..908de9b63e786bfb7f591480a3bdec5defb9962d 100644
--- a/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_actions_toolbar_gtk.cc
@@ -127,12 +127,6 @@ class BrowserActionButton : public content::NotificationObserver,
gfx::Size(Extension::kBrowserActionIconMaxSize,
Extension::kBrowserActionIconMaxSize),
ImageLoadingTracker::DONT_CACHE);
- } else {
- const SkBitmap* bm =
- ui::ResourceBundle::GetSharedInstance().GetImageNamed(
- IDR_EXTENSIONS_FAVICON).ToSkBitmap();
- default_skbitmap_ = *bm;
- default_icon_ = gfx::GdkPixbufFromSkBitmap(*bm);
}
UpdateState();
@@ -206,9 +200,7 @@ class BrowserActionButton : public content::NotificationObserver,
const std::string& extension_id,
int index) OVERRIDE {
if (!image.IsEmpty()) {
- default_skbitmap_ = *image.ToSkBitmap();
- default_icon_ =
- static_cast<GdkPixbuf*>(g_object_ref(image.ToGdkPixbuf()));
+ loaded_icons_[extension_->browser_action()->default_icon_path()] = image;
}
not at google - send to devlin 2012/07/26 02:29:44 nit: remove surrounding {}
Jeffrey Yasskin 2012/07/26 21:11:47 Done.
UpdateState();
}
@@ -226,15 +218,10 @@ class BrowserActionButton : public content::NotificationObserver,
else
gtk_widget_set_tooltip_text(button(), tooltip.c_str());
- SkBitmap image = extension_->browser_action()->GetIcon(tab_id);
- if (!image.isNull()) {
- GdkPixbuf* previous_gdk_icon = tab_specific_icon_;
- tab_specific_icon_ = gfx::GdkPixbufFromSkBitmap(image);
- SetImage(tab_specific_icon_);
- if (previous_gdk_icon)
- g_object_unref(previous_gdk_icon);
- } else if (default_icon_) {
- SetImage(default_icon_);
+ gfx::Image image = extension_->browser_action()->GetIcon(
+ tab_id, loaded_icons_);
+ if (!image.IsEmpty()) {
+ SetImage(image.ToGdkPixbuf());
}
not at google - send to devlin 2012/07/26 02:29:44 same nit
Jeffrey Yasskin 2012/07/26 21:11:47 Ah the perils of removing code. :)
bool enabled = extension_->browser_action()->GetIsVisible(tab_id);
gtk_widget_set_sensitive(button(), enabled);
@@ -243,13 +230,8 @@ class BrowserActionButton : public content::NotificationObserver,
}
SkBitmap GetIcon() {
- const SkBitmap& image = extension_->browser_action()->GetIcon(
- toolbar_->GetCurrentTabId());
- if (!image.isNull()) {
- return image;
- } else {
- return default_skbitmap_;
- }
+ return *extension_->browser_action()->GetIcon(
+ toolbar_->GetCurrentTabId(), loaded_icons_).ToSkBitmap();
}
MenuGtk* GetContextMenu() {
@@ -461,6 +443,9 @@ class BrowserActionButton : public content::NotificationObserver,
// If we are displaying a tab-specific icon, it will be here.
GdkPixbuf* tab_specific_icon_;
+ // Icons loaded from paths. Currently just the browser action's default icon.
+ ExtensionAction::PathToIconCache loaded_icons_;
+
// If the browser action has a default icon, it will be here.
GdkPixbuf* default_icon_;

Powered by Google App Engine
This is Rietveld 408576698