summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc11
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.h8
-rw-r--r--chrome/browser/instant/instant_loader.cc4
-rw-r--r--chrome/browser/task_manager/task_manager_resource_providers.cc2
-rw-r--r--chrome/browser/ui/browser.cc4
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm4
-rw-r--r--chrome/browser/ui/content_settings/content_setting_bubble_model.cc3
-rw-r--r--chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc2
-rw-r--r--chrome/browser/ui/gtk/location_bar_view_gtk.cc2
-rw-r--r--chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc3
-rw-r--r--chrome/browser/ui/panels/panel_host.cc4
-rw-r--r--chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc2
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc7
-rw-r--r--chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc4
-rw-r--r--content/public/browser/favicon_status.cc4
-rw-r--r--content/public/browser/favicon_status.h3
-rw-r--r--ui/gfx/image/image.cc8
-rw-r--r--ui/gfx/image/image.h7
19 files changed, 53 insertions, 31 deletions
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc
index 2d0eda3..a0e833a 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -49,18 +49,18 @@ void FaviconTabHelper::FetchFavicon(const GURL& url) {
touch_icon_handler_->FetchFavicon(url);
}
-SkBitmap FaviconTabHelper::GetFavicon() const {
+gfx::Image FaviconTabHelper::GetFavicon() const {
// Like GetTitle(), we also want to use the favicon for the last committed
// entry rather than a pending navigation entry.
const NavigationController& controller = web_contents()->GetController();
NavigationEntry* entry = controller.GetTransientEntry();
if (entry)
- return entry->GetFavicon().AsBitmap();
+ return entry->GetFavicon().image;
entry = controller.GetLastCommittedEntry();
if (entry)
- return entry->GetFavicon().AsBitmap();
- return SkBitmap();
+ return entry->GetFavicon().image;
+ return gfx::Image();
}
bool FaviconTabHelper::FaviconIsValid() const {
@@ -112,7 +112,8 @@ void FaviconTabHelper::SaveFavicon() {
}
std::vector<unsigned char> image_data;
// TODO: Save all representations.
- gfx::PNGCodec::EncodeBGRASkBitmap(favicon.AsBitmap(), false, &image_data);
+ gfx::PNGCodec::EncodeBGRASkBitmap(
+ favicon.image.AsBitmap(), false, &image_data);
service->SetFavicon(
entry->GetURL(), favicon.url, image_data, history::FAVICON);
}
diff --git a/chrome/browser/favicon/favicon_tab_helper.h b/chrome/browser/favicon/favicon_tab_helper.h
index caa5417..1563373 100644
--- a/chrome/browser/favicon/favicon_tab_helper.h
+++ b/chrome/browser/favicon/favicon_tab_helper.h
@@ -15,6 +15,10 @@
#include "content/public/browser/web_contents_observer.h"
#include "googleurl/src/gurl.h"
+namespace gfx {
+class Image;
+}
+
class FaviconHandler;
class SkBitmap;
@@ -38,9 +42,9 @@ class FaviconTabHelper : public content::WebContentsObserver,
// Returns the favicon for this tab, or IDR_DEFAULT_FAVICON if the tab does
// not have a favicon. The default implementation uses the current navigation
- // entry. This will return an isNull bitmap if there are no navigation
+ // entry. This will return an empty bitmap if there are no navigation
// entries, which should rarely happen.
- SkBitmap GetFavicon() const;
+ gfx::Image GetFavicon() const;
// Returns true if we have the favicon for the page.
bool FaviconIsValid() const;
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index e4f1885..41c9c85 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -379,8 +379,8 @@ void InstantLoader::WebContentsDelegateImpl::CommitHistory(
!active_entry->GetFavicon().image.IsEmpty()) {
std::vector<unsigned char> image_data;
// TODO: Add all variants once the history service supports it.
- gfx::PNGCodec::EncodeBGRASkBitmap(active_entry->GetFavicon().AsBitmap(),
- false, &image_data);
+ gfx::PNGCodec::EncodeBGRASkBitmap(
+ active_entry->GetFavicon().image.AsBitmap(), false, &image_data);
favicon_service->SetFavicon(active_entry->GetURL(),
active_entry->GetFavicon().url,
image_data,
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc
index 7233805..dbc26f7 100644
--- a/chrome/browser/task_manager/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager/task_manager_resource_providers.cc
@@ -334,7 +334,7 @@ string16 TaskManagerTabContentsResource::GetProfileName() const {
gfx::ImageSkia TaskManagerTabContentsResource::GetIcon() const {
if (IsPrerendering())
return *prerender_icon_;
- return tab_contents_->favicon_tab_helper()->GetFavicon();
+ return tab_contents_->favicon_tab_helper()->GetFavicon().AsImageSkia();
}
WebContents* TaskManagerTabContentsResource::GetWebContents() const {
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 5fcb373..1938d63 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -534,7 +534,9 @@ SkBitmap Browser::GetCurrentPageIcon() const {
TabContents* contents = chrome::GetActiveTabContents(this);
// |contents| can be NULL since GetCurrentPageIcon() is called by the window
// during the window's creation (before tabs have been added).
- return contents ? contents->favicon_tab_helper()->GetFavicon() : SkBitmap();
+ // TODO: Let this return a gfx::Image.
+ return contents ?
+ contents->favicon_tab_helper()->GetFavicon().AsBitmap() : SkBitmap();
}
string16 Browser::GetWindowTitleForCurrentTab() const {
diff --git a/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm b/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm
index 24b1342..77107f1 100644
--- a/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm
+++ b/chrome/browser/ui/cocoa/tab_contents/favicon_util_mac.mm
@@ -19,9 +19,7 @@ namespace mac {
NSImage* FaviconForTabContents(TabContents* contents) {
if (contents && contents->favicon_tab_helper()->FaviconIsValid()) {
- CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
- NSImage* image = gfx::SkBitmapToNSImageWithColorSpace(
- contents->favicon_tab_helper()->GetFavicon(), color_space);
+ NSImage* image = contents->favicon_tab_helper()->GetFavicon().ToNSImage();
// The |image| could be nil if the bitmap is null. In that case, fallback
// to the default image.
if (image) {
diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
index 277b0aa..b3cce9f 100644
--- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
+++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc
@@ -468,7 +468,8 @@ void ContentSettingPopupBubbleModel::SetPopups() {
title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE);
PopupItem popup_item;
popup_item.title = title;
- popup_item.bitmap = (*i)->favicon_tab_helper()->GetFavicon();
+ // TODO: Make this use gfx::Image.
+ popup_item.bitmap = (*i)->favicon_tab_helper()->GetFavicon().AsBitmap();
popup_item.tab_contents = (*i);
add_popup(popup_item);
}
diff --git a/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc
index 183cc1d..8f24d10 100644
--- a/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc
+++ b/chrome/browser/ui/gtk/hung_renderer_dialog_gtk.cc
@@ -191,7 +191,7 @@ void HungRendererDialogGtk::ShowForWebContents(WebContents* hung_contents) {
std::string title = UTF16ToUTF8(it->web_contents()->GetTitle());
if (title.empty())
title = UTF16ToUTF8(CoreTabHelper::GetDefaultTitle());
- SkBitmap favicon = it->favicon_tab_helper()->GetFavicon();
+ SkBitmap favicon = it->favicon_tab_helper()->GetFavicon().AsBitmap();
GdkPixbuf* pixbuf = NULL;
if (favicon.width() > 0)
diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
index dd2d3c82..3d78494 100644
--- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc
@@ -815,7 +815,7 @@ void LocationBarViewGtk::OnSetFocus() {
}
SkBitmap LocationBarViewGtk::GetFavicon() const {
- return GetTabContents()->favicon_tab_helper()->GetFavicon();
+ return GetTabContents()->favicon_tab_helper()->GetFavicon().AsBitmap();
}
string16 LocationBarViewGtk::GetTitle() const {
diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
index 15abf63..7b9dcbd 100644
--- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc
@@ -337,7 +337,8 @@ void TabRendererGtk::UpdateData(WebContents* contents,
if (app_icon) {
data_.favicon = *app_icon;
} else {
- data_.favicon = tab_contents->favicon_tab_helper()->GetFavicon();
+ data_.favicon =
+ tab_contents->favicon_tab_helper()->GetFavicon().AsBitmap();
}
data_.app = app;
diff --git a/chrome/browser/ui/panels/panel_host.cc b/chrome/browser/ui/panels/panel_host.cc
index 9162967..11cd3ef 100644
--- a/chrome/browser/ui/panels/panel_host.cc
+++ b/chrome/browser/ui/panels/panel_host.cc
@@ -22,6 +22,7 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
+#include "ui/gfx/image/image.h"
#include "ipc/ipc_message.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -62,8 +63,9 @@ void PanelHost::DestroyWebContents() {
}
SkBitmap PanelHost::GetPageIcon() const {
+ // TODO: Make this function return gfx::Image.
return favicon_tab_helper_.get() ?
- favicon_tab_helper_->GetFavicon() : SkBitmap();
+ favicon_tab_helper_->GetFavicon().AsBitmap() : SkBitmap();
}
void PanelHost::NavigationStateChanged(const content::WebContents* source,
diff --git a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc
index 3dde3c8..24f1eea 100644
--- a/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc
+++ b/chrome/browser/ui/views/ash/launcher/browser_launcher_item_controller.cc
@@ -227,7 +227,7 @@ void BrowserLauncherItemController::UpdateLauncher(TabContents* tab) {
DCHECK_EQ(TYPE_TABBED, type_);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
if (tab->favicon_tab_helper()->ShouldDisplayFavicon()) {
- item.image = tab->favicon_tab_helper()->GetFavicon();
+ item.image = tab->favicon_tab_helper()->GetFavicon().AsBitmap();
if (item.image.empty()) {
item.image = *rb.GetBitmapNamed(IDR_DEFAULT_FAVICON);
}
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index dfd9ddb..b23b9af 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -120,7 +120,7 @@ string16 HungPagesTableModel::GetText(int row, int column_id) {
gfx::ImageSkia HungPagesTableModel::GetIcon(int row) {
DCHECK(row >= 0 && row < RowCount());
- return tab_observers_[row]->favicon_tab_helper()->GetFavicon();
+ return tab_observers_[row]->favicon_tab_helper()->GetFavicon().AsImageSkia();
}
void HungPagesTableModel::SetObserver(ui::TableModelObserver* observer) {
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index aab0c32..bc5a539 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -1074,7 +1074,8 @@ void LocationBarView::OnSetFocus() {
}
SkBitmap LocationBarView::GetFavicon() const {
- return delegate_->GetTabContents()->favicon_tab_helper()->GetFavicon();
+ return delegate_->GetTabContents()->favicon_tab_helper()->
+ GetFavicon().AsBitmap();
}
string16 LocationBarView::GetTitle() const {
@@ -1305,10 +1306,12 @@ void LocationBarView::WriteDragDataForView(views::View* sender,
TabContents* tab_contents = delegate_->GetTabContents();
DCHECK(tab_contents);
+ gfx::ImageSkia favicon =
+ tab_contents->favicon_tab_helper()->GetFavicon().AsImageSkia();
button_drag_utils::SetURLAndDragImage(
tab_contents->web_contents()->GetURL(),
tab_contents->web_contents()->GetTitle(),
- tab_contents->favicon_tab_helper()->GetFavicon(),
+ favicon,
data,
sender->GetWidget());
}
diff --git a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
index fa7ccf8..7ddbd68 100644
--- a/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
+++ b/chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
@@ -509,7 +509,9 @@ void BrowserTabStripController::SetTabRendererDataFromModel(
TabStatus tab_status) {
TabContents* tab_contents = TabContents::FromWebContents(contents);
- data->favicon = tab_contents->favicon_tab_helper()->GetFavicon();
+ // TODO: Convert data->favicon to gfx::Image.
+ data->favicon =
+ tab_contents->favicon_tab_helper()->GetFavicon().AsBitmap();
data->network_state = TabContentsNetworkState(contents);
data->title = contents->GetTitle();
data->url = contents->GetURL();
diff --git a/content/public/browser/favicon_status.cc b/content/public/browser/favicon_status.cc
index 8e54003..89fd46d 100644
--- a/content/public/browser/favicon_status.cc
+++ b/content/public/browser/favicon_status.cc
@@ -13,8 +13,4 @@ FaviconStatus::FaviconStatus() : valid(false) {
image = gfx::Image(*GetContentClient()->browser()->GetDefaultFavicon());
}
-SkBitmap FaviconStatus::AsBitmap() const {
- return image.IsEmpty() ? SkBitmap() : *image.ToSkBitmap();
-}
-
} // namespace content
diff --git a/content/public/browser/favicon_status.h b/content/public/browser/favicon_status.h
index 1604067..3d1af9a 100644
--- a/content/public/browser/favicon_status.h
+++ b/content/public/browser/favicon_status.h
@@ -16,9 +16,6 @@ namespace content {
struct CONTENT_EXPORT FaviconStatus {
FaviconStatus();
- // Returns 1x resolution of image. This function should eventually go away.
- SkBitmap AsBitmap() const;
-
// Indicates whether we've gotten an official favicon for the page, or are
// just using the default favicon.
bool valid;
diff --git a/ui/gfx/image/image.cc b/ui/gfx/image/image.cc
index ea302ab..9854787 100644
--- a/ui/gfx/image/image.cc
+++ b/ui/gfx/image/image.cc
@@ -337,6 +337,14 @@ NSImage* Image::ToNSImage() const {
}
#endif
+SkBitmap Image::AsBitmap() const {
+ return IsEmpty() ? SkBitmap() : *ToSkBitmap();
+}
+
+ImageSkia Image::AsImageSkia() const {
+ return IsEmpty() ? ImageSkia(SkBitmap()) : *ToImageSkia();
+}
+
ImageSkia* Image::CopyImageSkia() const {
return new ImageSkia(*ToImageSkia());
}
diff --git a/ui/gfx/image/image.h b/ui/gfx/image/image.h
index c03db3a..04a79da 100644
--- a/ui/gfx/image/image.h
+++ b/ui/gfx/image/image.h
@@ -107,6 +107,13 @@ class UI_EXPORT Image {
NSImage* ToNSImage() const;
#endif
+ // Same as ToSkBitmap(), but returns a null SkBitmap if this image is empty.
+ SkBitmap AsBitmap() const;
+
+ // Same as ToSkBitmap(), but returns a ImageSkia with a null SkBitmap if this
+ // image is empty.
+ ImageSkia AsImageSkia() const;
+
// Performs a conversion, like above, but returns a copy of the result rather
// than a weak pointer. The caller is responsible for deleting the result.
// Note that the result is only a copy in terms of memory management; the