Chromium Code Reviews| 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..645b6901d951e31943d28821a4131aa620bb95fb 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,29 @@ 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::IconType::kFavIcon; |
| + case blink::WebIconURL::kTypeTouch: |
| + return FaviconURL::IconType::kTouchIcon; |
| + case blink::WebIconURL::kTypeTouchPrecomposed: |
| + return FaviconURL::IconType::kTouchPrecomposedIcon; |
| + case blink::WebIconURL::kTypeInvalid: |
| + return FaviconURL::IconType::kInvalid; |
| + } |
| + NOTREACHED(); |
| + return FaviconURL::IconType::kInvalid; |
| +} |
| + |
| +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) |
|
Avi (use Gerrit)
2017/06/06 23:10:04
for (:)
Łukasz Anforowicz
2017/06/06 23:25:36
Done + also returning the vector (instead of using
|
| + sizes->push_back(gfx::Size(web_sizes[i])); |
| +} |
| + |
| } // namespace |
| // The following methods are outside of the anonymous namespace to ensure that |
| @@ -3767,8 +3791,28 @@ 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_types_mask) { |
| + if (frame_->Parent()) |
| + return; |
| + |
| + WebVector<blink::WebIconURL> icon_urls = frame_->IconURLs(icon_types_mask); |
| + if (icon_urls.empty()) |
| + return; |
| + |
| + std::vector<FaviconURL> urls; |
| + for (size_t i = 0; i < icon_urls.size(); i++) { |
|
Avi (use Gerrit)
2017/06/06 23:10:04
for (:)
Łukasz Anforowicz
2017/06/06 23:25:36
Done.
|
| + 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)); |
| + } |
| + DCHECK_EQ(icon_urls.size(), urls.size()); |
| + |
| + Send(new FrameHostMsg_UpdateFaviconURL(GetRoutingID(), urls)); |
| } |
| void RenderFrameImpl::DidFinishDocumentLoad() { |
| @@ -5011,6 +5055,13 @@ void RenderFrameImpl::DidStopLoading() { |
| // this state anymore. |
| history_subframe_unique_names_.clear(); |
| + blink::WebIconURL::Type icon_types_mask = |
| + static_cast<blink::WebIconURL::Type>( |
| + blink::WebIconURL::kTypeFavicon | |
| + blink::WebIconURL::kTypeTouchPrecomposed | |
| + blink::WebIconURL::kTypeTouch); |
| + SendUpdateFaviconURL(icon_types_mask); |
| + |
| render_view_->FrameDidStopLoading(frame_); |
| Send(new FrameHostMsg_DidStopLoading(routing_id_)); |
| } |