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

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: nits and such. 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
« no previous file with comments | « components/web_view/web_view_impl.h ('k') | mandoline/ui/desktop_ui/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..eab771be1a6d783c5fcdf0f72bb9acb068a5c68b 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,34 @@ 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());
+ // Clear the forward list when performing a top level load request.
+ 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 +112,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:
« no previous file with comments | « components/web_view/web_view_impl.h ('k') | mandoline/ui/desktop_ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698