| 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/api/icons/icons_handler.h" | 22 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 23 #include "chrome/common/extensions/app_launcher_info.h" |
| 23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 25 #include "chrome/common/extensions/extension_resource.h" | 26 #include "chrome/common/extensions/extension_resource.h" |
| 26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.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" |
| 32 #include "ui/base/resource/resource_bundle.h" | 33 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 210 |
| 210 void ExtensionIconSource::LoadFaviconImage(int request_id) { | 211 void ExtensionIconSource::LoadFaviconImage(int request_id) { |
| 211 FaviconService* favicon_service = | 212 FaviconService* favicon_service = |
| 212 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 213 FaviconServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
| 213 // Fall back to the default icons if the service isn't available. | 214 // Fall back to the default icons if the service isn't available. |
| 214 if (favicon_service == NULL) { | 215 if (favicon_service == NULL) { |
| 215 LoadDefaultImage(request_id); | 216 LoadDefaultImage(request_id); |
| 216 return; | 217 return; |
| 217 } | 218 } |
| 218 | 219 |
| 219 GURL favicon_url = GetData(request_id)->extension->GetFullLaunchURL(); | 220 GURL favicon_url = extensions::AppLauncherInfo::GetFullLaunchURL( |
| 221 GetData(request_id)->extension); |
| 220 favicon_service->GetRawFaviconForURL( | 222 favicon_service->GetRawFaviconForURL( |
| 221 FaviconService::FaviconForURLParams( | 223 FaviconService::FaviconForURLParams( |
| 222 profile_, favicon_url, history::FAVICON, gfx::kFaviconSize), | 224 profile_, favicon_url, history::FAVICON, gfx::kFaviconSize), |
| 223 ui::SCALE_FACTOR_100P, | 225 ui::SCALE_FACTOR_100P, |
| 224 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, | 226 base::Bind(&ExtensionIconSource::OnFaviconDataAvailable, |
| 225 base::Unretained(this), request_id), | 227 base::Unretained(this), request_id), |
| 226 &cancelable_task_tracker_); | 228 &cancelable_task_tracker_); |
| 227 } | 229 } |
| 228 | 230 |
| 229 void ExtensionIconSource::OnFaviconDataAvailable( | 231 void ExtensionIconSource::OnFaviconDataAvailable( |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 338 |
| 337 void ExtensionIconSource::ClearData(int request_id) { | 339 void ExtensionIconSource::ClearData(int request_id) { |
| 338 std::map<int, ExtensionIconRequest*>::iterator i = | 340 std::map<int, ExtensionIconRequest*>::iterator i = |
| 339 request_map_.find(request_id); | 341 request_map_.find(request_id); |
| 340 if (i == request_map_.end()) | 342 if (i == request_map_.end()) |
| 341 return; | 343 return; |
| 342 | 344 |
| 343 delete i->second; | 345 delete i->second; |
| 344 request_map_.erase(i); | 346 request_map_.erase(i); |
| 345 } | 347 } |
| OLD | NEW |