Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Unified Diff: chrome/browser/ui/app_list/search/extension_app_result.cc

Issue 2817293002: Fix randomly disappearing icons in app list recent view. (Closed)
Patch Set: fix win compilation Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/search/extension_app_result.h ('k') | extensions/browser/extension_icon_image.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..376c4a1fdd13501c6d6f9f21731a326aa60dbc87 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();
+ CreateOrUpdateIcon();
StartObservingExtensionRegistry();
}
@@ -57,6 +50,23 @@ ExtensionAppResult::~ExtensionAppResult() {
StopObservingExtensionRegistry();
}
+void ExtensionAppResult::CreateOrUpdateIcon() {
+ 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.
+ CreateOrUpdateIcon();
}
void ExtensionAppResult::OnShutdown(extensions::ExtensionRegistry* registry) {
« no previous file with comments | « chrome/browser/ui/app_list/search/extension_app_result.h ('k') | extensions/browser/extension_icon_image.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698