diff options
-rw-r--r-- | chrome/browser/render_view_host.cc | 8 | ||||
-rw-r--r-- | chrome/browser/render_view_host.h | 2 | ||||
-rw-r--r-- | chrome/browser/render_view_host_delegate.h | 2 | ||||
-rw-r--r-- | chrome/browser/web_contents.cc | 23 | ||||
-rw-r--r-- | chrome/browser/web_contents.h | 2 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 4 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 16 | ||||
-rw-r--r-- | webkit/glue/webframe.h | 24 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 14 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 8 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 8 |
11 files changed, 31 insertions, 80 deletions
diff --git a/chrome/browser/render_view_host.cc b/chrome/browser/render_view_host.cc index 38bbe9e..77512b6 100644 --- a/chrome/browser/render_view_host.cc +++ b/chrome/browser/render_view_host.cc @@ -832,14 +832,8 @@ void RenderViewHost::OnMsgNavigate(const IPC::Message& msg) { } void RenderViewHost::OnMsgUpdateState(int32 page_id, - const GURL& url, - const std::wstring& title, const std::string& state) { - GURL validated_url(url); - FilterURL(RendererSecurityPolicy::GetInstance(), - process()->host_id(), &validated_url); - - delegate_->UpdateState(this, page_id, validated_url, title, state); + delegate_->UpdateState(this, page_id, state); } void RenderViewHost::OnMsgUpdateTitle(int32 page_id, diff --git a/chrome/browser/render_view_host.h b/chrome/browser/render_view_host.h index b7d1ae2..5ccd88f 100644 --- a/chrome/browser/render_view_host.h +++ b/chrome/browser/render_view_host.h @@ -420,8 +420,6 @@ class RenderViewHost : public RenderWidgetHost { void OnMsgRendererGone(); void OnMsgNavigate(const IPC::Message& msg); void OnMsgUpdateState(int32 page_id, - const GURL& url, - const std::wstring& title, const std::string& state); void OnMsgUpdateTitle(int32 page_id, const std::wstring& title); void OnMsgUpdateEncoding(const std::wstring& encoding); diff --git a/chrome/browser/render_view_host_delegate.h b/chrome/browser/render_view_host_delegate.h index 63e2eaa..f0c4b0e 100644 --- a/chrome/browser/render_view_host_delegate.h +++ b/chrome/browser/render_view_host_delegate.h @@ -160,8 +160,6 @@ class RenderViewHostDelegate { // The state for the page changed and should be updated. virtual void UpdateState(RenderViewHost* render_view_host, int32 page_id, - const GURL& url, - const std::wstring& title, const std::string& state) { } // The page's title was changed and should be updated. diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index 4afc290..1191d5d 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -745,8 +745,6 @@ void WebContents::DidNavigate(RenderViewHost* rvh, void WebContents::UpdateState(RenderViewHost* rvh, int32 page_id, - const GURL& url, - const std::wstring& title, const std::string& state) { if (rvh != render_view_host() || render_manager_.showing_interstitial_page()) { @@ -774,27 +772,12 @@ void WebContents::UpdateState(RenderViewHost* rvh, if (entry_index < 0) return; NavigationEntry* entry = controller()->GetEntryAtIndex(entry_index); - unsigned changed_flags = 0; - - // Update the URL. - if (url != entry->url()) { - changed_flags |= INVALIDATE_URL; - if (entry == controller()->GetActiveEntry()) - fav_icon_helper_.FetchFavIcon(url); - entry->set_url(url); - } - - // Save the new title if it changed. - if (UpdateTitleForEntry(entry, title)) - changed_flags |= INVALIDATE_TITLE; - // Update the state (forms, etc.). - if (state != entry->content_state()) - entry->set_content_state(state); + if (state == entry->content_state()) + return; // Nothing to update. + entry->set_content_state(state); // Notify everybody of the changes (only when the current page changed). - if (changed_flags && entry == controller()->GetActiveEntry()) - NotifyNavigationStateChanged(changed_flags); controller()->NotifyEntryChanged(entry, entry_index); } diff --git a/chrome/browser/web_contents.h b/chrome/browser/web_contents.h index efe7a10..f7ed61e 100644 --- a/chrome/browser/web_contents.h +++ b/chrome/browser/web_contents.h @@ -231,8 +231,6 @@ class WebContents : public TabContents, const ViewHostMsg_FrameNavigate_Params& params); virtual void UpdateState(RenderViewHost* render_view_host, int32 page_id, - const GURL& url, - const std::wstring& title, const std::string& state); virtual void UpdateTitle(RenderViewHost* render_view_host, int32 page_id, diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 8cc598a..96d7d89 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -565,10 +565,8 @@ IPC_BEGIN_MESSAGES(ViewHost, 2) // Notifies the browser that we have session history information. // page_id: unique ID that allows us to distinguish between history entries. - IPC_MESSAGE_ROUTED4(ViewHostMsg_UpdateState, + IPC_MESSAGE_ROUTED2(ViewHostMsg_UpdateState, int32 /* page_id */, - GURL /* url */, - std::wstring /* title */, std::string /* state */) // Changes the title for the page in the UI when the page is navigated or the diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index e571ace..23fab18 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -830,7 +830,7 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { bool is_reload = params.reload; WebFrame* main_frame = webview()->GetMainFrame(); - if (is_reload && !main_frame->HasCurrentState()) { + if (is_reload && !main_frame->HasCurrentHistoryState()) { // We cannot reload if we do not have any history state. This happens, for // example, when recovering from a crash. Our workaround here is a bit of // a hack since it means that reload after a crashed tab does not cause an @@ -1162,13 +1162,10 @@ void RenderView::UpdateSessionHistory(WebFrame* frame) { if (page_id_ == -1) return; - GURL url; - std::wstring title; std::string state; - if (!webview()->GetMainFrame()->GetPreviousState(&url, &title, &state)) + if (!webview()->GetMainFrame()->GetPreviousHistoryState(&state)) return; - - Send(new ViewHostMsg_UpdateState(routing_id_, page_id_, url, title, state)); + Send(new ViewHostMsg_UpdateState(routing_id_, page_id_, state)); } /////////////////////////////////////////////////////////////////////////////// @@ -1926,13 +1923,10 @@ void RenderView::SyncNavigationState() { if (!webview()) return; - GURL url; - std::wstring title; std::string state; - if (!webview()->GetMainFrame()->GetCurrentState(&url, &title, &state)) + if (!webview()->GetMainFrame()->GetCurrentHistoryState(&state)) return; - - Send(new ViewHostMsg_UpdateState(routing_id_, page_id_, url, title, state)); + Send(new ViewHostMsg_UpdateState(routing_id_, page_id_, state)); } void RenderView::ShowContextMenu(WebView* webview, diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index 7c6c1fc..2edc1eb 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -99,21 +99,25 @@ class WebFrame : public base::RefCounted<WebFrame> { const GURL& script_url) = 0; // Returns a string representing the state of the previous page load for - // later use when loading as well as the uri and title of the page. The - // previous page is the page that was loaded before DidCommitLoadForFrame was - // received. Returns false if there is no state. - virtual bool GetPreviousState(GURL* url, std::wstring* title, - std::string* history_state) const = 0; + // later use when loading. The previous page is the page that was loaded + // before DidCommitLoadForFrame was received. + // + // Returns false if there is no valid state to return (for example, there is + // no previous item). Returns true if the previous item's state was retrieved, + // even if that state may be empty. + virtual bool GetPreviousHistoryState(std::string* history_state) const = 0; // Returns a string representing the state of the current page load for later - // use when loading as well as the url and title of the page. Returns false - // if there is no state. - virtual bool GetCurrentState(GURL* url, std::wstring* title, - std::string* history_state) const = 0; + // use when loading as well as the url and title of the page. + // + // Returns false if there is no valid state to return (for example, there is + // no previous item). Returns true if the current item's state was retrieved, + // even if that state may be empty. + virtual bool GetCurrentHistoryState(std::string* history_state) const = 0; // Returns true if there is a current history item. A newly created WebFrame // lacks a history item. Otherwise, this will always be true. - virtual bool HasCurrentState() const = 0; + virtual bool HasCurrentHistoryState() const = 0; // Returns the current URL of the frame, or the empty string if there is no // URL to retrieve (for example, the frame may never have had any content). diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 78ac3d4..d639558 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -477,8 +477,7 @@ GURL WebFrameImpl::GetOSDDURL() const { return GURL(); } -bool WebFrameImpl::GetPreviousState(GURL* url, std::wstring* title, - std::string* history_state) const { +bool WebFrameImpl::GetPreviousHistoryState(std::string* history_state) const { // We use the previous item here because documentState (filled-out forms) // only get saved to history when it becomes the previous item. The caller // is expected to query the history state after a navigation occurs, after @@ -494,14 +493,10 @@ bool WebFrameImpl::GetPreviousState(GURL* url, std::wstring* title, StatsScope<StatsCounterTimer> history_scope(history_timer); webkit_glue::HistoryItemToString(item, history_state); - *url = webkit_glue::KURLToGURL(item->url()); - *title = webkit_glue::StringToStdWString(item->title()); - return true; } -bool WebFrameImpl::GetCurrentState(GURL* url, std::wstring* title, - std::string* state) const { +bool WebFrameImpl::GetCurrentHistoryState(std::string* state) const { if (frame_->loader()) frame_->loader()->saveDocumentAndScrollState(); RefPtr<HistoryItem> item = frame_->page()->backForwardList()->currentItem(); @@ -509,13 +504,10 @@ bool WebFrameImpl::GetCurrentState(GURL* url, std::wstring* title, return false; webkit_glue::HistoryItemToString(item, state); - *url = webkit_glue::KURLToGURL(item->url()); - *title = webkit_glue::StringToStdWString(item->title()); - return true; } -bool WebFrameImpl::HasCurrentState() const { +bool WebFrameImpl::HasCurrentHistoryState() const { return frame_->page()->backForwardList()->currentItem() != NULL; } diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index 61c9851..635b396 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -97,11 +97,9 @@ class WebFrameImpl : public WebFrame { const GURL& fake_url); virtual void ExecuteJavaScript(const std::string& js_code, const GURL& script_url); - virtual bool GetPreviousState(GURL* url, std::wstring* title, - std::string* history_state) const; - virtual bool GetCurrentState(GURL* url, std::wstring* title, - std::string* history_state) const; - virtual bool HasCurrentState() const; + virtual bool GetPreviousHistoryState(std::string* history_state) const; + virtual bool GetCurrentHistoryState(std::string* history_state) const; + virtual bool HasCurrentHistoryState() const; virtual GURL GetURL() const; virtual GURL GetFavIconURL() const; virtual GURL GetOSDDURL() const; diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 3adcf08..17d3786 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -763,15 +763,9 @@ void TestWebViewDelegate::UpdateSessionHistory(WebFrame* frame) { if (!entry) return; - GURL url; - std::wstring title; std::string state; - if (!shell_->webView()->GetMainFrame()-> - GetPreviousState(&url, &title, &state)) + if (!shell_->webView()->GetMainFrame()->GetPreviousHistoryState(&state)) return; - - entry->SetURL(url); - entry->SetTitle(title); entry->SetContentState(state); } |