| 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_wrapper.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_resource.h" | 11 #include "chrome/common/extensions/extension_resource.h" |
| 12 #include "chrome/common/extensions/extension_set.h" | 12 #include "chrome/common/extensions/extension_set.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 | 14 |
| 15 LauncherAppIconLoader::LauncherAppIconLoader( | 15 LauncherAppIconLoader::LauncherAppIconLoader( |
| 16 Profile* profile, | 16 Profile* profile, |
| 17 ChromeLauncherController* controller) | 17 ChromeLauncherController* controller) |
| 18 : profile_(profile), | 18 : profile_(profile), |
| 19 host_(controller) { | 19 host_(controller) { |
| 20 } | 20 } |
| 21 | 21 |
| 22 LauncherAppIconLoader::~LauncherAppIconLoader() { | 22 LauncherAppIconLoader::~LauncherAppIconLoader() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 std::string LauncherAppIconLoader::GetAppID(TabContentsWrapper* tab) { | 25 std::string LauncherAppIconLoader::GetAppID(TabContents* tab) { |
| 26 const extensions::Extension* extension = GetExtensionForTab(tab); | 26 const extensions::Extension* extension = GetExtensionForTab(tab); |
| 27 return extension ? extension->id() : std::string(); | 27 return extension ? extension->id() : std::string(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 bool LauncherAppIconLoader::IsValidID(const std::string& id) { | 30 bool LauncherAppIconLoader::IsValidID(const std::string& id) { |
| 31 return GetExtensionByID(id) != NULL; | 31 return GetExtensionByID(id) != NULL; |
| 32 } | 32 } |
| 33 | 33 |
| 34 void LauncherAppIconLoader::FetchImage(const std::string& id) { | 34 void LauncherAppIconLoader::FetchImage(const std::string& id) { |
| 35 for (ImageLoaderIDToExtensionIDMap::const_iterator i = map_.begin(); | 35 for (ImageLoaderIDToExtensionIDMap::const_iterator i = map_.begin(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 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, NULL); |
| 67 else | 67 else |
| 68 host_->SetAppImage(id, image.ToSkBitmap()); | 68 host_->SetAppImage(id, image.ToSkBitmap()); |
| 69 } | 69 } |
| 70 | 70 |
| 71 const extensions::Extension* LauncherAppIconLoader::GetExtensionForTab( | 71 const extensions::Extension* LauncherAppIconLoader::GetExtensionForTab( |
| 72 TabContentsWrapper* 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 |