OLD | NEW |
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/extensions/extension_icon_source.h" | 5 #include "chrome/browser/ui/webui/extensions/extension_icon_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 "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 favicon_url, | 216 favicon_url, |
217 history::FAVICON, | 217 history::FAVICON, |
218 &cancelable_consumer_, | 218 &cancelable_consumer_, |
219 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, | 219 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, |
220 base::Unretained(this))); | 220 base::Unretained(this))); |
221 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); | 221 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); |
222 } | 222 } |
223 | 223 |
224 void ExtensionIconSource::OnFaviconDataAvailable( | 224 void ExtensionIconSource::OnFaviconDataAvailable( |
225 FaviconService::Handle request_handle, | 225 FaviconService::Handle request_handle, |
226 history::FaviconData favicon) { | 226 history::FaviconData favicon_data, |
| 227 std::vector<GURL> icon_urls_in_db) { |
227 int request_id = cancelable_consumer_.GetClientData( | 228 int request_id = cancelable_consumer_.GetClientData( |
228 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle); | 229 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle); |
229 ExtensionIconRequest* request = GetData(request_id); | 230 ExtensionIconRequest* request = GetData(request_id); |
230 | 231 |
231 // Fallback to the default icon if there wasn't a favicon. | 232 // Fallback to the default icon if there wasn't a favicon. |
232 if (!favicon.is_valid()) { | 233 if (!favicon_data.has_valid_bitmaps()) { |
233 LoadDefaultImage(request_id); | 234 LoadDefaultImage(request_id); |
234 return; | 235 return; |
235 } | 236 } |
236 | 237 |
| 238 scoped_refptr<base::RefCountedMemory> bitmap_data = |
| 239 favicon_data.first_bitmap(); |
237 if (!request->grayscale) { | 240 if (!request->grayscale) { |
238 // If we don't need a grayscale image, then we can bypass FinalizeImage | 241 // If we don't need a grayscale image, then we can bypass FinalizeImage |
239 // to avoid unnecessary conversions. | 242 // to avoid unnecessary conversions. |
240 ClearData(request_id); | 243 ClearData(request_id); |
241 SendResponse(request_id, favicon.image_data); | 244 SendResponse(request_id, bitmap_data); |
242 } else { | 245 } else { |
243 FinalizeImage(ToBitmap(favicon.image_data->front(), | 246 FinalizeImage(ToBitmap(bitmap_data->front(), bitmap_data->size()), |
244 favicon.image_data->size()), request_id); | 247 request_id); |
245 } | 248 } |
246 } | 249 } |
247 | 250 |
248 void ExtensionIconSource::OnImageLoaded(const gfx::Image& image, | 251 void ExtensionIconSource::OnImageLoaded(const gfx::Image& image, |
249 const std::string& extension_id, | 252 const std::string& extension_id, |
250 int index) { | 253 int index) { |
251 int request_id = tracker_map_[index]; | 254 int request_id = tracker_map_[index]; |
252 tracker_map_.erase(tracker_map_.find(index)); | 255 tracker_map_.erase(tracker_map_.find(index)); |
253 | 256 |
254 if (image.IsEmpty()) | 257 if (image.IsEmpty()) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 | 342 |
340 void ExtensionIconSource::ClearData(int request_id) { | 343 void ExtensionIconSource::ClearData(int request_id) { |
341 std::map<int, ExtensionIconRequest*>::iterator i = | 344 std::map<int, ExtensionIconRequest*>::iterator i = |
342 request_map_.find(request_id); | 345 request_map_.find(request_id); |
343 if (i == request_map_.end()) | 346 if (i == request_map_.end()) |
344 return; | 347 return; |
345 | 348 |
346 delete i->second; | 349 delete i->second; |
347 request_map_.erase(i); | 350 request_map_.erase(i); |
348 } | 351 } |
OLD | NEW |