| 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_INTERFACE_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_INTERFACE_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_INTERFACE_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_INTERFACE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 | 10 |
| 11 class GURL; | 11 class GURL; |
| 12 | 12 |
| 13 namespace vr_shell { | 13 namespace vr_shell { |
| 14 | 14 |
| 15 class UiCommandHandler { | 15 class UiCommandHandler { |
| 16 public: | 16 public: |
| 17 virtual void SendCommandToUi(const base::Value& value) = 0; | 17 virtual void SendCommandToUi(const base::Value& value) = 0; |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 // This class manages the communication of browser state from VR shell to the | 20 // This class manages the communication of browser state from VR shell to the |
| 21 // HTML UI. State information is asynchronous and unidirectional. | 21 // HTML UI. State information is asynchronous and unidirectional. |
| 22 class UiInterface { | 22 class UiInterface { |
| 23 public: | 23 public: |
| 24 enum Mode { | 24 enum Mode { |
| 25 STANDARD, | 25 STANDARD, |
| 26 WEB_VR, | 26 WEB_VR, |
| 27 MENU, |
| 27 }; | 28 }; |
| 28 | 29 |
| 29 UiInterface(); | 30 UiInterface(); |
| 30 virtual ~UiInterface(); | 31 virtual ~UiInterface(); |
| 31 | 32 |
| 32 void SetMode(Mode mode); | 33 void SetMode(Mode mode); |
| 34 Mode GetMode() { return mode_; } |
| 33 void SetSecureOrigin(bool secure); | 35 void SetSecureOrigin(bool secure); |
| 34 void SetLoading(bool loading); | 36 void SetLoading(bool loading); |
| 35 void SetURL(const GURL& url); | 37 void SetURL(const GURL& url); |
| 36 | 38 |
| 37 // Called by WebUI when starting VR. | 39 // Called by WebUI when starting VR. |
| 38 void OnDomContentsLoaded(); | 40 void OnDomContentsLoaded(); |
| 39 void SetUiCommandHandler(UiCommandHandler* handler); | 41 void SetUiCommandHandler(UiCommandHandler* handler); |
| 40 | 42 |
| 41 private: | 43 private: |
| 42 void FlushUpdates(); | 44 void FlushUpdates(); |
| 43 | 45 |
| 46 Mode mode_; |
| 44 UiCommandHandler* handler_; | 47 UiCommandHandler* handler_; |
| 45 bool loaded_ = false; | 48 bool loaded_ = false; |
| 46 base::DictionaryValue updates_; | 49 base::DictionaryValue updates_; |
| 47 | 50 |
| 48 DISALLOW_COPY_AND_ASSIGN(UiInterface); | 51 DISALLOW_COPY_AND_ASSIGN(UiInterface); |
| 49 }; | 52 }; |
| 50 | 53 |
| 51 } // namespace vr_shell | 54 } // namespace vr_shell |
| 52 | 55 |
| 53 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_INTERFACE_H_ | 56 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_INTERFACE_H_ |
| OLD | NEW |