summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/webui/favicon_source.cc50
-rw-r--r--chrome/browser/ui/webui/favicon_source.h16
-rw-r--r--ui/resources/default_100_percent/default_large_favicon.pngbin266 -> 0 bytes
-rw-r--r--ui/resources/ui_resources.grd3
4 files changed, 41 insertions, 28 deletions
diff --git a/chrome/browser/ui/webui/favicon_source.cc b/chrome/browser/ui/webui/favicon_source.cc
index 750e387..d7f1d36 100644
--- a/chrome/browser/ui/webui/favicon_source.cc
+++ b/chrome/browser/ui/webui/favicon_source.cc
@@ -66,7 +66,8 @@ void FaviconSource::StartDataRequest(const std::string& path,
web_ui_util::ParseScaleFactor(scale_str, &scale_factor);
prefix_length = slash + 1;
}
- // TODO : Change GetFavicon to support combination of IconType.
+ // TODO(michaelbai): Change GetRawFavicon to support combination of
+ // IconType.
handle = favicon_service->GetRawFavicon(
GURL(path.substr(prefix_length)),
history::FAVICON,
@@ -82,8 +83,8 @@ void FaviconSource::StartDataRequest(const std::string& path,
size_t scale_delimiter = path.find("@", 5);
std::string size = path.substr(5, slash - 5);
pixel_size = atoi(size.c_str());
- CHECK(pixel_size == 32 || pixel_size == 16) <<
- "only 32x32 and 16x16 icons are supported";
+ DCHECK(pixel_size == 64 || pixel_size == 32 || pixel_size == 16) <<
+ "only 64x64, 32x32 and 16x16 icons are supported";
// Optional scale factor.
if (scale_delimiter != std::string::npos && scale_delimiter < slash) {
std::string scale_str = path.substr(scale_delimiter + 1,
@@ -172,23 +173,30 @@ void FaviconSource::OnFaviconDataAvailable(
}
void FaviconSource::SendDefaultResponse(const IconRequest& icon_request) {
- base::RefCountedMemory* bytes = NULL;
- ui::ScaleFactor scale_factor = icon_request.scale_factor;
-
- if (icon_request.pixel_size == 32) {
- if (!default_favicon_large_.get()) {
- default_favicon_large_ =
- ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
- IDR_DEFAULT_LARGE_FAVICON, scale_factor);
- }
- bytes = default_favicon_large_;
- } else {
- if (!default_favicon_.get()) {
- default_favicon_ =
- ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
- IDR_DEFAULT_FAVICON, scale_factor);
- }
- bytes = default_favicon_;
+ int favicon_index;
+ int resource_id;
+ switch (icon_request.pixel_size) {
+ case 64:
+ favicon_index = SIZE_64;
+ resource_id = IDR_DEFAULT_FAVICON_64;
+ break;
+ case 32:
+ favicon_index = SIZE_32;
+ resource_id = IDR_DEFAULT_FAVICON_32;
+ break;
+ default:
+ favicon_index = SIZE_16;
+ resource_id = IDR_DEFAULT_FAVICON;
+ break;
}
- SendResponse(icon_request.request_id, bytes);
+ base::RefCountedMemory* default_favicon = default_favicons_[favicon_index];
+
+ if (!default_favicon) {
+ ui::ScaleFactor scale_factor = icon_request.scale_factor;
+ default_favicon = ResourceBundle::GetSharedInstance()
+ .LoadDataResourceBytes(resource_id, scale_factor);
+ default_favicons_[favicon_index] = default_favicon;
+ }
+
+ SendResponse(icon_request.request_id, default_favicon);
}
diff --git a/chrome/browser/ui/webui/favicon_source.h b/chrome/browser/ui/webui/favicon_source.h
index 564c00a..79f6396 100644
--- a/chrome/browser/ui/webui/favicon_source.h
+++ b/chrome/browser/ui/webui/favicon_source.h
@@ -51,6 +51,13 @@ class FaviconSource : public ChromeURLDataManager::DataSource {
Profile* profile_;
private:
+ // Defines the allowed pixel sizes for requested favicons.
+ enum IconSize {
+ SIZE_16,
+ SIZE_32,
+ SIZE_64,
+ NUM_SIZES
+ };
struct IconRequest {
IconRequest()
@@ -80,12 +87,9 @@ class FaviconSource : public ChromeURLDataManager::DataSource {
CancelableRequestConsumerTSimple<IconRequest> cancelable_consumer_;
- // Raw PNG representation of the favicon to show when the favicon
- // database doesn't have a favicon for a webpage.
- // 16x16
- scoped_refptr<base::RefCountedMemory> default_favicon_;
- // 32x32
- scoped_refptr<base::RefCountedMemory> default_favicon_large_;
+ // Raw PNG representations of favicons of each size to show when the favicon
+ // database doesn't have a favicon for a webpage. Indexed by IconSize values.
+ scoped_refptr<base::RefCountedMemory> default_favicons_[NUM_SIZES];
// The history::IconTypes of icon that this FaviconSource handles.
int icon_types_;
diff --git a/ui/resources/default_100_percent/default_large_favicon.png b/ui/resources/default_100_percent/default_large_favicon.png
deleted file mode 100644
index 01d205f..0000000
--- a/ui/resources/default_100_percent/default_large_favicon.png
+++ /dev/null
Binary files differ
diff --git a/ui/resources/ui_resources.grd b/ui/resources/ui_resources.grd
index 102c9610..7cff645 100644
--- a/ui/resources/ui_resources.grd
+++ b/ui/resources/ui_resources.grd
@@ -93,7 +93,8 @@
<structure type="chrome_scaled_image" name="IDR_CONTENT_LEFT_SIDE" file="content_left_side.png" />
<structure type="chrome_scaled_image" name="IDR_CONTENT_RIGHT_SIDE" file="content_right_side.png" />
<structure type="chrome_scaled_image" name="IDR_DEFAULT_FAVICON" file="default_favicon.png" />
- <structure type="chrome_scaled_image" name="IDR_DEFAULT_LARGE_FAVICON" file="default_large_favicon.png" />
+ <structure type="chrome_scaled_image" name="IDR_DEFAULT_FAVICON_32" file="default_favicon_32.png" />
+ <structure type="chrome_scaled_image" name="IDR_DEFAULT_FAVICON_64" file="default_favicon_64.png" />
<structure type="chrome_scaled_image" name="IDR_FOLDER_CLOSED" file="common/folder_closed.png" />
<structure type="chrome_scaled_image" name="IDR_FOLDER_CLOSED_RTL" file="common/folder_closed_rtl.png" />
<structure type="chrome_scaled_image" name="IDR_FOLDER_OPEN" file="common/folder_open.png" />