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

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

Issue 6651014: Applied the IconType. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: sync Created 9 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_icon_source.h" 5 #include "chrome/browser/ui/webui/extension_icon_source.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/ref_counted_memory.h" 8 #include "base/ref_counted_memory.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 FaviconService* favicon_service = 194 FaviconService* favicon_service =
195 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); 195 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS);
196 // Fall back to the default icons if the service isn't available. 196 // Fall back to the default icons if the service isn't available.
197 if (favicon_service == NULL) { 197 if (favicon_service == NULL) {
198 LoadDefaultImage(request_id); 198 LoadDefaultImage(request_id);
199 return; 199 return;
200 } 200 }
201 201
202 GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL(); 202 GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL();
203 FaviconService::Handle handle = favicon_service->GetFaviconForURL( 203 FaviconService::Handle handle = favicon_service->GetFaviconForURL(
204 favicon_url, &cancelable_consumer_, 204 favicon_url,
205 history::FAVICON,
206 &cancelable_consumer_,
205 NewCallback(this, &ExtensionIconSource::OnFaviconDataAvailable)); 207 NewCallback(this, &ExtensionIconSource::OnFaviconDataAvailable));
206 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); 208 cancelable_consumer_.SetClientData(favicon_service, handle, request_id);
207 } 209 }
208 210
209 void ExtensionIconSource::OnFaviconDataAvailable( 211 void ExtensionIconSource::OnFaviconDataAvailable(
210 FaviconService::Handle request_handle, 212 FaviconService::Handle request_handle,
211 bool know_favicon, 213 history::FaviconData favicon) {
212 scoped_refptr<RefCountedMemory> data,
213 bool expired,
214 GURL icon_url) {
215 int request_id = cancelable_consumer_.GetClientData( 214 int request_id = cancelable_consumer_.GetClientData(
216 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle); 215 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle);
217 ExtensionIconRequest* request = GetData(request_id); 216 ExtensionIconRequest* request = GetData(request_id);
218 217
219 // Fallback to the default icon if there wasn't a favicon. 218 // Fallback to the default icon if there wasn't a favicon.
220 if (!know_favicon || !data.get() || !data->size()) { 219 if (!favicon.is_valid()) {
221 LoadDefaultImage(request_id); 220 LoadDefaultImage(request_id);
222 return; 221 return;
223 } 222 }
224 223
225 if (!request->grayscale) { 224 if (!request->grayscale) {
226 // If we don't need a grayscale image, then we can bypass FinalizeImage 225 // If we don't need a grayscale image, then we can bypass FinalizeImage
227 // to avoid unnecessary conversions. 226 // to avoid unnecessary conversions.
228 ClearData(request_id); 227 ClearData(request_id);
229 SendResponse(request_id, data); 228 SendResponse(request_id, favicon.image_data);
230 } else { 229 } else {
231 FinalizeImage(ToBitmap(data->front(), data->size()), request_id); 230 FinalizeImage(ToBitmap(favicon.image_data->front(),
231 favicon.image_data->size()), request_id);
232 } 232 }
233 } 233 }
234 234
235 void ExtensionIconSource::OnImageLoaded(SkBitmap* image, 235 void ExtensionIconSource::OnImageLoaded(SkBitmap* image,
236 const ExtensionResource& resource, 236 const ExtensionResource& resource,
237 int index) { 237 int index) {
238 int request_id = tracker_map_[index]; 238 int request_id = tracker_map_[index];
239 tracker_map_.erase(tracker_map_.find(index)); 239 tracker_map_.erase(tracker_map_.find(index));
240 240
241 if (!image || image->empty()) 241 if (!image || image->empty())
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 314
315 void ExtensionIconSource::ClearData(int request_id) { 315 void ExtensionIconSource::ClearData(int request_id) {
316 std::map<int, ExtensionIconRequest*>::iterator i = 316 std::map<int, ExtensionIconRequest*>::iterator i =
317 request_map_.find(request_id); 317 request_map_.find(request_id);
318 if (i == request_map_.end()) 318 if (i == request_map_.end())
319 return; 319 return;
320 320
321 delete i->second; 321 delete i->second;
322 request_map_.erase(i); 322 request_map_.erase(i);
323 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698