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

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: 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/android/vr_shell/ui_interface.h ('k') | chrome/browser/android/vr_shell/vr_shell.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1ce4c431c94b2eb0b2e3bb7cfea5dc4ae9c0df3d
--- /dev/null
+++ b/chrome/browser/android/vr_shell/ui_interface.cc
@@ -0,0 +1,43 @@
+// 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 "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(VrShellUIMessageHandler* handler) {
+ handler_ = handler;
+}
+
+void UiInterface::SetMode(Mode mode) {
+ updates_.SetInteger("mode", static_cast<int>(mode));
+ FlushUpdates();
+}
+
+void UiInterface::SetSecureOrigin(bool secure) {
+ updates_.SetBoolean("secureOrigin", static_cast<int>(secure));
+ FlushUpdates();
+}
+
+void UiInterface::OnDomContentsLoaded() {
+ loaded_ = true;
+ FlushUpdates();
+}
+
+void UiInterface::FlushUpdates() {
+ if (loaded_ && handler_) {
+ handler_->SendCommandToUi(updates_);
+ updates_.Clear();
+ }
+}
+
+} // namespace vr_shell
« no previous file with comments | « chrome/browser/android/vr_shell/ui_interface.h ('k') | chrome/browser/android/vr_shell/vr_shell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698