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

Unified Diff: chrome/browser/android/vr_shell/ui_interface.cc

Issue 2434013002: Implement a means of letting native VR Shell control the HTML UI. (Closed)
Patch Set: Impelement a means of letting native VR Shell control the HTML UI. 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
Index: chrome/browser/android/vr_shell/ui_interface.cc
diff --git a/chrome/browser/android/vr_shell/ui_interface.cc b/chrome/browser/android/vr_shell/ui_interface.cc
new file mode 100644
index 0000000000000000000000000000000000000000..640e3f7f36e0d7392321fb540905dc05cd18a522
--- /dev/null
+++ b/chrome/browser/android/vr_shell/ui_interface.cc
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/vr_shell/ui_interface.h"
+
+#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
bshe 2016/10/19 21:02:40 nit: remove the above two header as you included i
cjgrant 2016/10/20 15:25:39 Done.
+#include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h"
+
+namespace vr_shell {
+
+UiInterface::UiInterface() {
+ SetMode(Mode::STANDARD);
+}
+
+UiInterface::~UiInterface() {}
+
+void UiInterface::SetUiMessageHandler(
+ base::WeakPtr<VrShellUIMessageHandler> handler) {
+ handler_ = handler;
+}
+
+void UiInterface::SetMode(Mode mode) {
+ updates_.SetInteger("mode", static_cast<int>(mode));
mthiesse 2016/10/19 18:04:10 Maybe store the mode we're in locally, and only up
cjgrant 2016/10/20 15:25:38 Possibly, but at this point we shouldn't get a mod
+ FlushUpdates();
+}
+
+void UiInterface::SetSecureOrigin(bool secure) {
+ updates_.SetBoolean("secureOrigin", static_cast<int>(secure));
mthiesse 2016/10/19 18:04:10 Same comment here, you can store whether we're in
cjgrant 2016/10/20 15:25:39 See above.
+ FlushUpdates();
+}
+
+void UiInterface::OnDomContentsLoaded() {
+ loaded_ = true;
+ FlushUpdates();
+}
+
+void UiInterface::FlushUpdates() {
+ if (loaded_ && handler_) {
+ handler_->GetWebUi()->CallJavascriptFunctionUnsafe(
bshe 2016/10/19 21:02:40 Calling "CallJavascriptFunctionUnsafe" directly is
cjgrant 2016/10/20 14:32:40 As of now, VrShell gets calls to set the mode to W
cjgrant 2016/10/20 15:25:38 Done.
+ "chrome.vrShellUi.command", updates_);
+ }
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698