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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // we need to update FetchOAuthIssueAdviceIfNeeded. | 98 // we need to update FetchOAuthIssueAdviceIfNeeded. |
99 0, | 99 0, |
100 }; | 100 }; |
101 | 101 |
102 // Size of extension icon in top left of dialog. | 102 // Size of extension icon in top left of dialog. |
103 const int kIconSize = 69; | 103 const int kIconSize = 69; |
104 | 104 |
105 // Returns pixel size under maximal scale factor for the icon whose device | 105 // Returns pixel size under maximal scale factor for the icon whose device |
106 // independent size is |size_in_dip| | 106 // independent size is |size_in_dip| |
107 int GetSizeForMaxScaleFactor(int size_in_dip) { | 107 int GetSizeForMaxScaleFactor(int size_in_dip) { |
108 std::vector<ui::ScaleFactor> supported_scale_factors = | 108 float max_scale_factor_scale = |
109 ui::GetSupportedScaleFactors(); | 109 ui::GetScaleFactorScale(ui::GetMaxScaleFactor()); |
110 // Scale factors are in ascending order, so the last one is the one we need. | |
111 ui::ScaleFactor max_scale_factor = supported_scale_factors.back(); | |
112 float max_scale_factor_scale = ui::GetScaleFactorScale(max_scale_factor); | |
113 | |
114 return static_cast<int>(size_in_dip * max_scale_factor_scale); | 110 return static_cast<int>(size_in_dip * max_scale_factor_scale); |
115 } | 111 } |
116 | 112 |
117 // Returns bitmap for the default icon with size equal to the default icon's | 113 // Returns bitmap for the default icon with size equal to the default icon's |
118 // pixel size under maximal supported scale factor. | 114 // pixel size under maximal supported scale factor. |
119 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { | 115 SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { |
120 std::vector<ui::ScaleFactor> supported_scale_factors = | |
121 ui::GetSupportedScaleFactors(); | |
122 // Scale factors are in ascending order, so the last one is the one we need. | |
123 ui::ScaleFactor max_scale_factor = | |
124 supported_scale_factors[supported_scale_factors.size() - 1]; | |
125 | |
126 return Extension::GetDefaultIcon(is_app). | 116 return Extension::GetDefaultIcon(is_app). |
127 GetRepresentation(max_scale_factor).sk_bitmap(); | 117 GetRepresentation(ui::GetMaxScaleFactor()).sk_bitmap(); |
128 } | 118 } |
129 | 119 |
130 // If auto confirm is enabled then posts a task to proceed with or cancel the | 120 // If auto confirm is enabled then posts a task to proceed with or cancel the |
131 // install and returns true. Otherwise returns false. | 121 // install and returns true. Otherwise returns false. |
132 bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) { | 122 bool AutoConfirmPrompt(ExtensionInstallPrompt::Delegate* delegate) { |
133 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 123 const CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
134 if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) | 124 if (!cmdline->HasSwitch(switches::kAppsGalleryInstallAutoConfirmForTests)) |
135 return false; | 125 return false; |
136 std::string value = cmdline->GetSwitchValueASCII( | 126 std::string value = cmdline->GetSwitchValueASCII( |
137 switches::kAppsGalleryInstallAutoConfirmForTests); | 127 switches::kAppsGalleryInstallAutoConfirmForTests); |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 if (AutoConfirmPrompt(delegate_)) | 624 if (AutoConfirmPrompt(delegate_)) |
635 return; | 625 return; |
636 | 626 |
637 if (show_dialog_callback_.is_null()) { | 627 if (show_dialog_callback_.is_null()) { |
638 GetDefaultShowDialogCallback().Run( | 628 GetDefaultShowDialogCallback().Run( |
639 parent_web_contents_, delegate_, prompt_); | 629 parent_web_contents_, delegate_, prompt_); |
640 } else { | 630 } else { |
641 show_dialog_callback_.Run(parent_web_contents_, delegate_, prompt_); | 631 show_dialog_callback_.Run(parent_web_contents_, delegate_, prompt_); |
642 } | 632 } |
643 } | 633 } |
OLD | NEW |