Chromium Code Reviews| 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..b0e6bd549d8545fd79847fd85ac0d1783fb1ca71 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" |
| @@ -28,6 +29,8 @@ bool EnableRemoteDebugging() { |
| } // namespace |
| +using web_view::mojom::ButtonState; |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // WebViewImpl, public: |
| @@ -75,12 +78,31 @@ void WebViewImpl::OnLoad() { |
| content_->Embed(view_tree_client.Pass()); |
| } |
| +void WebViewImpl::UpdateBackForwardEnableState() { |
| + client_->BackForwardChanged( |
| + back_list_.empty() ? ButtonState::BUTTON_STATE_DISABLED : |
| + ButtonState::BUTTON_STATE_ENABLED, |
| + forward_list_.empty() ? ButtonState::BUTTON_STATE_DISABLED : |
| + ButtonState::BUTTON_STATE_ENABLED); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // 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()); |
|
sky
2015/09/09 20:43:28
Don't you need to prune the forward_list_ at some
|
| } |
| void WebViewImpl::GetViewTreeClient( |
| @@ -88,6 +110,31 @@ 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); |
| + |
| + LoadRequest(new_request.Pass()); |
| +} |
| + |
| +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); |
| + |
| + LoadRequest(new_request.Pass()); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // WebViewImpl, mojo::ViewTreeDelegate implementation: |