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

Unified Diff: chrome/browser/favicon/favicon_service.cc

Issue 10802066: Adds support for saving favicon size into history database. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment for History::SetFavicons Created 8 years, 3 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/favicon/favicon_service.cc
diff --git a/chrome/browser/favicon/favicon_service.cc b/chrome/browser/favicon/favicon_service.cc
index ec34ed10c7f7294048dfbf4d5237783c30a80f5b..2e99039667ecc9bc0bd2b8311076acbe8702ecbe 100644
--- a/chrome/browser/favicon/favicon_service.cc
+++ b/chrome/browser/favicon/favicon_service.cc
@@ -12,6 +12,7 @@
#include "chrome/common/url_constants.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/codec/png_codec.h"
+#include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image_skia.h"
FaviconService::FaviconService(HistoryService* history_service)
@@ -30,11 +31,14 @@ FaviconService::Handle FaviconService::GetFaviconImage(
desired_size_in_dip,
callback));
AddRequest(request, consumer);
- // TODO(pkotwicz): Pass in desired size and scale factors.
- if (history_service_)
- history_service_->GetFavicon(request, icon_url, icon_type);
- else
+ if (history_service_) {
+ std::vector<GURL> icon_urls;
+ icon_urls.push_back(icon_url);
+ history_service_->GetFavicons(request, icon_urls, icon_type,
+ desired_size_in_dip, ui::GetSupportedScaleFactors());
+ } else {
ForwardEmptyResultAsync(request);
+ }
return request->handle();
}
@@ -52,11 +56,16 @@ FaviconService::Handle FaviconService::GetRawFavicon(
desired_scale_factor,
callback));
AddRequest(request, consumer);
- // TODO(pkotwicz): Pass in desired size and scale factor.
- if (history_service_)
- history_service_->GetFavicon(request, icon_url, icon_type);
- else
+ if (history_service_) {
+ std::vector<GURL> icon_urls;
+ icon_urls.push_back(icon_url);
+ std::vector<ui::ScaleFactor> desired_scale_factors;
+ desired_scale_factors.push_back(desired_scale_factor);
+ history_service_->GetFavicons(request, icon_urls, icon_type,
+ desired_size_in_dip, desired_scale_factors);
+ } else {
ForwardEmptyResultAsync(request);
+ }
return request->handle();
}
@@ -69,10 +78,14 @@ FaviconService::Handle FaviconService::GetFavicon(
const FaviconResultsCallback& callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
- if (history_service_)
- history_service_->GetFavicon(request, icon_url, icon_type);
- else
+ if (history_service_) {
+ std::vector<GURL> icon_urls;
+ icon_urls.push_back(icon_url);
+ history_service_->GetFavicons(request, icon_urls, icon_type,
+ desired_size_in_dip, desired_scale_factors);
+ } else {
ForwardEmptyResultAsync(request);
+ }
return request->handle();
}
@@ -84,11 +97,16 @@ FaviconService::Handle FaviconService::UpdateFaviconMappingAndFetch(
const FaviconResultsCallback& callback) {
GetFaviconRequest* request = new GetFaviconRequest(callback);
AddRequest(request, consumer);
- if (history_service_)
- history_service_->UpdateFaviconMappingAndFetch(request, page_url,
- icon_url, icon_type);
- else
+ if (history_service_) {
+ std::vector<GURL> icon_urls;
+ icon_urls.push_back(icon_url);
+ // TODO(pkotwicz): Pass in |desired_size_in_dip| and |desired_scale_factors|
+ // from FaviconHandler.
+ history_service_->UpdateFaviconMappingsAndFetch(request, page_url,
+ icon_urls, icon_type, gfx::kFaviconSize, ui::GetSupportedScaleFactors());
sky 2012/09/04 20:52:29 > 80
+ } else {
ForwardEmptyResultAsync(request);
+ }
return request->handle();
}
@@ -160,25 +178,25 @@ FaviconService::Handle FaviconService::GetRawFaviconForID(
AddRequest(request, consumer);
FaviconService::Handle handle = request->handle();
- // TODO(pkotwicz): Pass in desired size and scale factor.
- if (history_service_)
- history_service_->GetFaviconForID(request, favicon_id);
- else
+ if (history_service_) {
+ history_service_->GetFaviconForID(request, favicon_id, desired_size_in_dip,
+ desired_scale_factor);
+ } else {
ForwardEmptyResultAsync(request);
-
+ }
return handle;
}
void FaviconService::SetFaviconOutOfDateForPage(const GURL& page_url) {
if (history_service_)
- history_service_->SetFaviconOutOfDateForPage(page_url);
+ history_service_->SetFaviconsOutOfDateForPage(page_url);
}
void FaviconService::CloneFavicon(const GURL& old_page_url,
const GURL& new_page_url) {
if (history_service_)
- history_service_->CloneFavicon(old_page_url, new_page_url);
+ history_service_->CloneFavicons(old_page_url, new_page_url);
}
void FaviconService::SetImportedFavicons(
@@ -191,8 +209,20 @@ void FaviconService::SetFavicon(const GURL& page_url,
const GURL& icon_url,
const std::vector<unsigned char>& image_data,
history::IconType icon_type) {
- if (history_service_)
- history_service_->SetFavicon(page_url, icon_url, image_data, icon_type);
+ if (history_service_) {
+ // TODO(pkotwicz): Pass in real pixel size to SetFavicons.
+ history::FaviconBitmapData bitmap_data_element;
+ bitmap_data_element.bitmap_data = scoped_refptr<base::RefCountedMemory>(
+ new base::RefCountedBytes(image_data));
+ bitmap_data_element.pixel_size = gfx::Size();
+ bitmap_data_element.icon_url = icon_url;
+ std::vector<history::FaviconBitmapData> favicon_bitmap_data;
+ favicon_bitmap_data.push_back(bitmap_data_element);
+ history::IconURLSizesMap icon_url_sizes;
+ icon_url_sizes[icon_url] = history::GetDefaultFaviconSizes();
+ history_service_->SetFavicons(page_url, icon_type,
+ favicon_bitmap_data, icon_url_sizes);
+ }
}
FaviconService::~FaviconService() {
@@ -214,11 +244,12 @@ FaviconService::Handle FaviconService::GetFaviconForURLImpl(
ChromeWebUIControllerFactory::GetInstance()->GetFaviconForURL(
profile, request, page_url);
} else {
- // TODO(pkotwicz): Pass in desired size and desired scale factors.
- if (history_service_)
- history_service_->GetFaviconForURL(request, page_url, icon_types);
- else
+ if (history_service_) {
+ history_service_->GetFaviconsForURL(request, page_url, icon_types,
+ desired_size_in_dip, desired_scale_factors);
+ } else {
ForwardEmptyResultAsync(request);
+ }
}
return handle;
}
« no previous file with comments | « no previous file | chrome/browser/favicon/select_favicon_frames.h » ('j') | chrome/browser/favicon/select_favicon_frames.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698