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

Side by Side Diff: content/browser/manifest/manifest_icon_selector.cc

Issue 2933743002: Move chrome/browser/manifest to content/browser. (Closed)
Patch Set: rebased Created 3 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
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_selector.h" 5 #include "content/public/browser/manifest_icon_selector.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "components/mime_util/mime_util.h" 11 #include "components/mime_util/mime_util.h"
12 12
13 namespace content {
14
13 // static 15 // static
14 GURL ManifestIconSelector::FindBestMatchingIcon( 16 GURL ManifestIconSelector::FindBestMatchingIcon(
15 const std::vector<content::Manifest::Icon>& icons, 17 const std::vector<Manifest::Icon>& icons,
16 int ideal_icon_size_in_px, 18 int ideal_icon_size_in_px,
17 int minimum_icon_size_in_px, 19 int minimum_icon_size_in_px,
18 content::Manifest::Icon::IconPurpose purpose) { 20 Manifest::Icon::IconPurpose purpose) {
19 DCHECK(minimum_icon_size_in_px <= ideal_icon_size_in_px); 21 DCHECK(minimum_icon_size_in_px <= ideal_icon_size_in_px);
20 22
21 // Icon with exact matching size has priority over icon with size "any", which 23 // Icon with exact matching size has priority over icon with size "any", which
22 // has priority over icon with closest matching size. 24 // has priority over icon with closest matching size.
23 int latest_size_any_index = -1; 25 int latest_size_any_index = -1;
24 int closest_size_match_index = -1; 26 int closest_size_match_index = -1;
25 int best_delta_in_size = std::numeric_limits<int>::min(); 27 int best_delta_in_size = std::numeric_limits<int>::min();
26 28
27 for (size_t i = 0; i < icons.size(); ++i) { 29 for (size_t i = 0; i < icons.size(); ++i) {
28 const auto& icon = icons[i]; 30 const auto& icon = icons[i];
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 75 }
74 } 76 }
75 77
76 if (latest_size_any_index != -1) 78 if (latest_size_any_index != -1)
77 return icons[latest_size_any_index].src; 79 return icons[latest_size_any_index].src;
78 else if (closest_size_match_index != -1) 80 else if (closest_size_match_index != -1)
79 return icons[closest_size_match_index].src; 81 return icons[closest_size_match_index].src;
80 else 82 else
81 return GURL(); 83 return GURL();
82 } 84 }
85
86 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698