| 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/ash/launcher/launcher_app_icon_loader.h" | 5 #include "chrome/browser/ui/ash/launcher/launcher_app_icon_loader.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| 11 #include "chrome/common/extensions/extension_constants.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 const extensions::Extension* GetExtensionByID(Profile* profile, | 15 const extensions::Extension* GetExtensionByID(Profile* profile, |
| 15 const std::string& id) { | 16 const std::string& id) { |
| 16 ExtensionService* service = profile->GetExtensionService(); | 17 ExtensionService* service = profile->GetExtensionService(); |
| 17 if (!service) | 18 if (!service) |
| 18 return NULL; | 19 return NULL; |
| 19 return service->extensions()->GetByID(id); | 20 return service->extensions()->GetByID(id); |
| 20 } | 21 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 40 } | 41 } |
| 41 | 42 |
| 42 const extensions::Extension* extension = GetExtensionByID(profile_, id); | 43 const extensions::Extension* extension = GetExtensionByID(profile_, id); |
| 43 if (!extension) | 44 if (!extension) |
| 44 return; | 45 return; |
| 45 if (!image_loader_.get()) | 46 if (!image_loader_.get()) |
| 46 image_loader_.reset(new ImageLoadingTracker(this)); | 47 image_loader_.reset(new ImageLoadingTracker(this)); |
| 47 map_[image_loader_->next_id()] = id; | 48 map_[image_loader_->next_id()] = id; |
| 48 image_loader_->LoadImage( | 49 image_loader_->LoadImage( |
| 49 extension, | 50 extension, |
| 50 extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALL, | 51 extension->GetIconResource(extension_misc::EXTENSION_ICON_SMALL, |
| 51 ExtensionIconSet::MATCH_BIGGER), | 52 ExtensionIconSet::MATCH_BIGGER), |
| 52 gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALL, | 53 gfx::Size(extension_misc::EXTENSION_ICON_SMALL, |
| 53 ExtensionIconSet::EXTENSION_ICON_SMALL), | 54 extension_misc::EXTENSION_ICON_SMALL), |
| 54 ImageLoadingTracker::CACHE); | 55 ImageLoadingTracker::CACHE); |
| 55 } | 56 } |
| 56 | 57 |
| 57 void LauncherAppIconLoader::OnImageLoaded(const gfx::Image& image, | 58 void LauncherAppIconLoader::OnImageLoaded(const gfx::Image& image, |
| 58 const std::string& extension_id, | 59 const std::string& extension_id, |
| 59 int index) { | 60 int index) { |
| 60 ImageLoaderIDToExtensionIDMap::iterator i = map_.find(index); | 61 ImageLoaderIDToExtensionIDMap::iterator i = map_.find(index); |
| 61 if (i == map_.end()) | 62 if (i == map_.end()) |
| 62 return; // The tab has since been removed, do nothing. | 63 return; // The tab has since been removed, do nothing. |
| 63 | 64 |
| 64 std::string id = i->second; | 65 std::string id = i->second; |
| 65 map_.erase(i); | 66 map_.erase(i); |
| 66 if (image.IsEmpty()) | 67 if (image.IsEmpty()) |
| 67 host_->SetAppImage(id, extensions::Extension::GetDefaultIcon(true)); | 68 host_->SetAppImage(id, extensions::Extension::GetDefaultIcon(true)); |
| 68 else | 69 else |
| 69 host_->SetAppImage(id, *image.ToImageSkia()); | 70 host_->SetAppImage(id, *image.ToImageSkia()); |
| 70 } | 71 } |
| OLD | NEW |