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

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2880723002: Favicon url is used only if it is valid (Closed)
Patch Set: Change the comment Created 3 years, 7 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 | « ios/web/web_state/js/resources/common.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 343362f14b72410ed435dd148c2f0311486502f5..6183daf12f7787aad12e8cec2f3e4ebb0824435a 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -2541,6 +2541,7 @@ registerLoadRequestForURL:(const GURL&)requestURL
return NO;
}
std::vector<web::FaviconURL> urls;
+ BOOL hasFavicon = NO;
for (size_t fav_idx = 0; fav_idx != favicons->GetSize(); ++fav_idx) {
base::DictionaryValue* favicon = nullptr;
if (!favicons->GetDictionary(fav_idx, &favicon))
@@ -2555,13 +2556,37 @@ registerLoadRequestForURL:(const GURL&)requestURL
DLOG(WARNING) << "JS message parameter not found: rel";
return NO;
}
+ BOOL isAppleTouch = YES;
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;
- urls.push_back(
- web::FaviconURL(GURL(href), icon_type, std::vector<gfx::Size>()));
+ else
+ isAppleTouch = NO;
+ GURL url = GURL(href);
+ if (url.is_valid()) {
+ urls.push_back(web::FaviconURL(url, icon_type, std::vector<gfx::Size>()));
+ hasFavicon = hasFavicon || !isAppleTouch;
+ }
+ }
+
+ if (!hasFavicon) {
+ // If an HTTP(S)? webpage does not reference a "favicon" of a type different
+ // from apple touch, then search for a file named "favicon.ico" at the root
+ // of the website (legacy). http://en.wikipedia.org/wiki/Favicon
+ id origin = context[kOriginURLKey];
+ if (origin) {
+ NSURL* originNSURL = base::mac::ObjCCastStrict<NSURL>(origin);
+ GURL originGURL = net::GURLWithNSURL(originNSURL);
+ if (originGURL.is_valid() && originGURL.SchemeIsHTTPOrHTTPS()) {
+ GURL::Replacements replacements;
+ replacements.SetPathStr("/favicon.ico");
+ urls.push_back(web::FaviconURL(
+ originGURL.ReplaceComponents(replacements),
+ web::FaviconURL::FAVICON, std::vector<gfx::Size>()));
+ }
+ }
}
if (!urls.empty())
_webStateImpl->OnFaviconUrlUpdated(urls);
« no previous file with comments | « ios/web/web_state/js/resources/common.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698