Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: chrome/browser/extensions/extension_web_ui.cc

Issue 335233003: Convert ui::ScaleFactor -> float in favicon/history code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix size_t Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 const Extension* extension = service->extensions()->GetByID(page_url.host()); 417 const Extension* extension = service->extensions()->GetByID(page_url.host());
418 if (!extension) { 418 if (!extension) {
419 RunFaviconCallbackAsync(callback, gfx::Image()); 419 RunFaviconCallbackAsync(callback, gfx::Image());
420 return; 420 return;
421 } 421 }
422 422
423 // Fetch resources for all supported scale factors for which there are 423 // Fetch resources for all supported scale factors for which there are
424 // resources. Load image reps for all supported scale factors (in addition to 424 // resources. Load image reps for all supported scale factors (in addition to
425 // 1x) immediately instead of in an as needed fashion to be consistent with 425 // 1x) immediately instead of in an as needed fashion to be consistent with
426 // how favicons are requested for chrome:// and page URLs. 426 // how favicons are requested for chrome:// and page URLs.
427 const std::vector<ui::ScaleFactor>& scale_factors = 427 const std::vector<float>& favicon_scales = favicon_base::GetFaviconScales();
428 favicon_base::GetFaviconScaleFactors();
429 std::vector<extensions::ImageLoader::ImageRepresentation> info_list; 428 std::vector<extensions::ImageLoader::ImageRepresentation> info_list;
430 for (size_t i = 0; i < scale_factors.size(); ++i) { 429 for (size_t i = 0; i < favicon_scales.size(); ++i) {
431 float scale = ui::GetScaleForScaleFactor(scale_factors[i]); 430 float scale = favicon_scales[i];
432 int pixel_size = static_cast<int>(gfx::kFaviconSize * scale); 431 int pixel_size = static_cast<int>(gfx::kFaviconSize * scale);
433 extensions::ExtensionResource icon_resource = 432 extensions::ExtensionResource icon_resource =
434 extensions::IconsInfo::GetIconResource(extension, 433 extensions::IconsInfo::GetIconResource(extension,
435 pixel_size, 434 pixel_size,
436 ExtensionIconSet::MATCH_BIGGER); 435 ExtensionIconSet::MATCH_BIGGER);
437 436
438 info_list.push_back( 437 ui::ScaleFactor resource_scale_factor = ui::GetSupportedScaleFactor(scale);
439 extensions::ImageLoader::ImageRepresentation( 438 info_list.push_back(extensions::ImageLoader::ImageRepresentation(
440 icon_resource, 439 icon_resource,
441 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, 440 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE,
442 gfx::Size(pixel_size, pixel_size), 441 gfx::Size(pixel_size, pixel_size),
443 scale_factors[i])); 442 resource_scale_factor));
444 } 443 }
445 444
446 // LoadImagesAsync actually can run callback synchronously. We want to force 445 // LoadImagesAsync actually can run callback synchronously. We want to force
447 // async. 446 // async.
448 extensions::ImageLoader::Get(profile)->LoadImagesAsync( 447 extensions::ImageLoader::Get(profile)->LoadImagesAsync(
449 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); 448 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback));
450 } 449 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/favicon/favicon_handler.cc » ('j') | chrome/browser/favicon/favicon_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698