Index: content/renderer/render_frame_impl.cc |
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
index 8ff540e93bfe07d49b3cacacc4f1a6987ea39c47..a30f0f7b0065934240edb9d221d3f556a0c534f1 100644 |
--- a/content/renderer/render_frame_impl.cc |
+++ b/content/renderer/render_frame_impl.cc |
@@ -80,6 +80,7 @@ |
#include "content/public/common/content_features.h" |
#include "content/public/common/content_switches.h" |
#include "content/public/common/context_menu_params.h" |
+#include "content/public/common/favicon_url.h" |
#include "content/public/common/file_chooser_file_info.h" |
#include "content/public/common/file_chooser_params.h" |
#include "content/public/common/isolated_world_ids.h" |
@@ -677,6 +678,28 @@ double ConvertToBlinkTime(const base::TimeTicks& time_ticks) { |
return (time_ticks - base::TimeTicks()).InSecondsF(); |
} |
+FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { |
+ switch (type) { |
+ case blink::WebIconURL::kTypeFavicon: |
+ return FaviconURL::FAVICON; |
+ case blink::WebIconURL::kTypeTouch: |
+ return FaviconURL::TOUCH_ICON; |
+ case blink::WebIconURL::kTypeTouchPrecomposed: |
+ return FaviconURL::TOUCH_PRECOMPOSED_ICON; |
+ case blink::WebIconURL::kTypeInvalid: |
+ return FaviconURL::INVALID_ICON; |
+ } |
+ return FaviconURL::INVALID_ICON; |
+} |
+ |
+void ConvertToFaviconSizes(const blink::WebVector<blink::WebSize>& web_sizes, |
+ std::vector<gfx::Size>* sizes) { |
+ DCHECK(sizes->empty()); |
+ sizes->reserve(web_sizes.size()); |
+ for (size_t i = 0; i < web_sizes.size(); ++i) |
+ sizes->push_back(gfx::Size(web_sizes[i])); |
+} |
+ |
} // namespace |
// The following methods are outside of the anonymous namespace to ensure that |
@@ -3767,8 +3790,24 @@ void RenderFrameImpl::DidReceiveTitle(const blink::WebString& title, |
} |
void RenderFrameImpl::DidChangeIcon(blink::WebIconURL::Type icon_type) { |
- // TODO(nasko): Investigate wheather implementation should move here. |
- render_view_->didChangeIcon(frame_, icon_type); |
+ SendUpdateFaviconURL(icon_type); |
+} |
+ |
+void RenderFrameImpl::SendUpdateFaviconURL(blink::WebIconURL::Type icon_type) { |
+ if (frame_->Parent()) |
+ return; |
+ |
+ WebVector<blink::WebIconURL> icon_urls = frame_->IconURLs(icon_type); |
+ std::vector<FaviconURL> urls; |
+ for (size_t i = 0; i < icon_urls.size(); i++) { |
+ std::vector<gfx::Size> sizes; |
+ ConvertToFaviconSizes(icon_urls[i].Sizes(), &sizes); |
+ urls.push_back(FaviconURL(icon_urls[i].GetIconURL(), |
+ ToFaviconType(icon_urls[i].IconType()), sizes)); |
+ } |
+ |
+ if (!urls.empty()) |
dcheng
2017/06/06 20:01:30
Maybe we can short-circuit this at line 3801? I gu
Łukasz Anforowicz
2017/06/06 20:55:00
Done.
|
+ Send(new FrameHostMsg_UpdateFaviconURL(GetRoutingID(), urls)); |
} |
void RenderFrameImpl::DidFinishDocumentLoad() { |
@@ -5011,6 +5050,11 @@ void RenderFrameImpl::DidStopLoading() { |
// this state anymore. |
history_subframe_unique_names_.clear(); |
+ blink::WebIconURL::Type icon_types = static_cast<blink::WebIconURL::Type>( |
+ blink::WebIconURL::kTypeFavicon | |
+ blink::WebIconURL::kTypeTouchPrecomposed | blink::WebIconURL::kTypeTouch); |
+ SendUpdateFaviconURL(icon_types); |
+ |
render_view_->FrameDidStopLoading(frame_); |
Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
} |