| 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/android/vr_shell/vr_omnibox.h" |
| 7 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" | 8 #include "chrome/browser/ui/webui/vr_shell/vr_shell_ui_message_handler.h" |
| 8 #include "url/gurl.h" | 9 #include "url/gurl.h" |
| 9 | 10 |
| 10 namespace vr_shell { | 11 namespace vr_shell { |
| 11 | 12 |
| 12 UiInterface::UiInterface(Mode initial_mode, bool fullscreen) { | 13 UiInterface::UiInterface(Mode initial_mode, bool fullscreen) { |
| 13 SetMode(initial_mode); | 14 SetMode(initial_mode); |
| 14 SetFullscreen(fullscreen); | 15 SetFullscreen(fullscreen); |
| 16 |
| 17 omnibox_.reset(new VrOmnibox(this)); |
| 15 } | 18 } |
| 16 | 19 |
| 17 UiInterface::~UiInterface() {} | 20 UiInterface::~UiInterface() {} |
| 18 | 21 |
| 19 void UiInterface::SetMode(Mode mode) { | 22 void UiInterface::SetMode(Mode mode) { |
| 20 mode_ = mode; | 23 mode_ = mode; |
| 21 FlushModeState(); | 24 FlushModeState(); |
| 22 } | 25 } |
| 23 | 26 |
| 24 void UiInterface::SetMenuMode(bool enabled) { | 27 void UiInterface::SetMenuMode(bool enabled) { |
| 25 menu_mode_ = enabled; | 28 menu_mode_ = enabled; |
| 26 FlushModeState(); | 29 FlushModeState(); |
| 27 } | 30 } |
| 28 | 31 |
| 29 void UiInterface::SetFullscreen(bool enabled) { | 32 void UiInterface::SetFullscreen(bool enabled) { |
| 30 fullscreen_ = enabled; | 33 fullscreen_ = enabled; |
| 31 FlushModeState(); | 34 FlushModeState(); |
| 32 } | 35 } |
| 33 | 36 |
| 37 void UiInterface::HandleOmniboxInput(const base::DictionaryValue& input) { |
| 38 omnibox_->HandleInput(input); |
| 39 } |
| 40 |
| 41 void UiInterface::SetOmniboxSuggestions( |
| 42 std::unique_ptr<base::Value> suggestions) { |
| 43 updates_.Set("suggestions", std::move(suggestions)); |
| 44 FlushUpdates(); |
| 45 } |
| 46 |
| 34 void UiInterface::FlushModeState() { | 47 void UiInterface::FlushModeState() { |
| 35 updates_.SetInteger("mode", static_cast<int>(mode_)); | 48 updates_.SetInteger("mode", static_cast<int>(mode_)); |
| 36 updates_.SetBoolean("menuMode", menu_mode_); | 49 updates_.SetBoolean("menuMode", menu_mode_); |
| 37 updates_.SetBoolean("fullscreen", fullscreen_); | 50 updates_.SetBoolean("fullscreen", fullscreen_); |
| 38 FlushUpdates(); | 51 FlushUpdates(); |
| 39 } | 52 } |
| 40 | 53 |
| 41 void UiInterface::SetSecurityLevel(int level) { | 54 void UiInterface::SetSecurityLevel(int level) { |
| 42 updates_.SetInteger("securityLevel", level); | 55 updates_.SetInteger("securityLevel", level); |
| 43 FlushUpdates(); | 56 FlushUpdates(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 } | 93 } |
| 81 | 94 |
| 82 void UiInterface::FlushUpdates() { | 95 void UiInterface::FlushUpdates() { |
| 83 if (loaded_ && handler_) { | 96 if (loaded_ && handler_) { |
| 84 handler_->SendCommandToUi(updates_); | 97 handler_->SendCommandToUi(updates_); |
| 85 updates_.Clear(); | 98 updates_.Clear(); |
| 86 } | 99 } |
| 87 } | 100 } |
| 88 | 101 |
| 89 } // namespace vr_shell | 102 } // namespace vr_shell |
| OLD | NEW |