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

Side by Side Diff: chrome/browser/ui/webui/chrome_web_ui_controller_factory.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/ui/webui/chrome_web_ui_controller_factory.h" 5 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 #else 589 #else
590 RunFaviconCallbackAsync( 590 RunFaviconCallbackAsync(
591 callback, new std::vector<favicon_base::FaviconRawBitmapResult>()); 591 callback, new std::vector<favicon_base::FaviconRawBitmapResult>());
592 #endif 592 #endif
593 return; 593 return;
594 } 594 }
595 595
596 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results = 596 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results =
597 new std::vector<favicon_base::FaviconRawBitmapResult>(); 597 new std::vector<favicon_base::FaviconRawBitmapResult>();
598 598
599 // Assume that GetFaviconResourceBytes() returns favicons which are 599 // Use ui::GetSupportedScaleFactors instead of
600 // |gfx::kFaviconSize| x |gfx::kFaviconSize| DIP. 600 // favicon_base::GetFaviconScales() because chrome favicons comes from
601 std::vector<ui::ScaleFactor> scale_factors = 601 // resources.
602 favicon_base::GetFaviconScaleFactors(); 602 std::vector<ui::ScaleFactor> resource_scale_factors =
603 ui::GetSupportedScaleFactors();
604
603 std::vector<gfx::Size> candidate_sizes; 605 std::vector<gfx::Size> candidate_sizes;
604 for (size_t i = 0; i < scale_factors.size(); ++i) { 606 for (size_t i = 0; i < resource_scale_factors.size(); ++i) {
605 float scale = ui::GetScaleForScaleFactor(scale_factors[i]); 607 float scale = ui::GetScaleForScaleFactor(resource_scale_factors[i]);
608 // Assume that GetFaviconResourceBytes() returns favicons which are
609 // |gfx::kFaviconSize| x |gfx::kFaviconSize| DIP.
606 int candidate_edge_size = 610 int candidate_edge_size =
607 static_cast<int>(gfx::kFaviconSize * scale + 0.5f); 611 static_cast<int>(gfx::kFaviconSize * scale + 0.5f);
608 candidate_sizes.push_back( 612 candidate_sizes.push_back(
609 gfx::Size(candidate_edge_size, candidate_edge_size)); 613 gfx::Size(candidate_edge_size, candidate_edge_size));
610 } 614 }
611 std::vector<size_t> selected_indices; 615 std::vector<size_t> selected_indices;
612 SelectFaviconFrameIndices(candidate_sizes, 616 SelectFaviconFrameIndices(
613 desired_sizes_in_pixel, 617 candidate_sizes, desired_sizes_in_pixel, &selected_indices, NULL);
614 &selected_indices,
615 NULL);
616 for (size_t i = 0; i < selected_indices.size(); ++i) { 618 for (size_t i = 0; i < selected_indices.size(); ++i) {
617 size_t selected_index = selected_indices[i]; 619 size_t selected_index = selected_indices[i];
618 scoped_refptr<base::RefCountedMemory> bitmap(GetFaviconResourceBytes( 620 ui::ScaleFactor selected_resource_scale =
619 url, scale_factors[selected_index])); 621 resource_scale_factors[selected_index];
622
623 scoped_refptr<base::RefCountedMemory> bitmap(
624 GetFaviconResourceBytes(url, selected_resource_scale));
620 if (bitmap.get() && bitmap->size()) { 625 if (bitmap.get() && bitmap->size()) {
621 favicon_base::FaviconRawBitmapResult bitmap_result; 626 favicon_base::FaviconRawBitmapResult bitmap_result;
622 bitmap_result.bitmap_data = bitmap; 627 bitmap_result.bitmap_data = bitmap;
623 // Leave |bitmap_result|'s icon URL as the default of GURL(). 628 // Leave |bitmap_result|'s icon URL as the default of GURL().
624 bitmap_result.icon_type = favicon_base::FAVICON; 629 bitmap_result.icon_type = favicon_base::FAVICON;
625 favicon_bitmap_results->push_back(bitmap_result); 630 favicon_bitmap_results->push_back(bitmap_result);
626 631
627 bitmap_result.pixel_size = candidate_sizes[selected_index]; 632 bitmap_result.pixel_size = candidate_sizes[selected_index];
628 } 633 }
629 } 634 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 #endif 707 #endif
703 708
704 // Android doesn't use the plugins pages. 709 // Android doesn't use the plugins pages.
705 if (page_url.host() == chrome::kChromeUIPluginsHost) 710 if (page_url.host() == chrome::kChromeUIPluginsHost)
706 return PluginsUI::GetFaviconResourceBytes(scale_factor); 711 return PluginsUI::GetFaviconResourceBytes(scale_factor);
707 712
708 #endif 713 #endif
709 714
710 return NULL; 715 return NULL;
711 } 716 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698