| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 return YES; | 2800 return YES; |
| 2801 } | 2801 } |
| 2802 | 2802 |
| 2803 - (BOOL)handleDocumentFaviconsMessage:(base::DictionaryValue*)message | 2803 - (BOOL)handleDocumentFaviconsMessage:(base::DictionaryValue*)message |
| 2804 context:(NSDictionary*)context { | 2804 context:(NSDictionary*)context { |
| 2805 base::ListValue* favicons = nullptr; | 2805 base::ListValue* favicons = nullptr; |
| 2806 if (!message->GetList("favicons", &favicons)) { | 2806 if (!message->GetList("favicons", &favicons)) { |
| 2807 DLOG(WARNING) << "JS message parameter not found: favicons"; | 2807 DLOG(WARNING) << "JS message parameter not found: favicons"; |
| 2808 return NO; | 2808 return NO; |
| 2809 } | 2809 } |
| 2810 |
| 2810 std::vector<web::FaviconURL> urls; | 2811 std::vector<web::FaviconURL> urls; |
| 2811 for (size_t fav_idx = 0; fav_idx != favicons->GetSize(); ++fav_idx) { | 2812 bool extraction_result = ExtractFaviconURL(favicons, urls); |
| 2812 base::DictionaryValue* favicon = nullptr; | 2813 |
| 2813 if (!favicons->GetDictionary(fav_idx, &favicon)) | 2814 if (extraction_result && !urls.empty()) |
| 2814 return NO; | |
| 2815 std::string href; | |
| 2816 std::string rel; | |
| 2817 if (!favicon->GetString("href", &href)) { | |
| 2818 DLOG(WARNING) << "JS message parameter not found: href"; | |
| 2819 return NO; | |
| 2820 } | |
| 2821 if (!favicon->GetString("rel", &rel)) { | |
| 2822 DLOG(WARNING) << "JS message parameter not found: rel"; | |
| 2823 return NO; | |
| 2824 } | |
| 2825 web::FaviconURL::IconType icon_type = web::FaviconURL::FAVICON; | |
| 2826 if (rel == "apple-touch-icon") | |
| 2827 icon_type = web::FaviconURL::TOUCH_ICON; | |
| 2828 else if (rel == "apple-touch-icon-precomposed") | |
| 2829 icon_type = web::FaviconURL::TOUCH_PRECOMPOSED_ICON; | |
| 2830 urls.push_back( | |
| 2831 web::FaviconURL(GURL(href), icon_type, std::vector<gfx::Size>())); | |
| 2832 } | |
| 2833 if (!urls.empty()) | |
| 2834 _webStateImpl->OnFaviconUrlUpdated(urls); | 2815 _webStateImpl->OnFaviconUrlUpdated(urls); |
| 2835 return YES; | 2816 return extraction_result; |
| 2836 } | 2817 } |
| 2837 | 2818 |
| 2838 - (BOOL)handleDocumentSubmitMessage:(base::DictionaryValue*)message | 2819 - (BOOL)handleDocumentSubmitMessage:(base::DictionaryValue*)message |
| 2839 context:(NSDictionary*)context { | 2820 context:(NSDictionary*)context { |
| 2840 std::string href; | 2821 std::string href; |
| 2841 if (!message->GetString("href", &href)) { | 2822 if (!message->GetString("href", &href)) { |
| 2842 DLOG(WARNING) << "JS message parameter not found: href"; | 2823 DLOG(WARNING) << "JS message parameter not found: href"; |
| 2843 return NO; | 2824 return NO; |
| 2844 } | 2825 } |
| 2845 const GURL targetURL(href); | 2826 const GURL targetURL(href); |
| (...skipping 2922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5768 } | 5749 } |
| 5769 | 5750 |
| 5770 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 5751 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 5771 } | 5752 } |
| 5772 | 5753 |
| 5773 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5754 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5774 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5755 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5775 } | 5756 } |
| 5776 | 5757 |
| 5777 @end | 5758 @end |
| OLD | NEW |