OLD | NEW |
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 "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/extensions/image_loader.h" | 11 #include "chrome/browser/extensions/image_loader.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
14 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
15 #include "chrome/common/extensions/extension_icon_set.h" | 15 #include "chrome/common/extensions/extension_icon_set.h" |
16 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | 16 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" |
17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_source.h" | 18 #include "content/public/browser/notification_source.h" |
19 #include "extensions/common/extension_resource.h" | 19 #include "extensions/common/extension_resource.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
22 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
23 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 24 #include "ui/gfx/image/image_skia.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 // Returns pixel size under maximal scale factor for the icon whose device | 28 // Returns pixel size under maximal scale factor for the icon whose device |
28 // independent size is |size_in_dip| | 29 // independent size is |size_in_dip| |
29 int GetSizeForMaxScaleFactor(int size_in_dip) { | 30 int GetSizeForMaxScaleFactor(int size_in_dip) { |
30 ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor(); | 31 float max_scale_factor_scale = gfx::ImageSkia::GetMaxSupportedScale(); |
31 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor); | |
32 | 32 |
33 return static_cast<int>(size_in_dip * max_scale_factor_scale); | 33 return static_cast<int>(size_in_dip * max_scale_factor_scale); |
34 } | 34 } |
35 | 35 |
36 // 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 |
37 // pixel size under maximal supported scale factor. | 37 // pixel size under maximal supported scale factor. |
38 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { | 38 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { |
39 const gfx::ImageSkia& image = is_app ? | 39 const gfx::ImageSkia& image = is_app ? |
40 extensions::IconsInfo::GetDefaultAppIcon() : | 40 extensions::IconsInfo::GetDefaultAppIcon() : |
41 extensions::IconsInfo::GetDefaultExtensionIcon(); | 41 extensions::IconsInfo::GetDefaultExtensionIcon(); |
42 return image.GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); | 42 return image.GetRepresentation( |
| 43 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); |
43 } | 44 } |
44 | 45 |
45 } // namespace | 46 } // namespace |
46 | 47 |
47 // Size of extension icon in top left of dialog. | 48 // Size of extension icon in top left of dialog. |
48 static const int kIconSize = 69; | 49 static const int kIconSize = 69; |
49 | 50 |
50 ExtensionUninstallDialog::ExtensionUninstallDialog( | 51 ExtensionUninstallDialog::ExtensionUninstallDialog( |
51 Profile* profile, | 52 Profile* profile, |
52 Browser* browser, | 53 Browser* browser, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 124 |
124 browser_ = NULL; | 125 browser_ = NULL; |
125 // If the browser is closed while waiting for the image, we need to send a | 126 // If the browser is closed while waiting for the image, we need to send a |
126 // "cancel" event here, because there will not be another opportunity to | 127 // "cancel" event here, because there will not be another opportunity to |
127 // notify the delegate of the cancellation as we won't open the dialog. | 128 // notify the delegate of the cancellation as we won't open the dialog. |
128 if (state_ == kImageIsLoading) { | 129 if (state_ == kImageIsLoading) { |
129 state_ = kBrowserIsClosing; | 130 state_ = kBrowserIsClosing; |
130 delegate_->ExtensionUninstallCanceled(); | 131 delegate_->ExtensionUninstallCanceled(); |
131 } | 132 } |
132 } | 133 } |
OLD | NEW |