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 26 matching lines...) Expand all Loading... |
37 if (i->second == id) | 37 if (i->second == id) |
38 return; // Already loading the image. | 38 return; // Already loading the image. |
39 } | 39 } |
40 | 40 |
41 const extensions::Extension* extension = GetExtensionByID(id); | 41 const extensions::Extension* extension = GetExtensionByID(id); |
42 if (!extension) | 42 if (!extension) |
43 return; | 43 return; |
44 if (!image_loader_.get()) | 44 if (!image_loader_.get()) |
45 image_loader_.reset(new ImageLoadingTracker(this)); | 45 image_loader_.reset(new ImageLoadingTracker(this)); |
46 map_[image_loader_->next_id()] = id; | 46 map_[image_loader_->next_id()] = id; |
47 image_loader_->LoadImage( | 47 |
| 48 image_loader_->LoadDIPImage( |
48 extension, | 49 extension, |
49 extension->GetIconResource(ExtensionIconSet::EXTENSION_ICON_SMALL, | 50 ExtensionIconSet::EXTENSION_ICON_SMALL, |
50 ExtensionIconSet::MATCH_BIGGER), | |
51 gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALL, | 51 gfx::Size(ExtensionIconSet::EXTENSION_ICON_SMALL, |
52 ExtensionIconSet::EXTENSION_ICON_SMALL), | 52 ExtensionIconSet::EXTENSION_ICON_SMALL), |
53 ImageLoadingTracker::CACHE); | 53 ImageLoadingTracker::CACHE); |
54 } | 54 } |
55 | 55 |
56 void LauncherAppIconLoader::OnImageLoaded(const gfx::Image& image, | 56 void LauncherAppIconLoader::OnImageLoaded(const gfx::Image& image, |
57 const std::string& extension_id, | 57 const std::string& extension_id, |
58 int index) { | 58 int index) { |
59 ImageLoaderIDToExtensionIDMap::iterator i = map_.find(index); | 59 ImageLoaderIDToExtensionIDMap::iterator i = map_.find(index); |
60 if (i == map_.end()) | 60 if (i == map_.end()) |
61 return; // The tab has since been removed, do nothing. | 61 return; // The tab has since been removed, do nothing. |
62 | 62 |
63 std::string id = i->second; | 63 std::string id = i->second; |
64 map_.erase(i); | 64 map_.erase(i); |
65 if (image.IsEmpty()) | 65 if (image.IsEmpty()) |
66 host_->SetAppImage(id, NULL); | 66 host_->SetAppImage(id, extensions::Extension::GetDefaultIcon(true)); |
67 else | 67 else |
68 host_->SetAppImage(id, image.ToSkBitmap()); | 68 host_->SetAppImage(id, *image.ToImageSkia()); |
69 } | 69 } |
70 | 70 |
71 const extensions::Extension* LauncherAppIconLoader::GetExtensionForTab( | 71 const extensions::Extension* LauncherAppIconLoader::GetExtensionForTab( |
72 TabContents* tab) { | 72 TabContents* tab) { |
73 ExtensionService* extension_service = profile_->GetExtensionService(); | 73 ExtensionService* extension_service = profile_->GetExtensionService(); |
74 if (!extension_service) | 74 if (!extension_service) |
75 return NULL; | 75 return NULL; |
76 return extension_service->GetInstalledApp(tab->web_contents()->GetURL()); | 76 return extension_service->GetInstalledApp(tab->web_contents()->GetURL()); |
77 } | 77 } |
78 | 78 |
79 const extensions::Extension* LauncherAppIconLoader::GetExtensionByID( | 79 const extensions::Extension* LauncherAppIconLoader::GetExtensionByID( |
80 const std::string& id) { | 80 const std::string& id) { |
81 ExtensionService* service = profile_->GetExtensionService(); | 81 ExtensionService* service = profile_->GetExtensionService(); |
82 if (!service) | 82 if (!service) |
83 return NULL; | 83 return NULL; |
84 return service->extensions()->GetByID(id); | 84 return service->extensions()->GetByID(id); |
85 } | 85 } |
OLD | NEW |