diff options
-rw-r--r-- | components/favicon.gypi | 20 | ||||
-rw-r--r-- | components/favicon/ios/DEPS | 3 | ||||
-rw-r--r-- | components/favicon/ios/favicon_url_util.cc | 51 | ||||
-rw-r--r-- | components/favicon/ios/favicon_url_util.h | 28 |
4 files changed, 102 insertions, 0 deletions
diff --git a/components/favicon.gypi b/components/favicon.gypi index d1aa277..a8fabbd 100644 --- a/components/favicon.gypi +++ b/components/favicon.gypi @@ -61,5 +61,25 @@ }, ], }], + ['OS=="ios"', { + 'targets': [ + { + 'target_name': 'favicon_ios', + 'type': 'static_library', + 'dependencies': [ + '../ios/web/ios_web.gyp:ios_web', + 'favicon_base', + 'favicon_core', + ], + 'sources': [ + 'favicon/ios/favicon_url_util.h', + 'favicon/ios/favicon_url_util.cc', + ], + 'include_dirs': [ + '..', + ], + }, + ], + }], ], } 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_ |