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

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

Issue 400893002: Resize webstore icons to a known size before placing them in the app list model. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix include Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_model_builder.h" 5 #include "chrome/browser/ui/app_list/extension_app_model_builder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "chrome/browser/extensions/extension_ui_util.h" 13 #include "chrome/browser/extensions/extension_ui_util.h"
14 #include "chrome/browser/extensions/install_tracker.h" 14 #include "chrome/browser/extensions/install_tracker.h"
15 #include "chrome/browser/extensions/install_tracker_factory.h" 15 #include "chrome/browser/extensions/install_tracker_factory.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" 17 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
18 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 18 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
19 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 19 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
20 #include "chrome/browser/ui/app_list/extension_app_item.h" 20 #include "chrome/browser/ui/app_list/extension_app_item.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "extensions/browser/extension_prefs.h" 22 #include "extensions/browser/extension_prefs.h"
23 #include "extensions/browser/extension_registry.h" 23 #include "extensions/browser/extension_registry.h"
24 #include "extensions/browser/extension_system.h" 24 #include "extensions/browser/extension_system.h"
25 #include "extensions/browser/extensions_browser_client.h" 25 #include "extensions/browser/extensions_browser_client.h"
26 #include "extensions/browser/pref_names.h" 26 #include "extensions/browser/pref_names.h"
27 #include "extensions/common/constants.h"
27 #include "extensions/common/extension.h" 28 #include "extensions/common/extension.h"
28 #include "extensions/common/extension_set.h" 29 #include "extensions/common/extension_set.h"
29 #include "ui/gfx/image/image_skia.h" 30 #include "ui/gfx/image/image_skia.h"
31 #include "ui/gfx/image/image_skia_operations.h"
30 32
31 using extensions::Extension; 33 using extensions::Extension;
32 34
33 ExtensionAppModelBuilder::ExtensionAppModelBuilder( 35 ExtensionAppModelBuilder::ExtensionAppModelBuilder(
34 AppListControllerDelegate* controller) 36 AppListControllerDelegate* controller)
35 : service_(NULL), 37 : service_(NULL),
36 profile_(NULL), 38 profile_(NULL),
37 controller_(controller), 39 controller_(controller),
38 model_(NULL), 40 model_(NULL),
39 highlighted_app_pending_(false), 41 highlighted_app_pending_(false),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (!params.is_app || params.is_ephemeral) 99 if (!params.is_app || params.is_ephemeral)
98 return; 100 return;
99 101
100 DVLOG(2) << service_ << ": OnBeginExtensionInstall: " 102 DVLOG(2) << service_ << ": OnBeginExtensionInstall: "
101 << params.extension_id.substr(0, 8); 103 << params.extension_id.substr(0, 8);
102 ExtensionAppItem* existing_item = GetExtensionAppItem(params.extension_id); 104 ExtensionAppItem* existing_item = GetExtensionAppItem(params.extension_id);
103 if (existing_item) { 105 if (existing_item) {
104 existing_item->SetIsInstalling(true); 106 existing_item->SetIsInstalling(true);
105 return; 107 return;
106 } 108 }
109
110 // Icons from the webstore can be unusual sizes. Once installed,
111 // ExtensionAppItem uses extension_misc::EXTENSION_ICON_MEDIUM (48) to load
112 // it, so be consistent with that.
113 gfx::Size icon_size(extension_misc::EXTENSION_ICON_MEDIUM,
114 extension_misc::EXTENSION_ICON_MEDIUM);
115 gfx::ImageSkia resized(gfx::ImageSkiaOperations::CreateResizedImage(
116 params.installing_icon, skia::ImageOperations::RESIZE_BEST, icon_size));
117
107 InsertApp(CreateAppItem(params.extension_id, 118 InsertApp(CreateAppItem(params.extension_id,
108 params.extension_name, 119 params.extension_name,
109 params.installing_icon, 120 resized,
110 params.is_platform_app)); 121 params.is_platform_app));
111 SetHighlightedApp(params.extension_id); 122 SetHighlightedApp(params.extension_id);
112 } 123 }
113 124
114 void ExtensionAppModelBuilder::OnDownloadProgress( 125 void ExtensionAppModelBuilder::OnDownloadProgress(
115 const std::string& extension_id, 126 const std::string& extension_id,
116 int percent_downloaded) { 127 int percent_downloaded) {
117 ExtensionAppItem* item = GetExtensionAppItem(extension_id); 128 ExtensionAppItem* item = GetExtensionAppItem(extension_id);
118 if (!item) 129 if (!item)
119 return; 130 return;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 app_list::AppListItem* item = item_list->item_at(idx + 1); 327 app_list::AppListItem* item = item_list->item_at(idx + 1);
317 if (item->GetItemType() == ExtensionAppItem::kItemType) { 328 if (item->GetItemType() == ExtensionAppItem::kItemType) {
318 next = static_cast<ExtensionAppItem*>(item); 329 next = static_cast<ExtensionAppItem*>(item);
319 break; 330 break;
320 } 331 }
321 } 332 }
322 // item->Move will call set_position, overriding the item's position. 333 // item->Move will call set_position, overriding the item's position.
323 if (prev || next) 334 if (prev || next)
324 static_cast<ExtensionAppItem*>(item)->Move(prev, next); 335 static_cast<ExtensionAppItem*>(item)->Move(prev, next);
325 } 336 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698