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

Side by Side Diff: chrome/browser/ui/app_list/search/extension_app_result.cc

Issue 2830453002: [Merge M58] Fix randomly disappearing icons in app list recent view. (Closed)
Patch Set: 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 "chrome/browser/extensions/extension_util.h" 7 #include "chrome/browser/extensions/extension_util.h"
8 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 9 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
10 #include "chrome/browser/ui/app_list/extension_app_context_menu.h" 10 #include "chrome/browser/ui/app_list/extension_app_context_menu.h"
(...skipping 26 matching lines...) Expand all
37 : AppResult(profile, app_id, controller, is_recommendation) { 37 : AppResult(profile, app_id, controller, is_recommendation) {
38 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id).spec()); 38 set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id).spec());
39 39
40 const extensions::Extension* extension = 40 const extensions::Extension* extension =
41 extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension( 41 extensions::ExtensionRegistry::Get(profile)->GetInstalledExtension(
42 app_id); 42 app_id);
43 DCHECK(extension); 43 DCHECK(extension);
44 44
45 is_platform_app_ = extension->is_platform_app(); 45 is_platform_app_ = extension->is_platform_app();
46 46
47 icon_.reset( 47 CreateOrUpdateIcon();
48 new extensions::IconImage(profile,
49 extension,
50 extensions::IconsInfo::GetIcons(extension),
51 GetPreferredIconDimension(),
52 extensions::util::GetDefaultAppIcon(),
53 this));
54 UpdateIcon();
55 48
56 StartObservingExtensionRegistry(); 49 StartObservingExtensionRegistry();
57 } 50 }
58 51
59 ExtensionAppResult::~ExtensionAppResult() { 52 ExtensionAppResult::~ExtensionAppResult() {
60 StopObservingExtensionRegistry(); 53 StopObservingExtensionRegistry();
61 } 54 }
62 55
56 void ExtensionAppResult::CreateOrUpdateIcon() {
57 if (icon_ && icon_->is_valid()) {
58 UpdateIcon();
59 return;
60 }
61
62 const extensions::Extension* extension =
63 extensions::ExtensionRegistry::Get(profile())->GetInstalledExtension(
64 app_id());
65 DCHECK(extension);
66
67 icon_ = base::MakeUnique<extensions::IconImage>(
68 profile(), extension, extensions::IconsInfo::GetIcons(extension),
69 GetPreferredIconDimension(), extensions::util::GetDefaultAppIcon(), this);
70 UpdateIcon();
71 }
72
63 void ExtensionAppResult::Open(int event_flags) { 73 void ExtensionAppResult::Open(int event_flags) {
64 RecordHistogram(APP_SEARCH_RESULT); 74 RecordHistogram(APP_SEARCH_RESULT);
65 const extensions::Extension* extension = 75 const extensions::Extension* extension =
66 extensions::ExtensionRegistry::Get(profile())->GetInstalledExtension( 76 extensions::ExtensionRegistry::Get(profile())->GetInstalledExtension(
67 app_id()); 77 app_id());
68 if (!extension) 78 if (!extension)
69 return; 79 return;
70 80
71 // Don't auto-enable apps that cannot be launched. 81 // Don't auto-enable apps that cannot be launched.
72 if (!extensions::util::IsAppLaunchable(app_id(), profile())) 82 if (!extensions::util::IsAppLaunchable(app_id(), profile()))
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 187 }
178 188
179 void ExtensionAppResult::ExtensionEnableFlowAborted(bool user_initiated) { 189 void ExtensionAppResult::ExtensionEnableFlowAborted(bool user_initiated) {
180 extension_enable_flow_.reset(); 190 extension_enable_flow_.reset();
181 controller()->OnCloseChildDialog(); 191 controller()->OnCloseChildDialog();
182 } 192 }
183 193
184 void ExtensionAppResult::OnExtensionLoaded( 194 void ExtensionAppResult::OnExtensionLoaded(
185 content::BrowserContext* browser_context, 195 content::BrowserContext* browser_context,
186 const extensions::Extension* extension) { 196 const extensions::Extension* extension) {
187 UpdateIcon(); 197 // Old |icon_| might be invalidated for forever in case extension gets
198 // updated. In this case we need re-create icon again.
199 CreateOrUpdateIcon();
188 } 200 }
189 201
190 void ExtensionAppResult::OnShutdown(extensions::ExtensionRegistry* registry) { 202 void ExtensionAppResult::OnShutdown(extensions::ExtensionRegistry* registry) {
191 DCHECK_EQ(extension_registry_, registry); 203 DCHECK_EQ(extension_registry_, registry);
192 StopObservingExtensionRegistry(); 204 StopObservingExtensionRegistry();
193 } 205 }
194 206
195 } // namespace app_list 207 } // namespace app_list
OLDNEW
« 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