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

Side by Side 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: forgot UpdateIcon to match previous logic 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list/search/extension_app_result.h" 5 #include "chrome/browser/ui/app_list/search/extension_app_result.h"
6 6
7 #include "base/metrics/user_metrics.h" 7 #include "base/metrics/user_metrics.h"
8 #include "chrome/browser/extensions/extension_util.h" 8 #include "chrome/browser/extensions/extension_util.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 10 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
(...skipping 23 matching lines...) Expand all
34 : AppResult(profile, app_id, controller, is_recommendation) { 34 : AppResult(profile, app_id, controller, is_recommendation) {
35 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id).spec()); 35 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id).spec());
36 36
37 const extensions::Extension* extension = 37 const extensions::Extension* extension =
38 extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension( 38 extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension(
39 app_id); 39 app_id);
40 DCHECK(extension); 40 DCHECK(extension);
41 41
42 is_platform_app_ = extension->is_platform_app(); 42 is_platform_app_ = extension->is_platform_app();
43 43
44 icon_.reset( 44 MaybeCreateIcon();
45 new extensions::IconImage(profile,
46 extension,
47 extensions::IconsInfo::GetIcons(extension),
48 GetPreferredIconDimension(),
49 extensions::util::GetDefaultAppIcon(),
50 this));
51 UpdateIcon();
52 45
53 StartObservingExtensionRegistry(); 46 StartObservingExtensionRegistry();
54 } 47 }
55 48
56 ExtensionAppResult::~ExtensionAppResult() { 49 ExtensionAppResult::~ExtensionAppResult() {
57 StopObservingExtensionRegistry(); 50 StopObservingExtensionRegistry();
58 } 51 }
59 52
53 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!
54 if (icon_ && icon_->is_valid()) {
55 UpdateIcon();
56 return;
57 }
58
59 const extensions::Extension* extension =
60 extensions::ExtensionRegistry::Get(profile())->GetInstalledExtension(
61 app_id());
62 DCHECK(extension);
63
64 icon_ = base::MakeUnique<extensions::IconImage>(
65 profile(), extension, extensions::IconsInfo::GetIcons(extension),
66 GetPreferredIconDimension(), extensions::util::GetDefaultAppIcon(), this);
67 UpdateIcon();
68 }
69
60 void ExtensionAppResult::Open(int event_flags) { 70 void ExtensionAppResult::Open(int event_flags) {
61 RecordHistogram(APP_SEARCH_RESULT); 71 RecordHistogram(APP_SEARCH_RESULT);
62 const extensions::Extension* extension = 72 const extensions::Extension* extension =
63 extensions::ExtensionRegistry::Get(profile())->GetInstalledExtension( 73 extensions::ExtensionRegistry::Get(profile())->GetInstalledExtension(
64 app_id()); 74 app_id());
65 if (!extension) 75 if (!extension)
66 return; 76 return;
67 77
68 // Don't auto-enable apps that cannot be launched. 78 // Don't auto-enable apps that cannot be launched.
69 if (!extensions::util::IsAppLaunchable(app_id(), profile())) 79 if (!extensions::util::IsAppLaunchable(app_id(), profile()))
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 181 }
172 182
173 void ExtensionAppResult::ExtensionEnableFlowAborted(bool user_initiated) { 183 void ExtensionAppResult::ExtensionEnableFlowAborted(bool user_initiated) {
174 extension_enable_flow_.reset(); 184 extension_enable_flow_.reset();
175 controller()->OnCloseChildDialog(); 185 controller()->OnCloseChildDialog();
176 } 186 }
177 187
178 void ExtensionAppResult::OnExtensionLoaded( 188 void ExtensionAppResult::OnExtensionLoaded(
179 content::BrowserContext* browser_context, 189 content::BrowserContext* browser_context,
180 const extensions::Extension* extension) { 190 const extensions::Extension* extension) {
181 UpdateIcon(); 191 // Old |icon_| might be invalidated for forever in case extension gets
192 // updated. In this case we need re-create icon again.
193 MaybeCreateIcon();
182 } 194 }
183 195
184 void ExtensionAppResult::OnShutdown(extensions::ExtensionRegistry* registry) { 196 void ExtensionAppResult::OnShutdown(extensions::ExtensionRegistry* registry) {
185 DCHECK_EQ(extension_registry_, registry); 197 DCHECK_EQ(extension_registry_, registry);
186 StopObservingExtensionRegistry(); 198 StopObservingExtensionRegistry();
187 } 199 }
188 200
189 } // namespace app_list 201 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698