Commit 3a225776 authored by Shawn Gallea's avatar Shawn Gallea Committed by Commit Bot

Add WebviewClient back navigation support

Allows user to test go back functionality.

Bug: 1011977
Test: Run client, use back command.
Change-Id: Ib07e48dd9e07211a9b2b8cf2199d9bc65e4df98d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142571
Commit-Queue: Shawn Gallea <sagallea@google.com>
Reviewed-by: default avatarDaniel Nicoara <dnicoara@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757908}
parent fdc2a1e2
...@@ -26,6 +26,7 @@ namespace { ...@@ -26,6 +26,7 @@ namespace {
constexpr int kGrpcMaxReconnectBackoffMs = 1000; constexpr int kGrpcMaxReconnectBackoffMs = 1000;
constexpr char kBackCommand[] = "back";
constexpr char kCreateCommand[] = "create"; constexpr char kCreateCommand[] = "create";
constexpr char kDestroyCommand[] = "destroy"; constexpr char kDestroyCommand[] = "destroy";
constexpr char kListCommand[] = "list"; constexpr char kListCommand[] = "list";
...@@ -306,6 +307,8 @@ void WebviewClient::InputCallback() { ...@@ -306,6 +307,8 @@ void WebviewClient::InputCallback() {
SendResizeRequest(tokens); SendResizeRequest(tokens);
else if (tokens[1] == kPositionCommand) else if (tokens[1] == kPositionCommand)
SetPosition(tokens); SetPosition(tokens);
else if (tokens[1] == kBackCommand)
SendBackRequest(tokens);
std::cout << "Enter command: "; std::cout << "Enter command: ";
std::cout.flush(); std::cout.flush();
...@@ -357,6 +360,22 @@ void WebviewClient::SchedulePaint() { ...@@ -357,6 +360,22 @@ void WebviewClient::SchedulePaint() {
FROM_HERE, base::BindOnce(&WebviewClient::Paint, base::Unretained(this))); FROM_HERE, base::BindOnce(&WebviewClient::Paint, base::Unretained(this)));
} }
void WebviewClient::SendBackRequest(const std::vector<std::string>& tokens) {
int id;
if (tokens.size() != 2 || !base::StringToInt(tokens[0], &id) ||
webviews_.find(id) == webviews_.end()) {
LOG(ERROR) << "Usage: [ID] back";
return;
}
const auto& webview = webviews_[id];
WebviewRequest back_request;
back_request.mutable_go_back();
if (!webview->client->Write(back_request)) {
LOG(ERROR) << ("Back request send failed");
}
}
void WebviewClient::SendNavigationRequest( void WebviewClient::SendNavigationRequest(
const std::vector<std::string>& tokens) { const std::vector<std::string>& tokens) {
int id; int id;
......
...@@ -81,6 +81,7 @@ class WebviewClient : public exo::wayland::clients::ClientBase { ...@@ -81,6 +81,7 @@ class WebviewClient : public exo::wayland::clients::ClientBase {
void InputCallback(); void InputCallback();
void ListActiveWebviews(); void ListActiveWebviews();
void Paint(); void Paint();
void SendBackRequest(const std::vector<std::string>& tokens);
void SendNavigationRequest(const std::vector<std::string>& tokens); void SendNavigationRequest(const std::vector<std::string>& tokens);
void SendResizeRequest(const std::vector<std::string>& tokens); void SendResizeRequest(const std::vector<std::string>& tokens);
void SendTouchInput(const Webview* webview, void SendTouchInput(const Webview* webview,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment