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

Unified Diff: components/favicon/content/favicon_url_util.cc

Issue 1020213002: Componentize conversion of content::FaviconURL to favicon::FaviconURL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/favicon/content/favicon_url_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/favicon/content/favicon_url_util.cc
diff --git a/components/favicon/content/favicon_url_util.cc b/components/favicon/content/favicon_url_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c77ff8b7808453325ec5446d51b8cb42206297e7
--- /dev/null
+++ b/components/favicon/content/favicon_url_util.cc
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/favicon/content/favicon_url_util.h"
+
+#include <algorithm>
+#include <iterator>
+
+#include "components/favicon/core/favicon_url.h"
+#include "components/favicon_base/favicon_types.h"
+#include "content/public/common/favicon_url.h"
+
+namespace favicon {
+namespace {
+
+favicon_base::IconType IconTypeFromContentIconType(
+ content::FaviconURL::IconType icon_type) {
+ switch (icon_type) {
+ case content::FaviconURL::FAVICON:
+ return favicon_base::FAVICON;
+ case content::FaviconURL::TOUCH_ICON:
+ return favicon_base::TOUCH_ICON;
+ case content::FaviconURL::TOUCH_PRECOMPOSED_ICON:
+ return favicon_base::TOUCH_PRECOMPOSED_ICON;
+ case content::FaviconURL::INVALID_ICON:
+ return favicon_base::INVALID_ICON;
+ }
+ NOTREACHED();
+ return favicon_base::INVALID_ICON;
+}
+
+} // namespace
+
+FaviconURL FaviconURLFromContentFaviconURL(
+ const content::FaviconURL& favicon_url) {
+ return FaviconURL(favicon_url.icon_url,
+ IconTypeFromContentIconType(favicon_url.icon_type),
+ favicon_url.icon_sizes);
+}
+
+std::vector<FaviconURL> FaviconURLsFromContentFaviconURLs(
+ const std::vector<content::FaviconURL>& favicon_urls) {
+ std::vector<FaviconURL> result;
+ result.reserve(favicon_urls.size());
+ std::transform(favicon_urls.begin(), favicon_urls.end(),
+ std::back_inserter(result), FaviconURLFromContentFaviconURL);
+ return result;
+}
+
+} // namespace favicon
« no previous file with comments | « components/favicon/content/favicon_url_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698