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