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

Side by Side Diff: chrome/browser/extensions/extension_uninstall_dialog.cc

Issue 301063003: Resized the icon in the Uninstall dialog to be 64x64 px (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated the Install dialog icon as well Created 6 years, 6 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/extensions/extension_uninstall_dialog.h" 5 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 12 matching lines...) Expand all
23 #include "extensions/common/manifest_handlers/icons_handler.h" 23 #include "extensions/common/manifest_handlers/icons_handler.h"
24 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
25 #include "grit/theme_resources.h" 25 #include "grit/theme_resources.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 #include "ui/gfx/image/image.h" 28 #include "ui/gfx/image/image.h"
29 #include "ui/gfx/image/image_skia.h" 29 #include "ui/gfx/image/image_skia.h"
30 30
31 namespace { 31 namespace {
32 32
33 // Returns pixel size under maximal scale factor for the icon whose device 33 // Size of extension icon in top left of dialog.
34 // independent size is |size_in_dip| 34 const int kIconSize = 64;
35 int GetSizeForMaxScaleFactor(int size_in_dip) {
36 float max_scale_factor_scale = gfx::ImageSkia::GetMaxSupportedScale();
37
38 return static_cast<int>(size_in_dip * max_scale_factor_scale);
39 }
40 35
41 // Returns bitmap for the default icon with size equal to the default icon's 36 // Returns bitmap for the default icon with size equal to the default icon's
42 // pixel size under maximal supported scale factor. 37 // pixel size under maximal supported scale factor.
43 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { 38 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) {
44 const gfx::ImageSkia& image = is_app ? 39 const gfx::ImageSkia& image = is_app ?
45 extensions::util::GetDefaultAppIcon() : 40 extensions::util::GetDefaultAppIcon() :
46 extensions::util::GetDefaultExtensionIcon(); 41 extensions::util::GetDefaultExtensionIcon();
47 return image.GetRepresentation( 42 return image.GetRepresentation(
48 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); 43 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap();
49 } 44 }
50 45
51 } // namespace 46 } // namespace
52 47
53 // Size of extension icon in top left of dialog.
54 static const int kIconSize = 69;
55
56 ExtensionUninstallDialog::ExtensionUninstallDialog( 48 ExtensionUninstallDialog::ExtensionUninstallDialog(
57 Profile* profile, 49 Profile* profile,
58 Browser* browser, 50 Browser* browser,
59 ExtensionUninstallDialog::Delegate* delegate) 51 ExtensionUninstallDialog::Delegate* delegate)
60 : profile_(profile), 52 : profile_(profile),
61 browser_(browser), 53 browser_(browser),
62 delegate_(delegate), 54 delegate_(delegate),
63 extension_(NULL), 55 extension_(NULL),
64 triggering_extension_(NULL), 56 triggering_extension_(NULL),
65 state_(kImageIsLoading), 57 state_(kImageIsLoading),
(...skipping 12 matching lines...) Expand all
78 const extensions::Extension* extension, 70 const extensions::Extension* extension,
79 const extensions::Extension* triggering_extension) { 71 const extensions::Extension* triggering_extension) {
80 triggering_extension_ = triggering_extension; 72 triggering_extension_ = triggering_extension;
81 ConfirmUninstall(extension); 73 ConfirmUninstall(extension);
82 } 74 }
83 75
84 void ExtensionUninstallDialog::ConfirmUninstall( 76 void ExtensionUninstallDialog::ConfirmUninstall(
85 const extensions::Extension* extension) { 77 const extensions::Extension* extension) {
86 DCHECK(ui_loop_ == base::MessageLoop::current()); 78 DCHECK(ui_loop_ == base::MessageLoop::current());
87 extension_ = extension; 79 extension_ = extension;
88 // Bookmark apps may not have 128x128 icons so accept 48x48 icons. 80
89 const int icon_size = extension_->from_bookmark()
90 ? extension_misc::EXTENSION_ICON_MEDIUM
91 : extension_misc::EXTENSION_ICON_LARGE;
calamity 2014/05/30 06:42:03 On second thought, I think we need to keep this fo
sashab 2014/05/30 07:20:46 Done.
92 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource( 81 extensions::ExtensionResource image = extensions::IconsInfo::GetIconResource(
93 extension_, 82 extension_,
94 icon_size, 83 kIconSize,
95 ExtensionIconSet::MATCH_BIGGER); 84 ExtensionIconSet::MATCH_BIGGER);
96 // Load the icon whose pixel size is large enough to be displayed under
97 // maximal supported scale factor. UI code will scale the icon down if needed.
98 int pixel_size = GetSizeForMaxScaleFactor(kIconSize);
99 85
100 // Load the image asynchronously. The response will be sent to OnImageLoaded. 86 // Load the image asynchronously. The response will be sent to OnImageLoaded.
101 state_ = kImageIsLoading; 87 state_ = kImageIsLoading;
102 extensions::ImageLoader* loader = 88 extensions::ImageLoader* loader =
103 extensions::ImageLoader::Get(profile_); 89 extensions::ImageLoader::Get(profile_);
104 loader->LoadImageAsync(extension_, 90
105 image, 91 std::vector<extensions::ImageLoader::ImageRepresentation> images_list;
106 gfx::Size(pixel_size, pixel_size), 92 images_list.push_back(extensions::ImageLoader::ImageRepresentation(
107 base::Bind(&ExtensionUninstallDialog::OnImageLoaded, 93 image,
108 AsWeakPtr(), 94 extensions::ImageLoader::ImageRepresentation::NEVER_RESIZE,
109 extension_->id())); 95 gfx::Size(),
96 ui::SCALE_FACTOR_100P));
97 loader->LoadImagesAsync(extension_,
98 images_list,
99 base::Bind(&ExtensionUninstallDialog::OnImageLoaded,
100 AsWeakPtr(),
101 extension_->id()));
110 } 102 }
111 103
112 void ExtensionUninstallDialog::SetIcon(const gfx::Image& image) { 104 void ExtensionUninstallDialog::SetIcon(const gfx::Image& image) {
113 if (image.IsEmpty()) { 105 if (image.IsEmpty()) {
114 // Let's set default icon bitmap whose size is equal to the default icon's 106 // Let's set default icon bitmap whose size is equal to the default icon's
115 // pixel size under maximal supported scale factor. If the bitmap is larger 107 // pixel size under maximal supported scale factor. If the bitmap is larger
116 // than the one we need, it will be scaled down by the ui code. 108 // than the one we need, it will be scaled down by the ui code.
117 // TODO(tbarzic): We should use IconImage here and load the required bitmap 109 // TODO(tbarzic): We should use IconImage here and load the required bitmap
118 // lazily. 110 // lazily.
119 icon_ = gfx::ImageSkia::CreateFrom1xBitmap( 111 icon_ = gfx::ImageSkia::CreateFrom1xBitmap(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 std::string ExtensionUninstallDialog::GetHeadingText() { 155 std::string ExtensionUninstallDialog::GetHeadingText() {
164 if (triggering_extension_) { 156 if (triggering_extension_) {
165 return l10n_util::GetStringFUTF8( 157 return l10n_util::GetStringFUTF8(
166 IDS_EXTENSION_PROGRAMMATIC_UNINSTALL_PROMPT_HEADING, 158 IDS_EXTENSION_PROGRAMMATIC_UNINSTALL_PROMPT_HEADING,
167 base::UTF8ToUTF16(triggering_extension_->name()), 159 base::UTF8ToUTF16(triggering_extension_->name()),
168 base::UTF8ToUTF16(extension_->name())); 160 base::UTF8ToUTF16(extension_->name()));
169 } 161 }
170 return l10n_util::GetStringFUTF8(IDS_EXTENSION_UNINSTALL_PROMPT_HEADING, 162 return l10n_util::GetStringFUTF8(IDS_EXTENSION_UNINSTALL_PROMPT_HEADING,
171 base::UTF8ToUTF16(extension_->name())); 163 base::UTF8ToUTF16(extension_->name()));
172 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698