| 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 #include "url/gurl.h" | 8 #include "url/gurl.h" |
| 9 | 9 |
| 10 namespace vr_shell { | 10 namespace vr_shell { |
| 11 | 11 |
| 12 UiInterface::UiInterface() { | 12 UiInterface::UiInterface(Mode initial_mode) { |
| 13 SetMode(Mode::STANDARD); | 13 SetMode(initial_mode); |
| 14 } | 14 } |
| 15 | 15 |
| 16 UiInterface::~UiInterface() {} | 16 UiInterface::~UiInterface() {} |
| 17 | 17 |
| 18 void UiInterface::SetMode(Mode mode) { | 18 void UiInterface::SetMode(Mode mode) { |
| 19 mode_ = mode; | 19 mode_ = mode; |
| 20 updates_.SetInteger("mode", static_cast<int>(mode)); | 20 FlushModeState(); |
| 21 } |
| 22 |
| 23 void UiInterface::SetMenuMode(bool enabled) { |
| 24 menu_mode_ = enabled; |
| 25 FlushModeState(); |
| 26 } |
| 27 |
| 28 void UiInterface::SetCinemaMode(bool enabled) { |
| 29 cinema_mode_ = enabled; |
| 30 FlushModeState(); |
| 31 } |
| 32 |
| 33 void UiInterface::FlushModeState() { |
| 34 updates_.SetInteger("mode", static_cast<int>(mode_)); |
| 35 updates_.SetBoolean("menuMode", menu_mode_); |
| 36 updates_.SetBoolean("cinemaMode", cinema_mode_); |
| 21 FlushUpdates(); | 37 FlushUpdates(); |
| 22 } | 38 } |
| 23 | 39 |
| 24 void UiInterface::SetSecureOrigin(bool secure) { | 40 void UiInterface::SetSecureOrigin(bool secure) { |
| 25 updates_.SetBoolean("secureOrigin", secure); | 41 updates_.SetBoolean("secureOrigin", secure); |
| 26 FlushUpdates(); | 42 FlushUpdates(); |
| 27 } | 43 } |
| 28 | 44 |
| 29 void UiInterface::SetLoading(bool loading) { | 45 void UiInterface::SetLoading(bool loading) { |
| 30 updates_.SetBoolean("loading", loading); | 46 updates_.SetBoolean("loading", loading); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 53 } | 69 } |
| 54 | 70 |
| 55 void UiInterface::FlushUpdates() { | 71 void UiInterface::FlushUpdates() { |
| 56 if (loaded_ && handler_) { | 72 if (loaded_ && handler_) { |
| 57 handler_->SendCommandToUi(updates_); | 73 handler_->SendCommandToUi(updates_); |
| 58 updates_.Clear(); | 74 updates_.Clear(); |
| 59 } | 75 } |
| 60 } | 76 } |
| 61 | 77 |
| 62 } // namespace vr_shell | 78 } // namespace vr_shell |
| OLD | NEW |