summaryrefslogtreecommitdiffstats
path: root/components/favicon
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2015-04-02 08:10:53 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-02 15:11:37 +0000
commita81c1a22cdf5ab99f59ac67965b4bacba2767e2e (patch)
tree046713736e0f364e2424f2d4d686c7e1532ec575 /components/favicon
parent7f47161c5246973e5ed615221e938eab359edfc0 (diff)
downloadchromium_src-a81c1a22cdf5ab99f59ac67965b4bacba2767e2e.zip
chromium_src-a81c1a22cdf5ab99f59ac67965b4bacba2767e2e.tar.gz
chromium_src-a81c1a22cdf5ab99f59ac67965b4bacba2767e2e.tar.bz2
Introduce components/favicon/ios
In preparation of the creation of WebFaviconDriver, introduce helper functions to convert from web::FaviconURL to favicon::FaviconURL mirroring the functions to convert from content::FaviconURL to favicon::FaviconURL. BUG=472117 Review URL: https://codereview.chromium.org/1050403002 Cr-Commit-Position: refs/heads/master@{#323488}
Diffstat (limited to 'components/favicon')
-rw-r--r--components/favicon/ios/DEPS3
-rw-r--r--components/favicon/ios/favicon_url_util.cc51
-rw-r--r--components/favicon/ios/favicon_url_util.h28
3 files changed, 82 insertions, 0 deletions
diff --git a/components/favicon/ios/DEPS b/components/favicon/ios/DEPS
new file mode 100644
index 0000000..0fc0ddd
--- /dev/null
+++ b/components/favicon/ios/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+ios/web/public",
+]
diff --git a/components/favicon/ios/favicon_url_util.cc b/components/favicon/ios/favicon_url_util.cc
new file mode 100644
index 0000000..95bcfda
--- /dev/null
+++ b/components/favicon/ios/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/ios/favicon_url_util.h"
+
+#include <algorithm>
+#include <iterator>
+
+#include "components/favicon/core/favicon_url.h"
+#include "components/favicon_base/favicon_types.h"
+#include "ios/web/public/favicon_url.h"
+
+namespace favicon {
+namespace {
+
+favicon_base::IconType IconTypeFromWebIconType(
+ web::FaviconURL::IconType icon_type) {
+ switch (icon_type) {
+ case web::FaviconURL::FAVICON:
+ return favicon_base::FAVICON;
+ case web::FaviconURL::TOUCH_ICON:
+ return favicon_base::TOUCH_ICON;
+ case web::FaviconURL::TOUCH_PRECOMPOSED_ICON:
+ return favicon_base::TOUCH_PRECOMPOSED_ICON;
+ case web::FaviconURL::INVALID_ICON:
+ return favicon_base::INVALID_ICON;
+ }
+ NOTREACHED();
+ return favicon_base::INVALID_ICON;
+}
+
+} // namespace
+
+FaviconURL FaviconURLFromWebFaviconURL(
+ const web::FaviconURL& favicon_url) {
+ return FaviconURL(favicon_url.icon_url,
+ IconTypeFromWebIconType(favicon_url.icon_type),
+ favicon_url.icon_sizes);
+}
+
+std::vector<FaviconURL> FaviconURLsFromWebFaviconURLs(
+ const std::vector<web::FaviconURL>& favicon_urls) {
+ std::vector<FaviconURL> result;
+ result.reserve(favicon_urls.size());
+ std::transform(favicon_urls.begin(), favicon_urls.end(),
+ std::back_inserter(result), FaviconURLFromWebFaviconURL);
+ return result;
+}
+
+} // namespace favicon
diff --git a/components/favicon/ios/favicon_url_util.h b/components/favicon/ios/favicon_url_util.h
new file mode 100644
index 0000000..a76db07
--- /dev/null
+++ b/components/favicon/ios/favicon_url_util.h
@@ -0,0 +1,28 @@
+// 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.
+
+#ifndef COMPONENTS_FAVICON_IOS_FAVICON_URL_UTIL_H_
+#define COMPONENTS_FAVICON_IOS_FAVICON_URL_UTIL_H_
+
+#include <vector>
+
+namespace web {
+struct FaviconURL;
+}
+
+namespace favicon {
+
+struct FaviconURL;
+
+// Creates a favicon::FaviconURL from a web::FaviconURL.
+FaviconURL FaviconURLFromWebFaviconURL(
+ const web::FaviconURL& favicon_url);
+
+// Creates favicon::FaviconURLs from web::FaviconURLs.
+std::vector<FaviconURL> FaviconURLsFromWebFaviconURLs(
+ const std::vector<web::FaviconURL>& favicon_urls);
+
+} // namespace favicon
+
+#endif // COMPONENTS_FAVICON_IOS_FAVICON_URL_UTIL_H_