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

Unified Diff: chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.cc

Issue 2434013002: Implement a means of letting native VR Shell control the HTML UI. (Closed)
Patch Set: Remove use of cr.define() Created 4 years, 2 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 | « chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.cc
diff --git a/chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.cc b/chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.cc
index c970d84b09a05184467e30984398c8985f42c988..8975009dada602ea11cf4ef2ff7d9435504f068c 100644
--- a/chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.cc
+++ b/chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.cc
@@ -10,13 +10,18 @@
#include "base/bind_helpers.h"
#include "base/callback.h"
#include "base/values.h"
+#include "chrome/browser/android/vr_shell/ui_interface.h"
#include "chrome/browser/android/vr_shell/ui_scene.h"
#include "chrome/browser/android/vr_shell/vr_shell.h"
#include "content/public/browser/web_ui.h"
VrShellUIMessageHandler::VrShellUIMessageHandler() = default;
-VrShellUIMessageHandler::~VrShellUIMessageHandler() = default;
+VrShellUIMessageHandler::~VrShellUIMessageHandler() {
+ if (vr_shell_) {
+ vr_shell_->GetUiInterface()->SetUiMessageHandler(nullptr);
+ }
+}
void VrShellUIMessageHandler::RegisterMessages() {
vr_shell_ = vr_shell::VrShell::GetWeakPtr(web_ui()->GetWebContents());
@@ -33,9 +38,12 @@ void VrShellUIMessageHandler::RegisterMessages() {
}
void VrShellUIMessageHandler::HandleDomLoaded(const base::ListValue* args) {
- if (!vr_shell_)
- return;
+ AllowJavascript();
+}
+void VrShellUIMessageHandler::OnJavascriptAllowed() {
+ CHECK(vr_shell_);
+ vr_shell_->GetUiInterface()->SetUiMessageHandler(this);
vr_shell_->OnDomContentsLoaded();
}
@@ -58,3 +66,7 @@ void VrShellUIMessageHandler::HandleDoAction(const base::ListValue* args) {
vr_shell_->DoUiAction((vr_shell::UiAction) action);
}
}
+
+void VrShellUIMessageHandler::SendCommandToUi(const base::Value& value) {
+ CallJavascriptFunction("vrShellUi.command", value);
+}
« no previous file with comments | « chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698