| 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_install_prompt.h" | 5 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 0, | 115 0, |
| 116 0, | 116 0, |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 // Size of extension icon in top left of dialog. | 119 // Size of extension icon in top left of dialog. |
| 120 const int kIconSize = 69; | 120 const int kIconSize = 69; |
| 121 | 121 |
| 122 // Returns pixel size under maximal scale factor for the icon whose device | 122 // Returns pixel size under maximal scale factor for the icon whose device |
| 123 // independent size is |size_in_dip| | 123 // independent size is |size_in_dip| |
| 124 int GetSizeForMaxScaleFactor(int size_in_dip) { | 124 int GetSizeForMaxScaleFactor(int size_in_dip) { |
| 125 return static_cast<int>(size_in_dip * gfx::ImageSkia::GetMaxSupportedScale()); | 125 float max_scale_factor_scale = |
| 126 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); |
| 127 return static_cast<int>(size_in_dip * max_scale_factor_scale); |
| 126 } | 128 } |
| 127 | 129 |
| 128 // Returns bitmap for the default icon with size equal to the default icon's | 130 // Returns bitmap for the default icon with size equal to the default icon's |
| 129 // pixel size under maximal supported scale factor. | 131 // pixel size under maximal supported scale factor. |
| 130 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { | 132 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { |
| 131 const gfx::ImageSkia& image = is_app ? | 133 const gfx::ImageSkia& image = is_app ? |
| 132 extensions::IconsInfo::GetDefaultAppIcon() : | 134 extensions::IconsInfo::GetDefaultAppIcon() : |
| 133 extensions::IconsInfo::GetDefaultExtensionIcon(); | 135 extensions::IconsInfo::GetDefaultExtensionIcon(); |
| 134 return image.GetRepresentation( | 136 return image.GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); |
| 135 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); | |
| 136 } | 137 } |
| 137 | 138 |
| 138 // If auto confirm is enabled then posts a task to proceed with or cancel the | 139 // If auto confirm is enabled then posts a task to proceed with or cancel the |
| 139 // install and returns true. Otherwise returns false. | 140 // install and returns true. Otherwise returns false. |
| 140 bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) { | 141 bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) { |
| 141 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 142 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 142 if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) | 143 if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) |
| 143 return false; | 144 return false; |
| 144 std::string value = cmdline->GetSwitchValueASCII( | 145 std::string value = cmdline->GetSwitchValueASCII( |
| 145 switches::kAppsGalleryInstallAutoConfirmForTests); | 146 switches::kAppsGalleryInstallAutoConfirmForTests); |
| (...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 } | 800 } |
| 800 | 801 |
| 801 if (AutoConfirmPrompt(delegate_)) | 802 if (AutoConfirmPrompt(delegate_)) |
| 802 return; | 803 return; |
| 803 | 804 |
| 804 if (show_dialog_callback_.is_null()) | 805 if (show_dialog_callback_.is_null()) |
| 805 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); | 806 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); |
| 806 else | 807 else |
| 807 show_dialog_callback_.Run(show_params_, delegate_, prompt_); | 808 show_dialog_callback_.Run(show_params_, delegate_, prompt_); |
| 808 } | 809 } |
| OLD | NEW |