Index: chrome/browser/favicon/favicon_tab_helper.cc |
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc |
index 84779f325e08937f51658343cc2559a68b23f6ff..93ab9dc3104f2b63b3acb4c59249d0b6b1d3e54d 100644 |
--- a/chrome/browser/favicon/favicon_tab_helper.cc |
+++ b/chrome/browser/favicon/favicon_tab_helper.cc |
@@ -24,6 +24,8 @@ |
#include "content/public/browser/web_ui.h" |
#include "ui/gfx/codec/png_codec.h" |
#include "ui/gfx/image/image.h" |
+#include "ui/gfx/image/image_skia.h" |
+#include "ui/gfx/image/image_skia_rep.h" |
using content::FaviconStatus; |
using content::NavigationController; |
@@ -50,6 +52,7 @@ void FaviconTabHelper::FetchFavicon(const GURL& url) { |
} |
SkBitmap FaviconTabHelper::GetFavicon() const { |
+ // XXX delete |
// 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(); |
@@ -63,6 +66,20 @@ SkBitmap FaviconTabHelper::GetFavicon() const { |
return SkBitmap(); |
} |
+gfx::Image FaviconTabHelper::GetFaviconImage() 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().image; |
+ |
+ entry = controller.GetLastCommittedEntry(); |
+ if (entry) |
+ return entry->GetFavicon().image; |
+ return gfx::Image(); |
+} |
+ |
bool FaviconTabHelper::FaviconIsValid() const { |
const NavigationController& controller = web_contents()->GetController(); |
NavigationEntry* entry = controller.GetTransientEntry(); |
@@ -141,9 +158,9 @@ NavigationEntry* FaviconTabHelper::GetActiveEntry() { |
return web_contents()->GetController().GetActiveEntry(); |
} |
-int FaviconTabHelper::StartDownload(const GURL& url, int image_size) { |
+int FaviconTabHelper::StartDownload(const GURL& url, const std::vector<int>& image_sizes) { |
content::RenderViewHost* host = web_contents()->GetRenderViewHost(); |
- int id = FaviconUtil::DownloadFavicon(host, url, image_size); |
+ int id = FaviconUtil::DownloadFavicon(host, url, image_sizes); |
return id; |
} |
@@ -187,8 +204,20 @@ bool FaviconTabHelper::OnMessageReceived(const IPC::Message& message) { |
void FaviconTabHelper::OnDidDownloadFavicon(int id, |
const GURL& image_url, |
bool errored, |
- const SkBitmap& image) { |
- gfx::Image favicon(image); |
+ const std::vector<SkBitmap>& image) { |
pkotwicz
2012/08/02 23:47:08
Please name this parameter bitmaps
|
+ // XXX use cole's desired scaling algorithm |
+ gfx::ImageSkia multi_image; |
+ for (size_t i = 0; i < image.size(); ++i) { |
+ if (!image[i].isNull()) { |
+ multi_image.AddRepresentation( |
+ gfx::ImageSkiaRep(image[i], |
+ ui::GetScaleFactorFromScale( |
+ image[i].width() / 16.0))); // XXX |
pkotwicz
2012/08/02 23:47:08
16 -> gfx::kFaviconSize.
Probably going to be some
|
+ } |
+ } |
+ |
+ gfx::Image favicon(multi_image); |
+ |
favicon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |
if (touch_icon_handler_.get()) |
touch_icon_handler_->OnDidDownloadFavicon(id, image_url, errored, favicon); |