Move didReceiveTitle and related stuff to RenderFrame.
BUG=361761
TEST=no visible change
Review URL: https://codereview.chromium.org/274883002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269641 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc
index 39bef48b8..d6d922d 100644
--- a/content/renderer/render_frame_impl.cc
+++ b/content/renderer/render_frame_impl.cc
@@ -1973,7 +1973,7 @@
UpdateURL(frame);
// Check whether we have new encoding name.
- render_view_->UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
+ UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
}
void RenderFrameImpl::didClearWindowObject(blink::WebLocalFrame* frame) {
@@ -2013,8 +2013,20 @@
const blink::WebString& title,
blink::WebTextDirection direction) {
DCHECK(!frame_ || frame_ == frame);
- // TODO(nasko): Investigate wheather implementation should move here.
- render_view_->didReceiveTitle(frame, title, direction);
+ // Ignore all but top level navigations.
+ if (!frame->parent()) {
+ base::string16 title16 = title;
+ base::debug::TraceLog::GetInstance()->UpdateProcessLabel(
+ routing_id_, base::UTF16ToUTF8(title16));
+
+ base::string16 shortened_title = title16.substr(0, kMaxTitleChars);
+ Send(new FrameHostMsg_UpdateTitle(routing_id_,
+ render_view_->page_id_,
+ shortened_title, direction));
+ }
+
+ // Also check whether we have new encoding name.
+ UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
}
void RenderFrameImpl::didChangeIcon(blink::WebLocalFrame* frame,
@@ -2037,7 +2049,7 @@
FOR_EACH_OBSERVER(RenderFrameObserver, observers_, DidFinishDocumentLoad());
// Check whether we have new encoding name.
- render_view_->UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
+ UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
}
void RenderFrameImpl::didHandleOnloadEvents(blink::WebLocalFrame* frame) {
@@ -3301,6 +3313,13 @@
Send(new FrameHostMsg_OpenURL(routing_id_, params));
}
+void RenderFrameImpl::UpdateEncoding(WebFrame* frame,
+ const std::string& encoding_name) {
+ // Only update main frame's encoding_name.
+ if (!frame->parent())
+ Send(new FrameHostMsg_UpdateEncoding(routing_id_, encoding_name));
+}
+
void RenderFrameImpl::SyncSelectionIfRequired() {
base::string16 text;
size_t offset;
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h
index d46c0cd..af42b7b 100644
--- a/content/renderer/render_frame_impl.h
+++ b/content/renderer/render_frame_impl.h
@@ -460,6 +460,22 @@
const Referrer& referrer,
blink::WebNavigationPolicy policy);
+ // Update current main frame's encoding and send it to browser window.
+ // Since we want to let users see the right encoding info from menu
+ // before finishing loading, we call the UpdateEncoding in
+ // a) function:DidCommitLoadForFrame. When this function is called,
+ // that means we have got first data. In here we try to get encoding
+ // of page if it has been specified in http header.
+ // b) function:DidReceiveTitle. When this function is called,
+ // that means we have got specified title. Because in most of webpages,
+ // title tags will follow meta tags. In here we try to get encoding of
+ // page if it has been specified in meta tag.
+ // c) function:DidFinishDocumentLoadForFrame. When this function is
+ // called, that means we have got whole html page. In here we should
+ // finally get right encoding of page.
+ void UpdateEncoding(blink::WebFrame* frame,
+ const std::string& encoding_name);
+
// Dispatches the current state of selection on the webpage to the browser if
// it has changed.
// TODO(varunjain): delete this method once we figure out how to keep
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index f2dc36a2..f46da97 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -1320,34 +1320,6 @@
///////////////////////////////////////////////////////////////////////////////
-// Tell the embedding application that the title of the active page has changed
-void RenderViewImpl::UpdateTitle(WebFrame* frame,
- const base::string16& title,
- WebTextDirection title_direction) {
- // Ignore all but top level navigations.
- if (frame->parent())
- return;
-
- base::debug::TraceLog::GetInstance()->UpdateProcessLabel(
- routing_id_, base::UTF16ToUTF8(title));
-
- base::string16 shortened_title = title.substr(0, kMaxTitleChars);
- Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title,
- title_direction));
-}
-
-void RenderViewImpl::UpdateEncoding(WebFrame* frame,
- const std::string& encoding_name) {
- // Only update main frame's encoding_name.
- if (webview()->mainFrame() == frame &&
- last_encoding_name_ != encoding_name) {
- // Save the encoding name for later comparing.
- last_encoding_name_ = encoding_name;
-
- Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_));
- }
-}
-
// Sends the last committed session history state to the browser so it will be
// saved before we navigate to a new page. This must be called *before* the
// page ID has been updated so we know what it was.
@@ -2241,15 +2213,6 @@
MemoryBenchmarkingExtension::Install(frame);
}
-void RenderViewImpl::didReceiveTitle(WebLocalFrame* frame,
- const WebString& title,
- WebTextDirection direction) {
- UpdateTitle(frame, title, direction);
-
- // Also check whether we have new encoding name.
- UpdateEncoding(frame, frame->view()->pageEncoding().utf8());
-}
-
void RenderViewImpl::didChangeIcon(WebLocalFrame* frame,
WebIconURL::Type icon_type) {
if (frame->parent())
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index f172a9f6..86c8a12 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -658,9 +658,6 @@
void didCreateDataSource(blink::WebLocalFrame* frame,
blink::WebDataSource* datasource);
void didClearWindowObject(blink::WebLocalFrame* frame);
- void didReceiveTitle(blink::WebLocalFrame* frame,
- const blink::WebString& title,
- blink::WebTextDirection direction);
void didChangeIcon(blink::WebLocalFrame*, blink::WebIconURL::Type);
void didUpdateCurrentHistoryItem(blink::WebLocalFrame* frame);
void didChangeScrollOffset(blink::WebLocalFrame* frame);
@@ -674,27 +671,9 @@
static WindowOpenDisposition NavigationPolicyToDisposition(
blink::WebNavigationPolicy policy);
- void UpdateTitle(blink::WebFrame* frame, const base::string16& title,
- blink::WebTextDirection title_direction);
void UpdateSessionHistory(blink::WebFrame* frame);
void SendUpdateState(HistoryEntry* entry);
- // Update current main frame's encoding and send it to browser window.
- // Since we want to let users see the right encoding info from menu
- // before finishing loading, we call the UpdateEncoding in
- // a) function:DidCommitLoadForFrame. When this function is called,
- // that means we have got first data. In here we try to get encoding
- // of page if it has been specified in http header.
- // b) function:DidReceiveTitle. When this function is called,
- // that means we have got specified title. Because in most of webpages,
- // title tags will follow meta tags. In here we try to get encoding of
- // page if it has been specified in meta tag.
- // c) function:DidFinishDocumentLoadForFrame. When this function is
- // called, that means we have got whole html page. In here we should
- // finally get right encoding of page.
- void UpdateEncoding(blink::WebFrame* frame,
- const std::string& encoding_name);
-
// Sends a message and runs a nested message loop.
bool SendAndRunNestedMessageLoop(IPC::SyncMessage* message);
@@ -1018,11 +997,6 @@
// navigate to stale entries that have been cropped from our history.
std::vector<int32> history_page_ids_;
- // Page info -----------------------------------------------------------------
-
- // The last gotten main frame's encoding.
- std::string last_encoding_name_;
-
// UI state ------------------------------------------------------------------
// The state of our target_url transmissions. When we receive a request to