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/aura/launcher/launcher_icon_loader.h" | 5 #include "chrome/browser/ui/views/aura/launcher/launcher_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_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
11 #include "chrome/common/extensions/extension_resource.h" | 11 #include "chrome/common/extensions/extension_resource.h" |
12 #include "content/public/browser/web_contents.h" | 12 #include "content/public/browser/web_contents.h" |
| 13 #include "ui/gfx/image/image.h" |
13 | 14 |
14 LauncherIconLoader::LauncherIconLoader(Profile* profile, | 15 LauncherIconLoader::LauncherIconLoader(Profile* profile, |
15 LauncherUpdater* icon_updater) | 16 LauncherUpdater* icon_updater) |
16 : profile_(profile), | 17 : profile_(profile), |
17 icon_updater_(icon_updater) { | 18 icon_updater_(icon_updater) { |
18 } | 19 } |
19 | 20 |
20 LauncherIconLoader::~LauncherIconLoader() { | 21 LauncherIconLoader::~LauncherIconLoader() { |
21 } | 22 } |
22 | 23 |
(...skipping 17 matching lines...) Expand all Loading... |
40 const Extension* extension = GetExtensionForTab(tab); | 41 const Extension* extension = GetExtensionForTab(tab); |
41 image_loader_->LoadImage( | 42 image_loader_->LoadImage( |
42 extension, | 43 extension, |
43 extension->GetIconResource(Extension::EXTENSION_ICON_SMALL, | 44 extension->GetIconResource(Extension::EXTENSION_ICON_SMALL, |
44 ExtensionIconSet::MATCH_BIGGER), | 45 ExtensionIconSet::MATCH_BIGGER), |
45 gfx::Size(Extension::EXTENSION_ICON_SMALL, | 46 gfx::Size(Extension::EXTENSION_ICON_SMALL, |
46 Extension::EXTENSION_ICON_SMALL), | 47 Extension::EXTENSION_ICON_SMALL), |
47 ImageLoadingTracker::CACHE); | 48 ImageLoadingTracker::CACHE); |
48 } | 49 } |
49 | 50 |
50 void LauncherIconLoader::OnImageLoaded(SkBitmap* image, | 51 void LauncherIconLoader::OnImageLoaded(const gfx::Image* image, |
51 const ExtensionResource& resource, | 52 const std::string& extension_id, |
52 int index) { | 53 int index) { |
53 ImageLoaderIDToTabMap::iterator i = image_loader_id_to_tab_map_.find(index); | 54 ImageLoaderIDToTabMap::iterator i = image_loader_id_to_tab_map_.find(index); |
54 if (i == image_loader_id_to_tab_map_.end()) | 55 if (i == image_loader_id_to_tab_map_.end()) |
55 return; // The tab has since been removed, do nothing. | 56 return; // The tab has since been removed, do nothing. |
56 | 57 |
57 TabContentsWrapper* tab = i->second; | 58 TabContentsWrapper* tab = i->second; |
58 image_loader_id_to_tab_map_.erase(i); | 59 image_loader_id_to_tab_map_.erase(i); |
59 icon_updater_->SetAppImage(tab, image); | 60 icon_updater_->SetAppImage(tab, image ? image->ToSkBitmap() : NULL); |
60 } | 61 } |
61 | 62 |
62 void LauncherIconLoader::RemoveFromImageLoaderMap(TabContentsWrapper* tab) { | 63 void LauncherIconLoader::RemoveFromImageLoaderMap(TabContentsWrapper* tab) { |
63 for (ImageLoaderIDToTabMap::iterator i = image_loader_id_to_tab_map_.begin(); | 64 for (ImageLoaderIDToTabMap::iterator i = image_loader_id_to_tab_map_.begin(); |
64 i != image_loader_id_to_tab_map_.end(); ++i) { | 65 i != image_loader_id_to_tab_map_.end(); ++i) { |
65 if (i->second == tab) { | 66 if (i->second == tab) { |
66 image_loader_id_to_tab_map_.erase(i); | 67 image_loader_id_to_tab_map_.erase(i); |
67 break; | 68 break; |
68 } | 69 } |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
72 const Extension* LauncherIconLoader::GetExtensionForTab( | 73 const Extension* LauncherIconLoader::GetExtensionForTab( |
73 TabContentsWrapper* tab) { | 74 TabContentsWrapper* tab) { |
74 ExtensionService* extension_service = profile_->GetExtensionService(); | 75 ExtensionService* extension_service = profile_->GetExtensionService(); |
75 if (!extension_service) | 76 if (!extension_service) |
76 return NULL; | 77 return NULL; |
77 return extension_service->GetInstalledApp(tab->web_contents()->GetURL()); | 78 return extension_service->GetInstalledApp(tab->web_contents()->GetURL()); |
78 } | 79 } |
OLD | NEW |