OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 6 |
| 7 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" |
| 8 |
| 9 namespace vr_shell { |
| 10 |
| 11 UiInterface::UiInterface() { |
| 12 SetMode(Mode::STANDARD); |
| 13 } |
| 14 |
| 15 UiInterface::~UiInterface() {} |
| 16 |
| 17 void UiInterface::SetUiMessageHandler(VrShellUIMessageHandler* handler) { |
| 18 handler_ = handler; |
| 19 } |
| 20 |
| 21 void UiInterface::SetMode(Mode mode) { |
| 22 updates_.SetInteger("mode", static_cast<int>(mode)); |
| 23 FlushUpdates(); |
| 24 } |
| 25 |
| 26 void UiInterface::SetSecureOrigin(bool secure) { |
| 27 updates_.SetBoolean("secureOrigin", static_cast<int>(secure)); |
| 28 FlushUpdates(); |
| 29 } |
| 30 |
| 31 void UiInterface::OnDomContentsLoaded() { |
| 32 loaded_ = true; |
| 33 FlushUpdates(); |
| 34 } |
| 35 |
| 36 void UiInterface::FlushUpdates() { |
| 37 if (loaded_ && handler_) { |
| 38 handler_->SendCommandToUi(updates_); |
| 39 updates_.Clear(); |
| 40 } |
| 41 } |
| 42 |
| 43 } // namespace vr_shell |
OLD | NEW |