Index: components/web_view/web_view_impl.cc |
diff --git a/components/web_view/web_view_impl.cc b/components/web_view/web_view_impl.cc |
index e73058937ec679c22701d31446d6c1c148c9083c..ea1174f4017dc4b332cacd9db51f0fb4d267b4e0 100644 |
--- a/components/web_view/web_view_impl.cc |
+++ b/components/web_view/web_view_impl.cc |
@@ -14,6 +14,7 @@ |
#include "components/web_view/frame_devtools_agent.h" |
#include "components/web_view/frame_tree.h" |
#include "components/web_view/pending_web_view_load.h" |
+#include "components/web_view/url_request_cloneable.h" |
#include "mojo/application/public/cpp/application_impl.h" |
#include "mojo/converters/geometry/geometry_type_converters.h" |
#include "url/gurl.h" |
@@ -75,12 +76,27 @@ void WebViewImpl::OnLoad() { |
content_->Embed(view_tree_client.Pass()); |
} |
+void WebViewImpl::UpdateBackForwardEnableState() { |
+ client_->BackForwardChanged(!back_list_.empty(), !forward_list_.empty()); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// WebViewImpl, WebView implementation: |
void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) { |
+ if (current_page_request_) { |
+ // TODO(erg): This doesn't deal with redirect chains. If you navigate to a |
+ // site, and it 300s, we put both the url which caused the 300 and the |
+ // target url here, when we should not add the redirect url to the back |
+ // list. |
+ back_list_.push_back(current_page_request_.Pass()); |
+ } |
+ UpdateBackForwardEnableState(); |
+ |
+ current_page_request_.reset(new URLRequestCloneable(request.Pass())); |
+ |
pending_load_.reset(new PendingWebViewLoad(this)); |
- pending_load_->Init(request.Pass()); |
+ pending_load_->Init(current_page_request_->Clone()); |
} |
void WebViewImpl::GetViewTreeClient( |
@@ -88,6 +104,33 @@ void WebViewImpl::GetViewTreeClient( |
mojo::ViewTreeConnection::Create(this, view_tree_client.Pass()); |
} |
+void WebViewImpl::GoBack() { |
+ if (back_list_.empty()) |
+ return; |
+ |
+ // Take the current page request and put it in the forward list. |
+ forward_list_.push_back(current_page_request_.Pass()); |
+ |
+ mojo::URLRequestPtr new_request = back_list_.back()->Clone(); |
+ back_list_.resize(back_list_.size() - 1); |
+ |
+ UpdateBackForwardEnableState(); |
+ client_->TopLevelNavigate(new_request.Pass()); |
sky
2015/09/08 16:00:32
TopLevelNavigate is intended for requests from the
|
+} |
+ |
+void WebViewImpl::GoForward() { |
+ if (forward_list_.empty()) |
+ return; |
+ |
+ back_list_.push_back(current_page_request_.Pass()); |
+ |
+ mojo::URLRequestPtr new_request = forward_list_.back()->Clone(); |
+ forward_list_.resize(forward_list_.size() - 1); |
+ |
+ UpdateBackForwardEnableState(); |
+ client_->TopLevelNavigate(new_request.Pass()); |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
// WebViewImpl, mojo::ViewTreeDelegate implementation: |