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