Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / favicon / content / favicon_url_util.cc
blobc77ff8b7808453325ec5446d51b8cb42206297e7
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/content/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 "content/public/common/favicon_url.h"
14 namespace favicon {
15 namespace {
17 favicon_base::IconType IconTypeFromContentIconType(
18 content::FaviconURL::IconType icon_type) {
19 switch (icon_type) {
20 case content::FaviconURL::FAVICON:
21 return favicon_base::FAVICON;
22 case content::FaviconURL::TOUCH_ICON:
23 return favicon_base::TOUCH_ICON;
24 case content::FaviconURL::TOUCH_PRECOMPOSED_ICON:
25 return favicon_base::TOUCH_PRECOMPOSED_ICON;
26 case content::FaviconURL::INVALID_ICON:
27 return favicon_base::INVALID_ICON;
29 NOTREACHED();
30 return favicon_base::INVALID_ICON;
33 } // namespace
35 FaviconURL FaviconURLFromContentFaviconURL(
36 const content::FaviconURL& favicon_url) {
37 return FaviconURL(favicon_url.icon_url,
38 IconTypeFromContentIconType(favicon_url.icon_type),
39 favicon_url.icon_sizes);
42 std::vector<FaviconURL> FaviconURLsFromContentFaviconURLs(
43 const std::vector<content::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), FaviconURLFromContentFaviconURL);
48 return result;
51 } // namespace favicon