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

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

Issue 2034293002: Just use the image skia from resouce bundle for default app icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 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
« 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/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/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 23 matching lines...) Expand all
34 34
35 namespace extensions { 35 namespace extensions {
36 36
37 namespace { 37 namespace {
38 38
39 const char kExtensionRemovedError[] = 39 const char kExtensionRemovedError[] =
40 "Extension was removed before dialog closed."; 40 "Extension was removed before dialog closed.";
41 41
42 const char kReferrerId[] = "chrome-remove-extension-dialog"; 42 const char kReferrerId[] = "chrome-remove-extension-dialog";
43 43
44 // Returns bitmap for the default icon with size equal to the default icon's 44 // Returns gfx::ImageSkia for the default icon.
45 // pixel size under maximal supported scale factor. 45 gfx::ImageSkia GetDefaultIconImage(bool is_app) {
46 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { 46 return is_app ? util::GetDefaultAppIcon() : util::GetDefaultExtensionIcon();
47 const gfx::ImageSkia& image =
48 is_app ? util::GetDefaultAppIcon() : util::GetDefaultExtensionIcon();
49 return image.GetRepresentation(
50 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap();
51 } 47 }
52 48
53 } // namespace 49 } // namespace
54 50
55 ExtensionUninstallDialog::ExtensionUninstallDialog( 51 ExtensionUninstallDialog::ExtensionUninstallDialog(
56 Profile* profile, 52 Profile* profile,
57 ExtensionUninstallDialog::Delegate* delegate) 53 ExtensionUninstallDialog::Delegate* delegate)
58 : profile_(profile), 54 : profile_(profile),
59 delegate_(delegate), 55 delegate_(delegate),
60 uninstall_reason_(UNINSTALL_REASON_FOR_TESTING) { 56 uninstall_reason_(UNINSTALL_REASON_FOR_TESTING) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 ImageLoader::ImageRepresentation::NEVER_RESIZE, 96 ImageLoader::ImageRepresentation::NEVER_RESIZE,
101 gfx::Size(), 97 gfx::Size(),
102 ui::SCALE_FACTOR_100P)); 98 ui::SCALE_FACTOR_100P));
103 loader->LoadImagesAsync(extension_.get(), images_list, 99 loader->LoadImagesAsync(extension_.get(), images_list,
104 base::Bind(&ExtensionUninstallDialog::OnImageLoaded, 100 base::Bind(&ExtensionUninstallDialog::OnImageLoaded,
105 AsWeakPtr(), extension_->id())); 101 AsWeakPtr(), extension_->id()));
106 } 102 }
107 103
108 void ExtensionUninstallDialog::SetIcon(const gfx::Image& image) { 104 void ExtensionUninstallDialog::SetIcon(const gfx::Image& image) {
109 if (image.IsEmpty()) { 105 if (image.IsEmpty()) {
110 // Let's set default icon bitmap whose size is equal to the default icon's 106 icon_ = GetDefaultIconImage(extension_->is_app());
111 // pixel size under maximal supported scale factor. If the bitmap is larger
112 // than the one we need, it will be scaled down by the ui code.
113 // TODO(tbarzic): We should use IconImage here and load the required bitmap
114 // lazily.
115 icon_ = gfx::ImageSkia::CreateFrom1xBitmap(
116 GetDefaultIconBitmapForMaxScaleFactor(extension_->is_app()));
117 } else { 107 } else {
118 icon_ = *image.ToImageSkia(); 108 icon_ = *image.ToImageSkia();
119 } 109 }
120 } 110 }
121 111
122 void ExtensionUninstallDialog::OnImageLoaded(const std::string& extension_id, 112 void ExtensionUninstallDialog::OnImageLoaded(const std::string& extension_id,
123 const gfx::Image& image) { 113 const gfx::Image& image) {
124 const Extension* target_extension = 114 const Extension* target_extension =
125 ExtensionRegistry::Get(profile_) 115 ExtensionRegistry::Get(profile_)
126 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); 116 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 void ExtensionUninstallDialog::HandleReportAbuse() { 193 void ExtensionUninstallDialog::HandleReportAbuse() {
204 chrome::NavigateParams params( 194 chrome::NavigateParams params(
205 profile_, 195 profile_,
206 extension_urls::GetWebstoreReportAbuseUrl(extension_->id(), kReferrerId), 196 extension_urls::GetWebstoreReportAbuseUrl(extension_->id(), kReferrerId),
207 ui::PAGE_TRANSITION_LINK); 197 ui::PAGE_TRANSITION_LINK);
208 params.disposition = NEW_FOREGROUND_TAB; 198 params.disposition = NEW_FOREGROUND_TAB;
209 chrome::Navigate(&params); 199 chrome::Navigate(&params);
210 } 200 }
211 201
212 } // namespace extensions 202 } // namespace extensions
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