Chromium Code Reviews| Index: chrome/browser/ui/app_list/search/extension_app_result.cc |
| diff --git a/chrome/browser/ui/app_list/search/extension_app_result.cc b/chrome/browser/ui/app_list/search/extension_app_result.cc |
| index fdbdd5dbf7ec98087e6bd41c825840a3672f4280..d1960b9e6db6af291ec124cf84230bc5a2b5aceb 100644 |
| --- a/chrome/browser/ui/app_list/search/extension_app_result.cc |
| +++ b/chrome/browser/ui/app_list/search/extension_app_result.cc |
| @@ -41,14 +41,7 @@ ExtensionAppResult::ExtensionAppResult(Profile* profile, |
| is_platform_app_ = extension->is_platform_app(); |
| - icon_.reset( |
| - new extensions::IconImage(profile, |
| - extension, |
| - extensions::IconsInfo::GetIcons(extension), |
| - GetPreferredIconDimension(), |
| - extensions::util::GetDefaultAppIcon(), |
| - this)); |
| - UpdateIcon(); |
| + MaybeCreateIcon(); |
| StartObservingExtensionRegistry(); |
| } |
| @@ -57,6 +50,23 @@ ExtensionAppResult::~ExtensionAppResult() { |
| StopObservingExtensionRegistry(); |
| } |
| +void ExtensionAppResult::MaybeCreateIcon() { |
|
Devlin
2017/04/15 00:42:54
drive-by: perhaps this should be called CreateOrUp
khmel
2017/04/15 20:21:28
Nice name, thanks!
|
| + if (icon_ && icon_->is_valid()) { |
| + UpdateIcon(); |
| + return; |
| + } |
| + |
| + const extensions::Extension* extension = |
| + extensions::ExtensionRegistry::Get(profile())->GetInstalledExtension( |
| + app_id()); |
| + DCHECK(extension); |
| + |
| + icon_ = base::MakeUnique<extensions::IconImage>( |
| + profile(), extension, extensions::IconsInfo::GetIcons(extension), |
| + GetPreferredIconDimension(), extensions::util::GetDefaultAppIcon(), this); |
| + UpdateIcon(); |
| +} |
| + |
| void ExtensionAppResult::Open(int event_flags) { |
| RecordHistogram(APP_SEARCH_RESULT); |
| const extensions::Extension* extension = |
| @@ -178,7 +188,9 @@ void ExtensionAppResult::ExtensionEnableFlowAborted(bool user_initiated) { |
| void ExtensionAppResult::OnExtensionLoaded( |
| content::BrowserContext* browser_context, |
| const extensions::Extension* extension) { |
| - UpdateIcon(); |
| + // Old |icon_| might be invalidated for forever in case extension gets |
| + // updated. In this case we need re-create icon again. |
| + MaybeCreateIcon(); |
| } |
| void ExtensionAppResult::OnShutdown(extensions::ExtensionRegistry* registry) { |