| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/manifest/manifest_icon_selector.h" | 5 #include "chrome/browser/manifest/manifest_icon_selector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 | 161 |
| 162 return result; | 162 return result; |
| 163 } | 163 } |
| 164 | 164 |
| 165 // static | 165 // static |
| 166 GURL ManifestIconSelector::FindBestMatchingIcon( | 166 GURL ManifestIconSelector::FindBestMatchingIcon( |
| 167 const std::vector<Manifest::Icon>& unfiltered_icons, | 167 const std::vector<Manifest::Icon>& unfiltered_icons, |
| 168 const int ideal_icon_size_in_dp, | 168 const int ideal_icon_size_in_dp, |
| 169 const int minimum_icon_size_in_dp, | 169 const int minimum_icon_size_in_dp) { |
| 170 const gfx::Screen* screen) { | |
| 171 DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp); | 170 DCHECK(minimum_icon_size_in_dp <= ideal_icon_size_in_dp); |
| 172 | 171 |
| 173 const float device_scale_factor = | 172 const float device_scale_factor = |
| 174 screen->GetPrimaryDisplay().device_scale_factor(); | 173 gfx::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor(); |
| 175 const int ideal_icon_size_in_px = | 174 const int ideal_icon_size_in_px = |
| 176 static_cast<int>(round(ideal_icon_size_in_dp * device_scale_factor)); | 175 static_cast<int>(round(ideal_icon_size_in_dp * device_scale_factor)); |
| 177 const int minimum_icon_size_in_px = | 176 const int minimum_icon_size_in_px = |
| 178 static_cast<int>(round(minimum_icon_size_in_dp * device_scale_factor)); | 177 static_cast<int>(round(minimum_icon_size_in_dp * device_scale_factor)); |
| 179 | 178 |
| 180 std::vector<Manifest::Icon> icons = | 179 std::vector<Manifest::Icon> icons = |
| 181 ManifestIconSelector::FilterIconsByType(unfiltered_icons); | 180 ManifestIconSelector::FilterIconsByType(unfiltered_icons); |
| 182 | 181 |
| 183 ManifestIconSelector selector(ideal_icon_size_in_px, | 182 ManifestIconSelector selector(ideal_icon_size_in_px, |
| 184 minimum_icon_size_in_px); | 183 minimum_icon_size_in_px); |
| 185 int index = selector.FindBestMatchingIcon(icons, device_scale_factor); | 184 int index = selector.FindBestMatchingIcon(icons, device_scale_factor); |
| 186 if (index == -1) | 185 if (index == -1) |
| 187 return GURL(); | 186 return GURL(); |
| 188 return icons[index].src; | 187 return icons[index].src; |
| 189 } | 188 } |
| OLD | NEW |