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

Side by Side Diff: chrome/browser/ui/ash/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 Created 8 years, 4 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/ash/app_list/extension_app_item.h" 5 #include "chrome/browser/ui/ash/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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ExtensionAppItem::~ExtensionAppItem() { 131 ExtensionAppItem::~ExtensionAppItem() {
132 } 132 }
133 133
134 const Extension* ExtensionAppItem::GetExtension() const { 134 const Extension* ExtensionAppItem::GetExtension() const {
135 const Extension* extension = 135 const Extension* extension =
136 profile_->GetExtensionService()->GetInstalledExtension(extension_id_); 136 profile_->GetExtensionService()->GetInstalledExtension(extension_id_);
137 return extension; 137 return extension;
138 } 138 }
139 139
140 void ExtensionAppItem::LoadImage(const Extension* extension) { 140 void ExtensionAppItem::LoadImage(const Extension* extension) {
141 tracker_.reset(new ImageLoadingTracker(this)); 141 icon_.reset(new extensions::IconImage(
142 tracker_->LoadImage(extension, 142 extension,
143 extension->GetIconResource( 143 extension->icons(),
144 extension_misc::EXTENSION_ICON_LARGE, 144 extension_misc::EXTENSION_ICON_MEDIUM,
145 ExtensionIconSet::MATCH_BIGGER), 145 this));
146 gfx::Size(extension_misc::EXTENSION_ICON_LARGE, 146 OnExtensionIconImageChanged(icon_.get());
147 extension_misc::EXTENSION_ICON_LARGE),
148 ImageLoadingTracker::DONT_CACHE);
149 } 147 }
150 148
151 void ExtensionAppItem::ShowExtensionOptions() { 149 void ExtensionAppItem::ShowExtensionOptions() {
152 const Extension* extension = GetExtension(); 150 const Extension* extension = GetExtension();
153 if (!extension) 151 if (!extension)
154 return; 152 return;
155 153
156 chrome::NavigateParams params(profile_, 154 chrome::NavigateParams params(profile_,
157 extension->options_url(), 155 extension->options_url(),
158 content::PAGE_TRANSITION_LINK); 156 content::PAGE_TRANSITION_LINK);
159 chrome::Navigate(&params); 157 chrome::Navigate(&params);
160 } 158 }
161 159
162 void ExtensionAppItem::StartExtensionUninstall() { 160 void ExtensionAppItem::StartExtensionUninstall() {
163 // ExtensionUninstall deletes itself when done or aborted. 161 // ExtensionUninstall deletes itself when done or aborted.
164 ExtensionUninstaller* uninstaller = new ExtensionUninstaller(profile_, 162 ExtensionUninstaller* uninstaller = new ExtensionUninstaller(profile_,
165 extension_id_); 163 extension_id_);
166 uninstaller->Run(); 164 uninstaller->Run();
167 } 165 }
168 166
169 void ExtensionAppItem::OnImageLoaded(const gfx::Image& image, 167 void ExtensionAppItem::OnExtensionIconImageChanged(
170 const std::string& extension_id, 168 extensions::IconImage* image) {
171 int tracker_index) { 169 DCHECK(icon_.get() == image);
172 if (!image.IsEmpty()) 170 SetIcon(image->image_skia());
173 SetIcon(*image.ToImageSkia()); 171 }
174 else 172
175 SetIcon(Extension::GetDefaultIcon(true /* is_app */)); 173 void ExtensionAppItem::OnIconImageLoadFailed(
174 extensions::IconImage* image,
175 ui::ScaleFactor scale_factor) {
176 DCHECK(icon_.get() == image);
177
178 image->SetRepresentation(gfx::ImageSkiaRep(
179 Extension::GetDefaultIcon(true), scale_factor));
176 } 180 }
177 181
178 bool ExtensionAppItem::IsItemForCommandIdDynamic(int command_id) const { 182 bool ExtensionAppItem::IsItemForCommandIdDynamic(int command_id) const {
179 return command_id == TOGGLE_PIN; 183 return command_id == TOGGLE_PIN;
180 } 184 }
181 185
182 string16 ExtensionAppItem::GetLabelForCommandId(int command_id) const { 186 string16 ExtensionAppItem::GetLabelForCommandId(int command_id) const {
183 if (command_id == TOGGLE_PIN) { 187 if (command_id == TOGGLE_PIN) {
184 return controller_->IsAppPinned(extension_id_) ? 188 return controller_->IsAppPinned(extension_id_) ?
185 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) : 189 l10n_util::GetStringUTF16(IDS_APP_LIST_CONTEXT_MENU_UNPIN) :
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 LAUNCH_TYPE_FULLSCREEN, 284 LAUNCH_TYPE_FULLSCREEN,
281 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED); 285 IDS_APP_CONTEXT_MENU_OPEN_MAXIMIZED);
282 context_menu_model_->AddSeparator(); 286 context_menu_model_->AddSeparator();
283 context_menu_model_->AddItemWithStringId(OPTIONS, IDS_NEW_TAB_APP_OPTIONS); 287 context_menu_model_->AddItemWithStringId(OPTIONS, IDS_NEW_TAB_APP_OPTIONS);
284 context_menu_model_->AddItemWithStringId(UNINSTALL, 288 context_menu_model_->AddItemWithStringId(UNINSTALL,
285 IDS_EXTENSIONS_UNINSTALL); 289 IDS_EXTENSIONS_UNINSTALL);
286 } 290 }
287 291
288 return context_menu_model_.get(); 292 return context_menu_model_.get();
289 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698