Index: ios/web/public/favicon_url.cc |
diff --git a/ios/web/public/favicon_url.cc b/ios/web/public/favicon_url.cc |
index 9906b357185d4d594a78fc1cca584cfc5095562c..08ec682d654cc30492317e7dfac8c08f7bf69760 100644 |
--- a/ios/web/public/favicon_url.cc |
+++ b/ios/web/public/favicon_url.cc |
@@ -4,6 +4,8 @@ |
#include "ios/web/public/favicon_url.h" |
+#include "base/values.h" |
+ |
namespace web { |
FaviconURL::FaviconURL() |
@@ -20,4 +22,31 @@ FaviconURL::FaviconURL(const FaviconURL& other) = default; |
FaviconURL::~FaviconURL() { |
} |
+bool ExtractFaviconURL(base::ListValue* favicons, |
+ std::vector<web::FaviconURL>& result_urls) { |
+ for (size_t fav_idx = 0; fav_idx != favicons->GetSize(); ++fav_idx) { |
+ base::DictionaryValue* favicon = nullptr; |
+ if (!favicons->GetDictionary(fav_idx, &favicon)) |
+ return false; |
+ std::string href; |
+ std::string rel; |
+ if (!favicon->GetString("href", &href)) { |
+ DLOG(WARNING) << "JS message parameter not found: href"; |
+ return false; |
+ } |
+ if (!favicon->GetString("rel", &rel)) { |
+ DLOG(WARNING) << "JS message parameter not found: rel"; |
+ return false; |
+ } |
+ web::FaviconURL::IconType icon_type = web::FaviconURL::FAVICON; |
+ if (rel == "apple-touch-icon") |
+ icon_type = web::FaviconURL::TOUCH_ICON; |
+ else if (rel == "apple-touch-icon-precomposed") |
+ icon_type = web::FaviconURL::TOUCH_PRECOMPOSED_ICON; |
+ result_urls.push_back( |
+ web::FaviconURL(GURL(href), icon_type, std::vector<gfx::Size>())); |
+ } |
+ return true; |
kkhorimoto
2016/11/28 23:48:26
Should we return false if |result_urls| is empty a
|
+} |
+ |
} // namespace web |