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

Unified Diff: ios/web/public/favicon_url.cc

Issue 2541093002: DO NOT COMMIT (Closed)
Patch Set: Created 4 years 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 | « ios/web/public/favicon_url.h ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
+
} // namespace web
« no previous file with comments | « ios/web/public/favicon_url.h ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698