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

Unified Diff: chrome/renderer/chrome_render_view_observer.cc

Issue 10831163: Update favicon URLs on FinishLoad for main frame (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Moved the function to match the order in the header file. Created 8 years, 4 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 | « chrome/renderer/chrome_render_view_observer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/chrome_render_view_observer.cc
diff --git a/chrome/renderer/chrome_render_view_observer.cc b/chrome/renderer/chrome_render_view_observer.cc
index 9d820967d6dfee9bf5bed81c71c2830eb39bd1e2..9793f19869f9e96fadf6fbd2169f5b6c3b5c8192 100644
--- a/chrome/renderer/chrome_render_view_observer.cc
+++ b/chrome/renderer/chrome_render_view_observer.cc
@@ -696,23 +696,21 @@ void ChromeRenderViewObserver::DidStopLoading() {
routing_id(), render_view()->GetPageId(), osd_url,
search_provider::AUTODETECTED_PROVIDER));
}
+}
+
+void ChromeRenderViewObserver::DidFinishLoad(WebKit::WebFrame* frame) {
+ if (frame->parent())
+ return;
+ // Please note that we are updating favicons only for the _main_ frame.
+ // Updating Favicon URLs at DidFinishLoad ensures that icon loads always get
+ // initiated after all of the other page resources have been fetched, so icon
+ // loads should not compete with page resources for network bandwidth.
int icon_types = WebIconURL::TypeFavicon;
if (chrome::kEnableTouchIcon)
icon_types |= WebIconURL::TypeTouchPrecomposed | WebIconURL::TypeTouch;
- WebVector<WebIconURL> icon_urls =
- render_view()->GetWebView()->mainFrame()->iconURLs(icon_types);
- std::vector<FaviconURL> urls;
- for (size_t i = 0; i < icon_urls.size(); i++) {
- WebURL url = icon_urls[i].iconURL();
- if (!url.isEmpty())
- urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType())));
- }
- if (!urls.empty()) {
- Send(new IconHostMsg_UpdateFaviconURL(
- routing_id(), render_view()->GetPageId(), urls));
- }
+ CollectAndUpdateFaviconURLs(frame, icon_types);
}
void ChromeRenderViewObserver::DidChangeIcon(WebFrame* frame,
@@ -724,14 +722,7 @@ void ChromeRenderViewObserver::DidChangeIcon(WebFrame* frame,
icon_type != WebIconURL::TypeFavicon)
return;
- WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type);
- std::vector<FaviconURL> urls;
- for (size_t i = 0; i < icon_urls.size(); i++) {
- urls.push_back(FaviconURL(icon_urls[i].iconURL(),
- ToFaviconType(icon_urls[i].iconType())));
- }
- Send(new IconHostMsg_UpdateFaviconURL(
- routing_id(), render_view()->GetPageId(), urls));
+ CollectAndUpdateFaviconURLs(frame, icon_type);
}
void ChromeRenderViewObserver::DidCommitProvisionalLoad(
@@ -1093,6 +1084,21 @@ SkBitmap ChromeRenderViewObserver::ImageFromDataUrl(const GURL& url) const {
return SkBitmap();
}
+void ChromeRenderViewObserver::CollectAndUpdateFaviconURLs(
+ WebKit::WebFrame* frame, int icon_types) {
+ WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_types);
+ std::vector<FaviconURL> urls;
+ for (size_t i = 0; i < icon_urls.size(); i++) {
+ WebURL url = icon_urls[i].iconURL();
+ if (!url.isEmpty())
+ urls.push_back(FaviconURL(url, ToFaviconType(icon_urls[i].iconType())));
+ }
+ if (!urls.empty()) {
+ Send(new IconHostMsg_UpdateFaviconURL(
+ routing_id(), render_view()->GetPageId(), urls));
+ }
+}
+
bool ChromeRenderViewObserver::IsStrictSecurityHost(const std::string& host) {
return (strict_security_hosts_.find(host) != strict_security_hosts_.end());
}
« no previous file with comments | « chrome/renderer/chrome_render_view_observer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698