cc: Fix high/low res scale collisions
[chromium-blink-merge.git] / components / favicon / ios / favicon_url_util.cc
blob95bcfda262b4a424b7ec2e1757b3d572d1351a39
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
3 // found in the LICENSE file.
5 #include "components/favicon/ios/favicon_url_util.h"
7 #include <algorithm>
8 #include <iterator>
10 #include "components/favicon/core/favicon_url.h"
11 #include "components/favicon_base/favicon_types.h"
12 #include "ios/web/public/favicon_url.h"
14 namespace favicon {
15 namespace {
17 favicon_base::IconType IconTypeFromWebIconType(
18 web::FaviconURL::IconType icon_type) {
19 switch (icon_type) {
20 case web::FaviconURL::FAVICON:
21 return favicon_base::FAVICON;
22 case web::FaviconURL::TOUCH_ICON:
23 return favicon_base::TOUCH_ICON;
24 case web::FaviconURL::TOUCH_PRECOMPOSED_ICON:
25 return favicon_base::TOUCH_PRECOMPOSED_ICON;
26 case web::FaviconURL::INVALID_ICON:
27 return favicon_base::INVALID_ICON;
29 NOTREACHED();
30 return favicon_base::INVALID_ICON;
33 } // namespace
35 FaviconURL FaviconURLFromWebFaviconURL(
36 const web::FaviconURL& favicon_url) {
37 return FaviconURL(favicon_url.icon_url,
38 IconTypeFromWebIconType(favicon_url.icon_type),
39 favicon_url.icon_sizes);
42 std::vector<FaviconURL> FaviconURLsFromWebFaviconURLs(
43 const std::vector<web::FaviconURL>& favicon_urls) {
44 std::vector<FaviconURL> result;
45 result.reserve(favicon_urls.size());
46 std::transform(favicon_urls.begin(), favicon_urls.end(),
47 std::back_inserter(result), FaviconURLFromWebFaviconURL);
48 return result;
51 } // namespace favicon