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 float max_scale_factor_scale = | 125 return static_cast<int>(size_in_dip * gfx::ImageSkia::GetMaxSupportedScale()); |
126 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); | |
127 return static_cast<int>(size_in_dip * max_scale_factor_scale); | |
128 } | 126 } |
129 | 127 |
130 // Returns bitmap for the default icon with size equal to the default icon's | 128 // Returns bitmap for the default icon with size equal to the default icon's |
131 // pixel size under maximal supported scale factor. | 129 // pixel size under maximal supported scale factor. |
132 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { | 130 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { |
133 const gfx::ImageSkia& image = is_app ? | 131 const gfx::ImageSkia& image = is_app ? |
134 extensions::IconsInfo::GetDefaultAppIcon() : | 132 extensions::IconsInfo::GetDefaultAppIcon() : |
135 extensions::IconsInfo::GetDefaultExtensionIcon(); | 133 extensions::IconsInfo::GetDefaultExtensionIcon(); |
136 return image.GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); | 134 return image.GetRepresentation( |
| 135 gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); |
137 } | 136 } |
138 | 137 |
139 // If auto confirm is enabled then posts a task to proceed with or cancel the | 138 // If auto confirm is enabled then posts a task to proceed with or cancel the |
140 // install and returns true. Otherwise returns false. | 139 // install and returns true. Otherwise returns false. |
141 bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) { | 140 bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) { |
142 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 141 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
143 if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) | 142 if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) |
144 return false; | 143 return false; |
145 std::string value = cmdline->GetSwitchValueASCII( | 144 std::string value = cmdline->GetSwitchValueASCII( |
146 switches::kAppsGalleryInstallAutoConfirmForTests); | 145 switches::kAppsGalleryInstallAutoConfirmForTests); |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 } | 809 } |
811 | 810 |
812 if (AutoConfirmPrompt(delegate_)) | 811 if (AutoConfirmPrompt(delegate_)) |
813 return; | 812 return; |
814 | 813 |
815 if (show_dialog_callback_.is_null()) | 814 if (show_dialog_callback_.is_null()) |
816 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); | 815 GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_); |
817 else | 816 else |
818 show_dialog_callback_.Run(show_params_, delegate_, prompt_); | 817 show_dialog_callback_.Run(show_params_, delegate_, prompt_); |
819 } | 818 } |
OLD | NEW |