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

Side by Side Diff: components/favicon_base/select_favicon_frames.cc

Issue 2739173002: Always select best favicon bitmap (Closed)
Patch Set: Return default value after NOTREACHED. Created 3 years, 8 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
« no previous file with comments | « components/favicon/core/favicon_handler_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/favicon_base/select_favicon_frames.h" 5 #include "components/favicon_base/select_favicon_frames.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <map> 10 #include <map>
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 259
260 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes, 260 void SelectFaviconFrameIndices(const std::vector<gfx::Size>& frame_pixel_sizes,
261 const std::vector<int>& desired_sizes, 261 const std::vector<int>& desired_sizes,
262 std::vector<size_t>* best_indices, 262 std::vector<size_t>* best_indices,
263 float* match_score) { 263 float* match_score) {
264 std::vector<SelectionResult> results; 264 std::vector<SelectionResult> results;
265 GetCandidateIndicesWithBestScores( 265 GetCandidateIndicesWithBestScores(
266 frame_pixel_sizes, desired_sizes, match_score, &results); 266 frame_pixel_sizes, desired_sizes, match_score, &results);
267 267
268 if (!best_indices)
269 return;
270
268 std::set<size_t> already_added; 271 std::set<size_t> already_added;
269 for (size_t i = 0; i < results.size(); ++i) { 272 for (size_t i = 0; i < results.size(); ++i) {
270 size_t index = results[i].index; 273 size_t index = results[i].index;
271 // GetCandidateIndicesWithBestScores() will return duplicate indices if the 274 // GetCandidateIndicesWithBestScores() will return duplicate indices if the
272 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple 275 // bitmap data with |frame_pixel_sizes[index]| should be used for multiple
273 // scale factors. Remove duplicates here such that |best_indices| contains 276 // scale factors. Remove duplicates here such that |best_indices| contains
274 // no duplicates. 277 // no duplicates.
275 if (already_added.find(index) == already_added.end()) { 278 if (already_added.find(index) == already_added.end()) {
276 already_added.insert(index); 279 already_added.insert(index);
277 best_indices->push_back(index); 280 best_indices->push_back(index);
278 } 281 }
279 } 282 }
280 } 283 }
OLDNEW
« no previous file with comments | « components/favicon/core/favicon_handler_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698