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

Unified Diff: components/web_view/web_view_impl.cc

Issue 1326443006: mandoline: Add back/forward support and UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add apptests. Created 5 years, 3 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: 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 9d04651edc6d0395fb20e659b340f071883c113c..2be791e609219733f114417a7d9e546d97c11c49 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:
@@ -74,12 +77,35 @@ void WebViewImpl::OnLoad() {
frame_tree_client, frame_connection.Pass(), client_properties));
}
+void WebViewImpl::LoadRequestImpl(mojo::URLRequestPtr request) {
+ client_->BackForwardChanged(
+ back_list_.empty() ? ButtonState::BUTTON_STATE_DISABLED
+ : ButtonState::BUTTON_STATE_ENABLED,
+ forward_list_.empty() ? ButtonState::BUTTON_STATE_DISABLED
+ : ButtonState::BUTTON_STATE_ENABLED);
+
+ current_page_request_.reset(new URLRequestCloneable(request.Pass()));
+ pending_load_.reset(new PendingWebViewLoad(this));
+ pending_load_->Init(current_page_request_->Clone());
+}
+
////////////////////////////////////////////////////////////////////////////////
// WebViewImpl, WebView implementation:
void WebViewImpl::LoadRequest(mojo::URLRequestPtr request) {
- pending_load_.reset(new PendingWebViewLoad(this));
- pending_load_->Init(request.Pass());
+ // When we are performing a top level load request, we must clear the forward
msw 2015/09/11 20:07:54 nit: consider "Clear the forward list when perform
+ // list.
+ forward_list_.clear();
+
+ 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());
+ }
+
+ LoadRequestImpl(request.Pass());
}
void WebViewImpl::GetViewTreeClient(
@@ -87,6 +113,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);
+
+ LoadRequestImpl(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);
+
+ LoadRequestImpl(new_request.Pass());
+}
+
////////////////////////////////////////////////////////////////////////////////
// WebViewImpl, mojo::ViewTreeDelegate implementation:

Powered by Google App Engine
This is Rietveld 408576698