Commit 15fa9ef8 authored by jennb@chromium.org's avatar jennb@chromium.org

Change panels to use gfx::Image instead of SkBitmap for favicon.

Completes a TODO added in r149891.

BUG=None
TEST=open panels and verify favicons look correct


Review URL: https://chromiumcodereview.appspot.com/10827259

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151668 0039d316-1c4b-4281-b951-d872f2087c98
parent 0a4494f3
...@@ -570,7 +570,8 @@ string16 TaskManagerPanelResource::GetProfileName() const { ...@@ -570,7 +570,8 @@ string16 TaskManagerPanelResource::GetProfileName() const {
} }
gfx::ImageSkia TaskManagerPanelResource::GetIcon() const { gfx::ImageSkia TaskManagerPanelResource::GetIcon() const {
return panel_->GetCurrentPageIcon(); gfx::Image icon = panel_->GetCurrentPageIcon();
return icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia();
} }
WebContents* TaskManagerPanelResource::GetWebContents() const { WebContents* TaskManagerPanelResource::GetWebContents() const {
......
...@@ -4,12 +4,15 @@ ...@@ -4,12 +4,15 @@
#include "chrome/browser/ui/panels/old_panel.h" #include "chrome/browser/ui/panels/old_panel.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_command_controller.h" #include "chrome/browser/ui/browser_command_controller.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/panels/panel_browser_window.h" #include "chrome/browser/ui/panels/panel_browser_window.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "ui/gfx/image/image.h"
OldPanel::OldPanel(Browser* browser, OldPanel::OldPanel(Browser* browser,
const gfx::Size& min_size, const gfx::Size& max_size) const gfx::Size& min_size, const gfx::Size& max_size)
...@@ -58,6 +61,9 @@ void OldPanel::ExecuteCommandWithDisposition( ...@@ -58,6 +61,9 @@ void OldPanel::ExecuteCommandWithDisposition(
chrome::ExecuteCommandWithDisposition(browser_, id, disposition); chrome::ExecuteCommandWithDisposition(browser_, id, disposition);
} }
SkBitmap OldPanel::GetCurrentPageIcon() const { gfx::Image OldPanel::GetCurrentPageIcon() const {
return browser_->GetCurrentPageIcon(); // Browser has not been changed to return SkBitmap yet so we get the favicon
// directly rather than use browser_->GetCurrentPageIcon().
TabContents* contents = chrome::GetActiveTabContents(browser_);
return contents ? contents->favicon_tab_helper()->GetFavicon() : gfx::Image();
} }
...@@ -30,7 +30,7 @@ class OldPanel : public Panel { ...@@ -30,7 +30,7 @@ class OldPanel : public Panel {
virtual void ExecuteCommandWithDisposition( virtual void ExecuteCommandWithDisposition(
int id, int id,
WindowOpenDisposition disposition) OVERRIDE; WindowOpenDisposition disposition) OVERRIDE;
virtual SkBitmap GetCurrentPageIcon() const OVERRIDE; virtual gfx::Image GetCurrentPageIcon() const OVERRIDE;
private: private:
Browser* browser_; // Weak pointer. Owned by native panel. Browser* browser_; // Weak pointer. Owned by native panel.
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/user_metrics.h" #include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
using content::RenderViewHost; using content::RenderViewHost;
...@@ -750,7 +750,7 @@ void Panel::FormatTitleForDisplay(string16* title) { ...@@ -750,7 +750,7 @@ void Panel::FormatTitleForDisplay(string16* title) {
} }
} }
SkBitmap Panel::GetCurrentPageIcon() const { gfx::Image Panel::GetCurrentPageIcon() const {
return panel_host_->GetPageIcon(); return panel_host_->GetPageIcon();
} }
......
...@@ -26,7 +26,6 @@ class PanelHost; ...@@ -26,7 +26,6 @@ class PanelHost;
class PanelManager; class PanelManager;
class PanelStrip; class PanelStrip;
class Profile; class Profile;
class SkBitmap;
namespace content { namespace content {
class WebContents; class WebContents;
...@@ -37,6 +36,10 @@ namespace extensions { ...@@ -37,6 +36,10 @@ namespace extensions {
class WindowController; class WindowController;
} }
namespace gfx {
class Image;
}
// A platform independent implementation of BaseWindow for Panels. // A platform independent implementation of BaseWindow for Panels.
// This class gets the first crack at all the BaseWindow calls for Panels and // This class gets the first crack at all the BaseWindow calls for Panels and
// does one or more of the following: // does one or more of the following:
...@@ -291,7 +294,7 @@ class Panel : public BaseWindow, ...@@ -291,7 +294,7 @@ class Panel : public BaseWindow,
string16 GetWindowTitle() const; string16 GetWindowTitle() const;
// Gets the Favicon of the web contents. // Gets the Favicon of the web contents.
virtual SkBitmap GetCurrentPageIcon() const; virtual gfx::Image GetCurrentPageIcon() const;
// Updates the title bar to display the current title and icon. // Updates the title bar to display the current title and icon.
void UpdateTitleBar(); void UpdateTitleBar();
......
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_compat.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/skia_utils_gtk.h" #include "ui/gfx/skia_utils_gtk.h"
namespace { namespace {
...@@ -235,15 +235,14 @@ void PanelBrowserTitlebarGtk::UpdateThrobber( ...@@ -235,15 +235,14 @@ void PanelBrowserTitlebarGtk::UpdateThrobber(
} else { } else {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
SkBitmap icon = browser_window_->panel()->GetCurrentPageIcon(); gfx::Image icon = browser_window_->panel()->GetCurrentPageIcon();
if (icon.empty()) { if (icon.IsEmpty()) {
// Fallback to the Chromium icon if the page has no icon. // Fallback to the Chromium icon if the page has no icon.
gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), gtk_image_set_from_pixbuf(GTK_IMAGE(icon_),
rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf());
} else { } else {
GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); GdkPixbuf* icon_pixbuf = icon.ToGdkPixbuf();
gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf); gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf);
g_object_unref(icon_pixbuf);
} }
throbber_.Reset(); throbber_.Reset();
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "ipc/ipc_message.h" #include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h" #include "ipc/ipc_message_macros.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "ui/gfx/image/image.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
using content::UserMetricsAction; using content::UserMetricsAction;
...@@ -66,10 +66,9 @@ void PanelHost::DestroyWebContents() { ...@@ -66,10 +66,9 @@ void PanelHost::DestroyWebContents() {
web_contents_.reset(); web_contents_.reset();
} }
SkBitmap PanelHost::GetPageIcon() const { gfx::Image PanelHost::GetPageIcon() const {
// TODO: Make this function return gfx::Image.
return favicon_tab_helper_.get() ? return favicon_tab_helper_.get() ?
favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap(); favicon_tab_helper_->GetFavicon() : gfx::Image();
} }
void PanelHost::NavigationStateChanged(const content::WebContents* source, void PanelHost::NavigationStateChanged(const content::WebContents* source,
......
...@@ -27,6 +27,7 @@ class WindowController; ...@@ -27,6 +27,7 @@ class WindowController;
} }
namespace gfx { namespace gfx {
class Image;
class Rect; class Rect;
} }
...@@ -44,7 +45,7 @@ class PanelHost : public content::WebContentsDelegate, ...@@ -44,7 +45,7 @@ class PanelHost : public content::WebContentsDelegate,
void DestroyWebContents(); void DestroyWebContents();
// Returns the icon for the current page. // Returns the icon for the current page.
SkBitmap GetPageIcon() const; gfx::Image GetPageIcon() const;
// content::WebContentsDelegate overrides. // content::WebContentsDelegate overrides.
virtual void NavigationStateChanged(const content::WebContents* source, virtual void NavigationStateChanged(const content::WebContents* source,
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_compat.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/skia_utils_gtk.h" #include "ui/gfx/skia_utils_gtk.h"
namespace { namespace {
...@@ -216,15 +216,13 @@ void PanelTitlebarGtk::UpdateThrobber( ...@@ -216,15 +216,13 @@ void PanelTitlebarGtk::UpdateThrobber(
} else { } else {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
SkBitmap icon = panel_gtk_->panel()->GetCurrentPageIcon(); gfx::Image icon = panel_gtk_->panel()->GetCurrentPageIcon();
if (icon.empty()) { if (icon.IsEmpty()) {
// Fallback to the Chromium icon if the page has no icon. // Fallback to the Chromium icon if the page has no icon.
gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), gtk_image_set_from_pixbuf(GTK_IMAGE(icon_),
rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf()); rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_16).ToGdkPixbuf());
} else { } else {
GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(icon); gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon.ToGdkPixbuf());
gtk_image_set_from_pixbuf(GTK_IMAGE(icon_), icon_pixbuf);
g_object_unref(icon_pixbuf);
} }
throbber_.Reset(); throbber_.Reset();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/ui/panels/panel_manager.h" #include "chrome/browser/ui/panels/panel_manager.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/render_widget_host_view.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/path.h" #include "ui/gfx/path.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#include "ui/views/controls/button/image_button.h" #include "ui/views/controls/button/image_button.h"
...@@ -504,7 +505,8 @@ string16 PanelView::GetWindowTitle() const { ...@@ -504,7 +505,8 @@ string16 PanelView::GetWindowTitle() const {
} }
gfx::ImageSkia PanelView::GetWindowIcon() { gfx::ImageSkia PanelView::GetWindowIcon() {
return panel_->GetCurrentPageIcon(); gfx::Image icon = panel_->GetCurrentPageIcon();
return icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia();
} }
void PanelView::DeleteDelegate() { void PanelView::DeleteDelegate() {
......
...@@ -38,7 +38,6 @@ ...@@ -38,7 +38,6 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
#include "grit/ui_resources.h" #include "grit/ui_resources.h"
#include "skia/ext/skia_utils_mac.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
#include "webkit/glue/webcursor.h" #include "webkit/glue/webcursor.h"
...@@ -562,12 +561,10 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) { ...@@ -562,12 +561,10 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) {
icon = [ThrobberView filmstripThrobberViewWithFrame:iconFrame icon = [ThrobberView filmstripThrobberViewWithFrame:iconFrame
image:iconImage]; image:iconImage];
} else { } else {
SkBitmap bitmap = windowShim_->panel()->GetCurrentPageIcon(); gfx::Image page_icon = windowShim_->panel()->GetCurrentPageIcon();
ResourceBundle& rb = ResourceBundle::GetSharedInstance(); ResourceBundle& rb = ResourceBundle::GetSharedInstance();
NSImage* iconImage = bitmap.isNull() ? NSImage* iconImage = page_icon.IsEmpty() ?
rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) : rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON) : page_icon.ToNSImage();
gfx::SkBitmapToNSImageWithColorSpace(bitmap,
base::mac::GetSystemColorSpace());
NSImageView* iconView = NSImageView* iconView =
[[[NSImageView alloc] initWithFrame:iconFrame] autorelease]; [[[NSImageView alloc] initWithFrame:iconFrame] autorelease];
[iconView setImage:iconImage]; [iconView setImage:iconImage];
......
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