OLD | NEW |
---|---|
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
193 FaviconService* favicon_service = | 193 FaviconService* favicon_service = |
194 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); | 194 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); |
195 // Fall back to the default icons if the service isn't available. | 195 // Fall back to the default icons if the service isn't available. |
196 if (favicon_service == NULL) { | 196 if (favicon_service == NULL) { |
197 LoadDefaultImage(request_id); | 197 LoadDefaultImage(request_id); |
198 return; | 198 return; |
199 } | 199 } |
200 | 200 |
201 GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL(); | 201 GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL(); |
202 FaviconService::Handle handle = favicon_service->GetFaviconForURL( | 202 FaviconService::Handle handle = favicon_service->GetFaviconForURL( |
203 favicon_url, &cancelable_consumer_, | 203 favicon_url, |
204 history::FAV_ICON, | |
205 &cancelable_consumer_, | |
204 NewCallback(this, &ExtensionIconSource::OnFaviconDataAvailable)); | 206 NewCallback(this, &ExtensionIconSource::OnFaviconDataAvailable)); |
205 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); | 207 cancelable_consumer_.SetClientData(favicon_service, handle, request_id); |
206 } | 208 } |
207 | 209 |
208 void ExtensionIconSource::OnFaviconDataAvailable( | 210 void ExtensionIconSource::OnFaviconDataAvailable( |
209 FaviconService::Handle request_handle, | 211 FaviconService::Handle request_handle, |
210 bool know_favicon, | 212 bool know_favicon, |
211 scoped_refptr<RefCountedMemory> data, | 213 scoped_refptr<RefCountedMemory> data, |
212 bool expired, | 214 bool expired, |
213 GURL icon_url) { | 215 GURL icon_url, |
216 history::IconType) { | |
sky
2011/03/09 21:41:08
name
michaelbai
2011/03/09 23:11:45
Done.
| |
214 int request_id = cancelable_consumer_.GetClientData( | 217 int request_id = cancelable_consumer_.GetClientData( |
215 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle); | 218 profile_->GetFaviconService(Profile::EXPLICIT_ACCESS), request_handle); |
216 ExtensionIconRequest* request = GetData(request_id); | 219 ExtensionIconRequest* request = GetData(request_id); |
217 | 220 |
218 // Fallback to the default icon if there wasn't a favicon. | 221 // Fallback to the default icon if there wasn't a favicon. |
219 if (!know_favicon || !data.get() || !data->size()) { | 222 if (!know_favicon || !data.get() || !data->size()) { |
220 LoadDefaultImage(request_id); | 223 LoadDefaultImage(request_id); |
221 return; | 224 return; |
222 } | 225 } |
223 | 226 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 | 312 |
310 void ExtensionIconSource::ClearData(int request_id) { | 313 void ExtensionIconSource::ClearData(int request_id) { |
311 std::map<int, ExtensionIconRequest*>::iterator i = | 314 std::map<int, ExtensionIconRequest*>::iterator i = |
312 request_map_.find(request_id); | 315 request_map_.find(request_id); |
313 if (i == request_map_.end()) | 316 if (i == request_map_.end()) |
314 return; | 317 return; |
315 | 318 |
316 delete i->second; | 319 delete i->second; |
317 request_map_.erase(i); | 320 request_map_.erase(i); |
318 } | 321 } |
OLD | NEW |