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

Unified Diff: content/renderer/render_frame_impl.cc

Issue 2918903002: Move IconURLs method from WebFrame to WebLocalFrame (Closed)
Patch Set: s/kFavIcon/kFavicon/g (as suggested in CR feedback from pkotwicz@). Created 3 years, 6 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 | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_frame_impl.cc
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index c36999d9a0e188092a453ed1402ea42d7f5b6921..36c29de84408e4a3b48c189ab1bd6cd0574ca866 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -79,6 +79,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,30 @@ 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;
+}
+
+std::vector<gfx::Size> ConvertToFaviconSizes(
+ const blink::WebVector<blink::WebSize>& web_sizes) {
+ std::vector<gfx::Size> result;
+ result.reserve(web_sizes.size());
+ for (const blink::WebSize& web_size : web_sizes)
+ result.push_back(gfx::Size(web_size));
+ return result;
+}
+
} // namespace
// The following methods are outside of the anonymous namespace to ensure that
@@ -3787,8 +3812,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;
+ urls.reserve(icon_urls.size());
+ for (const blink::WebIconURL& icon_url : icon_urls) {
+ urls.push_back(FaviconURL(icon_url.GetIconURL(),
+ ToFaviconType(icon_url.IconType()),
+ ConvertToFaviconSizes(icon_url.Sizes())));
+ }
+ DCHECK_EQ(icon_urls.size(), urls.size());
+
+ Send(new FrameHostMsg_UpdateFaviconURL(GetRoutingID(), urls));
}
void RenderFrameImpl::DidFinishDocumentLoad() {
@@ -5043,6 +5088,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_));
}
« no previous file with comments | « content/renderer/render_frame_impl.h ('k') | content/renderer/render_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698