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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 274883002: Move didReceiveTitle and related stuff to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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
Index: content/browser/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 19fadd63ba4d64bcecb821b11ed12b6c14a17639..574915c9b8f88977ad03396100012b937147ba5c 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -867,7 +867,7 @@ std::set<GURL> WebContentsImpl::GetSitesInTab() const {
}
const std::string& WebContentsImpl::GetEncoding() const {
- return encoding_;
+ return canonical_encoding_;
}
bool WebContentsImpl::DisplayedInsecureContent() const {
@@ -2086,7 +2086,7 @@ void WebContentsImpl::SetOverrideEncoding(const std::string& encoding) {
}
void WebContentsImpl::ResetOverrideEncoding() {
- encoding_.clear();
+ canonical_encoding_.clear();
Send(new ViewMsg_ResetPageEncodingToDefault(GetRoutingID()));
}
@@ -3331,39 +3331,6 @@ void WebContentsImpl::UpdateState(RenderViewHost* rvh,
controller_.NotifyEntryChanged(entry, entry_index);
}
-void WebContentsImpl::UpdateTitle(RenderViewHost* rvh,
- int32 page_id,
- const base::string16& title,
- base::i18n::TextDirection title_direction) {
- // If we have a title, that's a pretty good indication that we've started
- // getting useful data.
- SetNotWaitingForResponse();
-
- // Try to find the navigation entry, which might not be the current one.
- // For example, it might be from a pending RVH for the pending entry.
- NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
- rvh->GetSiteInstance(), page_id);
-
- // We can handle title updates when we don't have an entry in
- // UpdateTitleForEntry, but only if the update is from the current RVH.
- if (!entry && rvh != GetRenderViewHost())
- return;
-
- // TODO(evan): make use of title_direction.
- // http://code.google.com/p/chromium/issues/detail?id=27094
- if (!UpdateTitleForEntry(entry, title))
- return;
-
- // Broadcast notifications when the UI should be updated.
- if (entry == controller_.GetEntryAtOffset(0))
- NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE);
-}
-
-void WebContentsImpl::UpdateEncoding(RenderViewHost* render_view_host,
- const std::string& encoding) {
- SetEncoding(encoding);
-}
-
void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) {
if (delegate_)
delegate_->UpdateTargetURL(this, page_id, url);
@@ -3482,6 +3449,42 @@ void WebContentsImpl::DocumentOnLoadCompleted(
NotificationService::NoDetails());
}
+void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host,
+ int32 page_id,
+ const base::string16& title,
+ base::i18n::TextDirection title_direction) {
+ RenderViewHost* rvh = render_frame_host->GetRenderViewHost();
+
+ // If we have a title, that's a pretty good indication that we've started
+ // getting useful data.
+ SetNotWaitingForResponse();
+
+ // Try to find the navigation entry, which might not be the current one.
+ // For example, it might be from a pending RVH for the pending entry.
+ NavigationEntryImpl* entry = controller_.GetEntryWithPageID(
+ rvh->GetSiteInstance(), page_id);
+
+ // We can handle title updates when we don't have an entry in
+ // UpdateTitleForEntry, but only if the update is from the current RVH.
+ // TODO(avi): Change to make decisions based on the RenderFrameHost.
+ if (!entry && rvh != GetRenderViewHost())
+ return;
+
+ // TODO(evan): make use of title_direction.
+ // http://code.google.com/p/chromium/issues/detail?id=27094
+ if (!UpdateTitleForEntry(entry, title))
+ return;
+
+ // Broadcast notifications when the UI should be updated.
+ if (entry == controller_.GetEntryAtOffset(0))
+ NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE);
+}
+
+void WebContentsImpl::UpdateEncoding(RenderFrameHost* render_frame_host,
+ const std::string& encoding) {
+ SetEncoding(encoding);
+}
+
void WebContentsImpl::DocumentAvailableInMainFrame(
RenderViewHost* render_view_host) {
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
@@ -3888,7 +3891,11 @@ void WebContentsImpl::OnDialogClosed(int render_process_id,
}
void WebContentsImpl::SetEncoding(const std::string& encoding) {
- encoding_ = GetContentClient()->browser()->
+ if (encoding == last_reported_encoding_)
+ return;
+ last_reported_encoding_ = encoding;
+
+ canonical_encoding_ = GetContentClient()->browser()->
GetCanonicalEncodingNameByAliasName(encoding);
}
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698