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" | |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 // Returns pixel size under maximal scale factor for the icon whose device | 27 // Returns pixel size under maximal scale factor for the icon whose device |
29 // independent size is |size_in_dip| | 28 // independent size is |size_in_dip| |
30 int GetSizeForMaxScaleFactor(int size_in_dip) { | 29 int GetSizeForMaxScaleFactor(int size_in_dip) { |
31 float max_scale_factor_scale = gfx::ImageSkia::GetMaxSupportedScale(); | 30 ui::ScaleFactor max_scale_factor = ui::GetMaxScaleFactor(); |
| 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( | 42 return image.GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); |
43 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); | |
44 } | 43 } |
45 | 44 |
46 } // namespace | 45 } // namespace |
47 | 46 |
48 // Size of extension icon in top left of dialog. | 47 // Size of extension icon in top left of dialog. |
49 static const int kIconSize = 69; | 48 static const int kIconSize = 69; |
50 | 49 |
51 ExtensionUninstallDialog::ExtensionUninstallDialog( | 50 ExtensionUninstallDialog::ExtensionUninstallDialog( |
52 Profile* profile, | 51 Profile* profile, |
53 Browser* browser, | 52 Browser* browser, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 | 123 |
125 browser_ = NULL; | 124 browser_ = NULL; |
126 // If the browser is closed while waiting for the image, we need to send a | 125 // If the browser is closed while waiting for the image, we need to send a |
127 // "cancel" event here, because there will not be another opportunity to | 126 // "cancel" event here, because there will not be another opportunity to |
128 // notify the delegate of the cancellation as we won't open the dialog. | 127 // notify the delegate of the cancellation as we won't open the dialog. |
129 if (state_ == kImageIsLoading) { | 128 if (state_ == kImageIsLoading) { |
130 state_ = kBrowserIsClosing; | 129 state_ = kBrowserIsClosing; |
131 delegate_->ExtensionUninstallCanceled(); | 130 delegate_->ExtensionUninstallCanceled(); |
132 } | 131 } |
133 } | 132 } |
OLD | NEW |