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

Unified Diff: blimp/engine/browser/blimp_engine_session.cc

Issue 1422363008: Add a basic UI to the Android Blimp client. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made sure to clear old control data Created 5 years, 1 month 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 | « blimp/engine/browser/blimp_engine_session.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/engine/browser/blimp_engine_session.cc
diff --git a/blimp/engine/browser/blimp_engine_session.cc b/blimp/engine/browser/blimp_engine_session.cc
index 6ffd79dabdbee355d0383aee2861d41584e3e79d..47bf3301c7cffe720415ac02bc09865e350ec95d 100644
--- a/blimp/engine/browser/blimp_engine_session.cc
+++ b/blimp/engine/browser/blimp_engine_session.cc
@@ -96,6 +96,11 @@ void BlimpEngineSession::CreateWebContents(const int target_tab_id) {
PlatformSetContents(new_contents.Pass());
}
+void BlimpEngineSession::CloseWebContents(const int target_tab_id) {
+ DCHECK(web_contents_);
+ web_contents_->Close();
+}
+
void BlimpEngineSession::LoadUrl(const int target_tab_id, const GURL& url) {
if (url.is_empty() || !web_contents_)
return;
@@ -107,19 +112,59 @@ void BlimpEngineSession::LoadUrl(const int target_tab_id, const GURL& url) {
web_contents_->Focus();
}
+void BlimpEngineSession::GoBack(const int target_tab_id) {
+ if (!web_contents_)
+ return;
+
+ web_contents_->GetController().GoBack();
+}
+
+void BlimpEngineSession::GoForward(const int target_tab_id) {
+ if (!web_contents_)
+ return;
+
+ web_contents_->GetController().GoForward();
+}
+
+void BlimpEngineSession::Reload(const int target_tab_id) {
+ if (!web_contents_)
+ return;
+
+ web_contents_->GetController().Reload(true);
+}
+
net::Error BlimpEngineSession::OnBlimpMessage(const BlimpMessage& message) {
- DCHECK(message.type() == BlimpMessage::CONTROL);
-
- switch (message.control().type()) {
- case ControlMessage::CREATE_TAB:
- CreateWebContents(message.target_tab_id());
- break;
- case ControlMessage::LOAD_URL:
- LoadUrl(message.target_tab_id(),
- GURL(message.control().load_url().url()));
- break;
- default:
- NOTIMPLEMENTED();
+ DCHECK(message.type() == BlimpMessage::CONTROL ||
+ message.type() == BlimpMessage::NAVIGATION);
+
+ if (message.type() == BlimpMessage::CONTROL) {
+ switch (message.control().type()) {
+ case ControlMessage::CREATE_TAB:
+ CreateWebContents(message.target_tab_id());
+ break;
+ case ControlMessage::CLOSE_TAB:
+ CloseWebContents(message.target_tab_id());
+ default:
+ NOTIMPLEMENTED();
+ }
+ } else if (message.type() == BlimpMessage::NAVIGATION && web_contents_) {
+ switch (message.navigation().type()) {
+ case NavigationMessage::LOAD_URL:
+ LoadUrl(message.target_tab_id(),
+ GURL(message.navigation().load_url().url()));
+ break;
+ case NavigationMessage::GO_BACK:
+ GoBack(message.target_tab_id());
+ break;
+ case NavigationMessage::GO_FORWARD:
+ GoForward(message.target_tab_id());
+ break;
+ case NavigationMessage::RELOAD:
+ Reload(message.target_tab_id());
+ break;
+ default:
+ NOTIMPLEMENTED();
+ }
}
return net::OK;
« no previous file with comments | « blimp/engine/browser/blimp_engine_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698