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

Side by Side Diff: chrome/browser/manifest/manifest_icon_downloader.cc

Issue 1354903003: manifest: allow the icon downloader to choose non-square icons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on latest Created 5 years, 3 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 | « no previous file | chrome/browser/manifest/manifest_icon_downloader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_downloader.h" 5 #include "chrome/browser/manifest/manifest_icon_downloader.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "chrome/browser/manifest/manifest_icon_selector.h" 9 #include "chrome/browser/manifest/manifest_icon_selector.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 119
120 if (best_delta > 0 && delta < 0) 120 if (best_delta > 0 && delta < 0)
121 continue; 121 continue;
122 122
123 if ((best_delta > 0 && delta < best_delta) || 123 if ((best_delta > 0 && delta < best_delta) ||
124 (best_delta < 0 && delta > best_delta && delta >= max_negative_delta)) { 124 (best_delta < 0 && delta > best_delta && delta >= max_negative_delta)) {
125 best_index = i; 125 best_index = i;
126 best_delta = delta; 126 best_delta = delta;
127 } 127 }
128 } 128 }
129
130 if (best_index != -1)
131 return best_index;
132
133 // There was no square icon of a correct size found. Try to find the most
134 // square possible icon which has both dimensions greater than the minimum
135 // size.
mlamouri (slow - plz ping) 2015/09/18 13:41:59 Very quick comment: maybe you could use a ratio in
Lalit Maganti 2015/09/18 14:06:46 Problem with using a ratio is that the code become
gone 2015/09/18 18:46:41 I agree with Mounir about relying on ratios; the d
Lalit Maganti 2015/09/21 09:52:34 Done.
136 int best_dimension_difference = std::numeric_limits<int>::max();
137 for (size_t i = 0; i < bitmaps.size(); ++i) {
138 if (bitmaps[i].height() < minimum_icon_size_in_px ||
139 bitmaps[i].width() < minimum_icon_size_in_px) {
140 continue;
141 }
142
143 int dimension_difference = abs(bitmaps[i].height() - bitmaps[i].width());
144 if (dimension_difference < best_dimension_difference) {
145 best_index = i;
146 best_dimension_difference = dimension_difference;
147 }
148 }
149
129 return best_index; 150 return best_index;
130 } 151 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/manifest/manifest_icon_downloader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698