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

Side by Side Diff: chrome/browser/ui/webui/favicon_source.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/favicon_source.h" 5 #include "chrome/browser/ui/webui/favicon_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "chrome/browser/history/top_sites.h" 9 #include "chrome/browser/history/top_sites.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "grit/locale_settings.h" 12 #include "grit/locale_settings.h"
13 #include "grit/ui_resources.h" 13 #include "grit/ui_resources.h"
14 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/layout.h"
15 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
16 17
17 FaviconSource::FaviconSource(Profile* profile, IconType type) 18 FaviconSource::FaviconSource(Profile* profile, IconType type)
18 : DataSource(type == FAVICON ? chrome::kChromeUIFaviconHost : 19 : DataSource(type == FAVICON ? chrome::kChromeUIFaviconHost :
19 chrome::kChromeUITouchIconHost, 20 chrome::kChromeUITouchIconHost,
20 MessageLoop::current()) { 21 MessageLoop::current()) {
21 Init(profile, type); 22 Init(profile, type);
22 } 23 }
23 24
24 FaviconSource::FaviconSource(Profile* profile, 25 FaviconSource::FaviconSource(Profile* profile,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 request_size_map_[request_id] = 16; 90 request_size_map_[request_id] = 16;
90 } 91 }
91 92
92 // Intercept requests for prepopulated pages. 93 // Intercept requests for prepopulated pages.
93 for (size_t i = 0; i < arraysize(history::kPrepopulatedPages); i++) { 94 for (size_t i = 0; i < arraysize(history::kPrepopulatedPages); i++) {
94 if (url.spec() == 95 if (url.spec() ==
95 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) { 96 l10n_util::GetStringUTF8(history::kPrepopulatedPages[i].url_id)) {
96 request_size_map_.erase(request_id); 97 request_size_map_.erase(request_id);
97 SendResponse(request_id, 98 SendResponse(request_id,
98 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 99 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
99 history::kPrepopulatedPages[i].favicon_id)); 100 history::kPrepopulatedPages[i].favicon_id,
101 ui::SCALE_FACTOR_100P));
100 return; 102 return;
101 } 103 }
102 } 104 }
103 105
104 // TODO(estade): fetch the requested size. 106 // TODO(estade): fetch the requested size.
105 handle = favicon_service->GetFaviconForURL( 107 handle = favicon_service->GetFaviconForURL(
106 url, 108 url,
107 icon_types_, 109 icon_types_,
108 &cancelable_consumer_, 110 &cancelable_consumer_,
109 base::Bind(&FaviconSource::OnFaviconDataAvailable, 111 base::Bind(&FaviconSource::OnFaviconDataAvailable,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 SendDefaultResponse(request_id); 143 SendDefaultResponse(request_id);
142 } 144 }
143 } 145 }
144 146
145 void FaviconSource::SendDefaultResponse(int request_id) { 147 void FaviconSource::SendDefaultResponse(int request_id) {
146 base::RefCountedMemory* bytes = NULL; 148 base::RefCountedMemory* bytes = NULL;
147 if (request_size_map_[request_id] == 32) { 149 if (request_size_map_[request_id] == 32) {
148 if (!default_favicon_large_.get()) { 150 if (!default_favicon_large_.get()) {
149 default_favicon_large_ = 151 default_favicon_large_ =
150 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 152 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
151 IDR_DEFAULT_LARGE_FAVICON); 153 IDR_DEFAULT_LARGE_FAVICON, ui::SCALE_FACTOR_100P);
152 } 154 }
153 bytes = default_favicon_large_; 155 bytes = default_favicon_large_;
154 } else { 156 } else {
155 if (!default_favicon_.get()) { 157 if (!default_favicon_.get()) {
156 default_favicon_ = 158 default_favicon_ =
157 ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 159 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
158 IDR_DEFAULT_FAVICON); 160 IDR_DEFAULT_FAVICON, ui::SCALE_FACTOR_100P);
159 } 161 }
160 bytes = default_favicon_; 162 bytes = default_favicon_;
161 } 163 }
162 request_size_map_.erase(request_id); 164 request_size_map_.erase(request_id);
163 165
164 SendResponse(request_id, bytes); 166 SendResponse(request_id, bytes);
165 } 167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698