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 |