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

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

Issue 11360233: Ensure that favicons always have 1x representation regardless of whether the platform supports it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "chrome/common/chrome_notification_types.h" 9 #include "chrome/common/chrome_notification_types.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
11 #include "chrome/common/extensions/extension_constants.h" 11 #include "chrome/common/extensions/extension_constants.h"
12 #include "chrome/common/extensions/extension_icon_set.h" 12 #include "chrome/common/extensions/extension_icon_set.h"
13 #include "chrome/common/extensions/extension_resource.h" 13 #include "chrome/common/extensions/extension_resource.h"
14 #include "content/public/browser/notification_service.h" 14 #include "content/public/browser/notification_service.h"
15 #include "content/public/browser/notification_source.h" 15 #include "content/public/browser/notification_source.h"
16 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
17 #include "grit/theme_resources.h" 17 #include "grit/theme_resources.h"
18 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
20 20
21 namespace { 21 namespace {
22 22
23 // Returns pixel size under maximal scale factor for the icon whose device 23 // Returns pixel size under maximal scale factor for the icon whose device
24 // independent size is |size_in_dip| 24 // independent size is |size_in_dip|
25 int GetSizeForMaxScaleFactor(int size_in_dip) { 25 int GetSizeForMaxScaleFactor(int size_in_dip) {
26 std::vector<ui::ScaleFactor> supported_scale_factors = 26 ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor();
27 ui::GetSupportedScaleFactors();
28 // Scale factors are in ascending order, so the last one is the one we need.
29 ui::ScaleFactor max_scale_factor = supported_scale_factors.back();
30 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor); 27 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor);
31 28
32 return static_cast<int>(size_in_dip * max_scale_factor_scale); 29 return static_cast<int>(size_in_dip * max_scale_factor_scale);
33 } 30 }
34 31
35 // Returns bitmap for the default icon with size equal to the default icon's 32 // Returns bitmap for the default icon with size equal to the default icon's
36 // pixel size under maximal supported scale factor. 33 // pixel size under maximal supported scale factor.
37 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { 34 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) {
38 std::vector<ui::ScaleFactor> supported_scale_factors =
39 ui::GetSupportedScaleFactors();
40 // Scale factors are in ascending order, so the last one is the one we need.
41 ui::ScaleFactor max_scale_factor =
42 supported_scale_factors[supported_scale_factors.size() - 1];
43
44 return extensions::Extension::GetDefaultIcon(is_app). 35 return extensions::Extension::GetDefaultIcon(is_app).
45 GetRepresentation(max_scale_factor).sk_bitmap(); 36 GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap();
46 } 37 }
47 38
48 } // namespace 39 } // namespace
49 40
50 // Size of extension icon in top left of dialog. 41 // Size of extension icon in top left of dialog.
51 static const int kIconSize = 69; 42 static const int kIconSize = 69;
52 43
53 ExtensionUninstallDialog::ExtensionUninstallDialog( 44 ExtensionUninstallDialog::ExtensionUninstallDialog(
54 Browser* browser, 45 Browser* browser,
55 ExtensionUninstallDialog::Delegate* delegate) 46 ExtensionUninstallDialog::Delegate* delegate)
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING); 109 DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSING);
119 110
120 browser_ = NULL; 111 browser_ = NULL;
121 if (tracker_.get()) { 112 if (tracker_.get()) {
122 // If we're waiting for the icon, stop doing so because we're not going to 113 // If we're waiting for the icon, stop doing so because we're not going to
123 // show the dialog. 114 // show the dialog.
124 tracker_.reset(); 115 tracker_.reset();
125 delegate_->ExtensionUninstallCanceled(); 116 delegate_->ExtensionUninstallCanceled();
126 } 117 }
127 } 118 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.cc ('k') | chrome/browser/extensions/extension_web_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698