Chromium Code Reviews| 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/views/ash/launcher/launcher_app_icon_loader.h" | 5 #include "chrome/browser/ui/views/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" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 if (i->second == id) | 38 if (i->second == id) |
| 39 return; // Already loading the image. | 39 return; // Already loading the image. |
| 40 } | 40 } |
| 41 | 41 |
| 42 const extensions::Extension* extension = GetExtensionByID(profile_, id); | 42 const extensions::Extension* extension = GetExtensionByID(profile_, id); |
| 43 if (!extension) | 43 if (!extension) |
| 44 return; | 44 return; |
| 45 if (!image_loader_.get()) | 45 if (!image_loader_.get()) |
| 46 image_loader_.reset(new ImageLoadingTracker(this)); | 46 image_loader_.reset(new ImageLoadingTracker(this)); |
| 47 map_[image_loader_->next_id()] = id; | 47 map_[image_loader_->next_id()] = id; |
| 48 ExtensionResource extensionResource = | |
|
Aaron Boodman
2012/08/06 03:09:34
extension_resource
sschmitz
2012/08/07 17:59:00
Done.
| |
| 49 extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALL, | |
| 50 ExtensionIconSet::MATCH_BIGGER); | |
| 48 image_loader_->LoadImage( | 51 image_loader_->LoadImage( |
| 49 extension, | 52 extension, |
| 50 extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALL, | 53 extensionResource, |
| 51 ExtensionIconSet::MATCH_BIGGER), | |
| 52 gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALL, | 54 gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALL, |
| 53 ExtensionIconSet::EXTENSION_ICON_SMALL), | 55 ExtensionIconSet::EXTENSION_ICON_SMALL), |
| 54 ImageLoadingTracker::CACHE); | 56 extensionResource.empty() ? ImageLoadingTracker::DONT_CACHE : |
| 57 ImageLoadingTracker::CACHE); | |
| 55 } | 58 } |
| 56 | 59 |
| 57 void LauncherAppIconLoader::OnImageLoaded(const gfx::Image& image, | 60 void LauncherAppIconLoader::OnImageLoaded(const gfx::Image& image, |
| 58 const std::string& extension_id, | 61 const std::string& extension_id, |
| 59 int index) { | 62 int index) { |
| 60 ImageLoaderIDToExtensionIDMap::iterator i = map_.find(index); | 63 ImageLoaderIDToExtensionIDMap::iterator i = map_.find(index); |
| 61 if (i == map_.end()) | 64 if (i == map_.end()) |
| 62 return; // The tab has since been removed, do nothing. | 65 return; // The tab has since been removed, do nothing. |
| 63 | 66 |
| 64 std::string id = i->second; | 67 std::string id = i->second; |
| 65 map_.erase(i); | 68 map_.erase(i); |
| 66 if (image.IsEmpty()) | 69 if (image.IsEmpty()) |
| 67 host_->SetAppImage(id, extensions::Extension::GetDefaultIcon(true)); | 70 host_->SetAppImage(id, extensions::Extension::GetDefaultIcon(true)); |
| 68 else | 71 else |
| 69 host_->SetAppImage(id, *image.ToImageSkia()); | 72 host_->SetAppImage(id, *image.ToImageSkia()); |
| 70 } | 73 } |
| OLD | NEW |