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

Side by Side Diff: chrome/browser/ui/app_list/extension_app_item.cc

Issue 10868003: chromeos: Fix pixelated icons in app list and launcher (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase on tony's cl, get rid of icon cache and worker thread Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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/app_list/extension_app_item.h" 5 #include "chrome/browser/ui/app_list/extension_app_item.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_prefs.h" 8 #include "chrome/browser/extensions/extension_prefs.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ExtensionAppItem::~ExtensionAppItem() { 132 ExtensionAppItem::~ExtensionAppItem() {
133 } 133 }
134 134
135 const Extension* ExtensionAppItem::GetExtension() const { 135 const Extension* ExtensionAppItem::GetExtension() const {
136 const Extension* extension = 136 const Extension* extension =
137 profile_->GetExtensionService()->GetInstalledExtension(extension_id_); 137 profile_->GetExtensionService()->GetInstalledExtension(extension_id_);
138 return extension; 138 return extension;
139 } 139 }
140 140
141 void ExtensionAppItem::LoadImage(const Extension* extension) { 141 void ExtensionAppItem::LoadImage(const Extension* extension) {
142 tracker_.reset(new ImageLoadingTracker(this)); 142 icon_.reset(new extensions::IconImage(
143 tracker_->LoadImage(extension, 143 extension,
144 extension->GetIconResource( 144 extension->icons(),
145 extension_misc::EXTENSION_ICON_LARGE, 145 extension_misc::EXTENSION_ICON_MEDIUM,
pkotwicz 2012/09/07 19:24:49 Just to confirm, you are changing the size of the
xiyuan 2012/09/07 20:05:59 This is actually the right size to use. We show 48
146 ExtensionIconSet::MATCH_BIGGER), 146 Extension::GetDefaultIcon(true),
147 gfx::Size(extension_misc::EXTENSION_ICON_LARGE, 147 this));
148 extension_misc::EXTENSION_ICON_LARGE), 148 OnExtensionIconImageChanged(icon_.get());
tbarzic 2012/09/07 17:14:07 optional: I think SetIcon(icon_->image_skia()) wou
xiyuan 2012/09/07 20:05:59 Done.
149 ImageLoadingTracker::DONT_CACHE);
150 } 149 }
151 150
152 void ExtensionAppItem::ShowExtensionOptions() { 151 void ExtensionAppItem::ShowExtensionOptions() {
153 const Extension* extension = GetExtension(); 152 const Extension* extension = GetExtension();
154 if (!extension) 153 if (!extension)
155 return; 154 return;
156 155
157 chrome::NavigateParams params(profile_, 156 chrome::NavigateParams params(profile_,
158 extension->options_url(), 157 extension->options_url(),
159 content::PAGE_TRANSITION_LINK); 158 content::PAGE_TRANSITION_LINK);
(...skipping 11 matching lines...) Expand all
171 chrome::Navigate(&params); 170 chrome::Navigate(&params);
172 } 171 }
173 172
174 void ExtensionAppItem::StartExtensionUninstall() { 173 void ExtensionAppItem::StartExtensionUninstall() {
175 // ExtensionUninstall deletes itself when done or aborted. 174 // ExtensionUninstall deletes itself when done or aborted.
176 ExtensionUninstaller* uninstaller = new ExtensionUninstaller(profile_, 175 ExtensionUninstaller* uninstaller = new ExtensionUninstaller(profile_,
177 extension_id_); 176 extension_id_);
178 uninstaller->Run(); 177 uninstaller->Run();
179 } 178 }
180 179
181 void ExtensionAppItem::OnImageLoaded(const gfx::Image& image, 180 void ExtensionAppItem::OnExtensionIconImageChanged(
182 const std::string& extension_id, 181 extensions::IconImage* image) {
183 int tracker_index) { 182 DCHECK(icon_.get() == image);
184 if (!image.IsEmpty()) { 183 SetIcon(icon_->image_skia());
185 gfx::ImageSkia image_skia = *image.ToImageSkia();
186 image_skia.MakeThreadSafe();
187 SetIcon(image_skia);
188 } else {
189 gfx::ImageSkia image_skia(Extension::GetDefaultIcon(true /* is_app */));
190 image_skia.MakeThreadSafe();
191 SetIcon(image_skia);
192 }
193 } 184 }
194 185
195 bool ExtensionAppItem::IsItemForCommandIdDynamic(int command_id) const { 186 bool ExtensionAppItem::IsItemForCommandIdDynamic(int command_id) const {
196 return command_id == TOGGLE_PIN; 187 return command_id == TOGGLE_PIN;
197 } 188 }
198 189
199 string16 ExtensionAppItem::GetLabelForCommandId(int command_id) const { 190 string16 ExtensionAppItem::GetLabelForCommandId(int command_id) const {
200 if (command_id == TOGGLE_PIN) { 191 if (command_id == TOGGLE_PIN) {
201 return controller_->IsAppPinned(extension_id_) ? 192 return controller_->IsAppPinned(extension_id_) ?
202 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) : 193 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) :
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED); 294 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED);
304 context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR); 295 context_menu_model_->AddSeparator(ui::NORMAL_SEPARATOR);
305 context_menu_model_->AddItemWithStringId(OPTIONS, IDS_NEW_TAB_APP_OPTIONS); 296 context_menu_model_->AddItemWithStringId(OPTIONS, IDS_NEW_TAB_APP_OPTIONS);
306 context_menu_model_->AddItemWithStringId(DETAILS, IDS_NEW_TAB_APP_DETAILS); 297 context_menu_model_->AddItemWithStringId(DETAILS, IDS_NEW_TAB_APP_DETAILS);
307 context_menu_model_->AddItemWithStringId(UNINSTALL, 298 context_menu_model_->AddItemWithStringId(UNINSTALL,
308 IDS_EXTENSIONS_UNINSTALL); 299 IDS_EXTENSIONS_UNINSTALL);
309 } 300 }
310 301
311 return context_menu_model_.get(); 302 return context_menu_model_.get();
312 } 303 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698