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

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: Fix comment 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 e73058937ec679c22701d31446d6c1c148c9083c..d355a9e1ab74715f293e135f2524389907595ccb 100644
--- a/components/web_view/web_view_impl.cc
+++ b/components/web_view/web_view_impl.cc
@@ -13,6 +13,7 @@
#include "components/web_view/frame_connection.h"
#include "components/web_view/frame_devtools_agent.h"
#include "components/web_view/frame_tree.h"
+#include "components/web_view/navigation_entry.h"
#include "components/web_view/pending_web_view_load.h"
#include "mojo/application/public/cpp/application_impl.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
@@ -75,12 +76,27 @@ void WebViewImpl::OnLoad() {
content_->Embed(view_tree_client.Pass());
}
+void WebViewImpl::UpdateBackForwardEnableState() {
+ client_->BackForwardChanged(back_list_.size() > 0, forward_list_.size() > 0);
msw 2015/09/04 22:05:00 nit: use !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 NavigationEntry(request.Pass()));
+
pending_load_.reset(new PendingWebViewLoad(this));
- pending_load_->Init(request.Pass());
+ pending_load_->Init(current_page_request_->AsURLRequest());
}
void WebViewImpl::GetViewTreeClient(
@@ -88,6 +104,33 @@ void WebViewImpl::GetViewTreeClient(
mojo::ViewTreeConnection::Create(this, view_tree_client.Pass());
}
+void WebViewImpl::GoBack() {
+ if (back_list_.size() == 0)
msw 2015/09/04 22:05:00 nit: 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()->AsURLRequest();
+ back_list_.resize(back_list_.size() - 1);
+
+ UpdateBackForwardEnableState();
+ client_->TopLevelNavigate(new_request.Pass());
+}
+
+void WebViewImpl::GoForward() {
+ if (forward_list_.size() == 0)
msw 2015/09/04 22:05:00 nit: empty
+ return;
+
+ back_list_.push_back(current_page_request_.Pass());
+
+ mojo::URLRequestPtr new_request = forward_list_.back()->AsURLRequest();
+ forward_list_.resize(forward_list_.size() - 1);
+
+ UpdateBackForwardEnableState();
+ client_->TopLevelNavigate(new_request.Pass());
+}
+
////////////////////////////////////////////////////////////////////////////////
// WebViewImpl, mojo::ViewTreeDelegate implementation:

Powered by Google App Engine
This is Rietveld 408576698