| 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" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "chrome/browser/extensions/extension_prefs.h" | 16 #include "chrome/browser/extensions/extension_prefs.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/extensions/image_loader.h" | 19 #include "chrome/browser/extensions/image_loader.h" |
| 20 #include "chrome/browser/favicon/favicon_service_factory.h" | 20 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/common/extensions/app_launcher_info.h" |
| 22 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
| 23 #include "chrome/common/extensions/extension_constants.h" | 24 #include "chrome/common/extensions/extension_constants.h" |
| 24 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 25 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
| 25 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 26 #include "extensions/common/extension_resource.h" | 27 #include "extensions/common/extension_resource.h" |
| 27 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
| 28 #include "grit/component_extension_resources_map.h" | 29 #include "grit/component_extension_resources_map.h" |
| 29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
| 30 #include "skia/ext/image_operations.h" | 31 #include "skia/ext/image_operations.h" |
| 31 #include "ui/base/layout.h" | 32 #include "ui/base/layout.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 211 |
| 211 void ExtensionIconSource::LoadFaviconImage(int request_id) { | 212 void ExtensionIconSource::LoadFaviconImage(int request_id) { |
| 212 FaviconService* favicon_service = | 213 FaviconService* favicon_service = |
| 213 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 214 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 214 // Fall back to the default icons if the service isn't available. | 215 // Fall back to the default icons if the service isn't available. |
| 215 if (favicon_service == NULL) { | 216 if (favicon_service == NULL) { |
| 216 LoadDefaultImage(request_id); | 217 LoadDefaultImage(request_id); |
| 217 return; | 218 return; |
| 218 } | 219 } |
| 219 | 220 |
| 220 GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL(); | 221 GURL favicon_url = extensions::AppLauncherInfo::GetFullLaunchURL( |
| 222 GetData(request_id)->extension); |
| 221 favicon_service->GetRawFaviconForURL( | 223 favicon_service->GetRawFaviconForURL( |
| 222 FaviconService::FaviconForURLParams( | 224 FaviconService::FaviconForURLParams( |
| 223 profile_, favicon_url, history::FAVICON, gfx::kFaviconSize), | 225 profile_, favicon_url, history::FAVICON, gfx::kFaviconSize), |
| 224 ui::SCALE_FACTOR_100P, | 226 ui::SCALE_FACTOR_100P, |
| 225 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, | 227 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, |
| 226 base::Unretained(this), request_id), | 228 base::Unretained(this), request_id), |
| 227 &cancelable_task_tracker_); | 229 &cancelable_task_tracker_); |
| 228 } | 230 } |
| 229 | 231 |
| 230 void ExtensionIconSource::OnFaviconDataAvailable( | 232 void ExtensionIconSource::OnFaviconDataAvailable( |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 339 |
| 338 void ExtensionIconSource::ClearData(int request_id) { | 340 void ExtensionIconSource::ClearData(int request_id) { |
| 339 std::map<int, ExtensionIconRequest*>::iterator i = | 341 std::map<int, ExtensionIconRequest*>::iterator i = |
| 340 request_map_.find(request_id); | 342 request_map_.find(request_id); |
| 341 if (i == request_map_.end()) | 343 if (i == request_map_.end()) |
| 342 return; | 344 return; |
| 343 | 345 |
| 344 delete i->second; | 346 delete i->second; |
| 345 request_map_.erase(i); | 347 request_map_.erase(i); |
| 346 } | 348 } |
| OLD | NEW |