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_web_ui.h" | 5 #include "chrome/browser/extensions/extension_web_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 397 } |
398 | 398 |
399 // Fetch resources for all supported scale factors for which there are | 399 // Fetch resources for all supported scale factors for which there are |
400 // resources. Load image reps for all supported scale factors (in addition to | 400 // resources. Load image reps for all supported scale factors (in addition to |
401 // 1x) immediately instead of in an as needed fashion to be consistent with | 401 // 1x) immediately instead of in an as needed fashion to be consistent with |
402 // how favicons are requested for chrome:// and page URLs. | 402 // how favicons are requested for chrome:// and page URLs. |
403 const std::vector<ui::ScaleFactor>& scale_factors = | 403 const std::vector<ui::ScaleFactor>& scale_factors = |
404 FaviconUtil::GetFaviconScaleFactors(); | 404 FaviconUtil::GetFaviconScaleFactors(); |
405 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; | 405 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; |
406 for (size_t i = 0; i < scale_factors.size(); ++i) { | 406 for (size_t i = 0; i < scale_factors.size(); ++i) { |
407 float scale = ui::GetScaleFactorScale(scale_factors[i]); | 407 float scale = ui::GetImageScale(scale_factors[i]); |
408 int pixel_size = static_cast<int>(gfx::kFaviconSize * scale); | 408 int pixel_size = static_cast<int>(gfx::kFaviconSize * scale); |
409 extensions::ExtensionResource icon_resource = | 409 extensions::ExtensionResource icon_resource = |
410 extensions::IconsInfo::GetIconResource(extension, | 410 extensions::IconsInfo::GetIconResource(extension, |
411 pixel_size, | 411 pixel_size, |
412 ExtensionIconSet::MATCH_BIGGER); | 412 ExtensionIconSet::MATCH_BIGGER); |
413 | 413 |
414 info_list.push_back( | 414 info_list.push_back( |
415 extensions::ImageLoader::ImageRepresentation( | 415 extensions::ImageLoader::ImageRepresentation( |
416 icon_resource, | 416 icon_resource, |
417 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 417 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
418 gfx::Size(pixel_size, pixel_size), | 418 gfx::Size(pixel_size, pixel_size), |
419 scale_factors[i])); | 419 scale_factors[i])); |
420 } | 420 } |
421 | 421 |
422 // LoadImagesAsync actually can run callback synchronously. We want to force | 422 // LoadImagesAsync actually can run callback synchronously. We want to force |
423 // async. | 423 // async. |
424 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 424 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
425 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); | 425 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); |
426 } | 426 } |
OLD | NEW |