| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_ELEMENTS_SIMPLE_TEXTURED_ELEMENT_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_SIMPLE_TEXTURED_ELEMENT_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_SIMPLE_TEXTURED_ELEMENT_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_SIMPLE_TEXTURED_ELEMENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/android/vr_shell/textures/exclusive_screen_toast_textur
e.h" | 12 #include "chrome/browser/android/vr_shell/textures/exclusive_screen_toast_textur
e.h" |
| 13 #include "chrome/browser/android/vr_shell/textures/exit_warning_texture.h" | 13 #include "chrome/browser/android/vr_shell/textures/exit_warning_texture.h" |
| 14 #include "chrome/browser/android/vr_shell/textures/insecure_content_permanent_te
xture.h" | 14 #include "chrome/browser/android/vr_shell/textures/insecure_content_permanent_te
xture.h" |
| 15 #include "chrome/browser/android/vr_shell/textures/insecure_content_transient_te
xture.h" | 15 #include "chrome/browser/android/vr_shell/textures/insecure_content_transient_te
xture.h" |
| 16 #include "chrome/browser/android/vr_shell/textures/splash_screen_icon_texture.h" | 16 #include "chrome/browser/android/vr_shell/textures/splash_screen_icon_texture.h" |
| 17 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 17 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 18 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h" | 18 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h" |
| 19 #include "chrome/browser/android/vr_shell/ui_elements/transience_manager.h" |
| 19 | 20 |
| 20 namespace vr_shell { | 21 namespace vr_shell { |
| 21 | 22 |
| 22 template <class T> | 23 template <class T> |
| 23 class SimpleTexturedElement : public TexturedElement { | 24 class SimpleTexturedElement : public TexturedElement { |
| 24 public: | 25 public: |
| 25 // |preferred_width| is the element's desired width in meters. Constraints | 26 // |preferred_width| is the element's desired width in meters. Constraints |
| 26 // implied by the texture being rendered may or may not allow it to be | 27 // implied by the texture being rendered may or may not allow it to be |
| 27 // rendered exactly at the preferred width. | 28 // rendered exactly at the preferred width. |
| 28 explicit SimpleTexturedElement(int maximum_width) | 29 explicit SimpleTexturedElement(int maximum_width) |
| 29 : TexturedElement(maximum_width), texture_(base::MakeUnique<T>()) {} | 30 : TexturedElement(maximum_width), texture_(base::MakeUnique<T>()) {} |
| 30 ~SimpleTexturedElement() override {} | 31 ~SimpleTexturedElement() override {} |
| 31 T* GetDerivedTexture() { return texture_.get(); } | 32 T* GetDerivedTexture() { return texture_.get(); } |
| 32 | 33 |
| 33 protected: | 34 protected: |
| 34 UiTexture* GetTexture() const override { return texture_.get(); } | 35 UiTexture* GetTexture() const override { return texture_.get(); } |
| 35 | 36 |
| 36 private: | 37 private: |
| 37 std::unique_ptr<T> texture_; | 38 std::unique_ptr<T> texture_; |
| 38 | 39 |
| 39 DISALLOW_COPY_AND_ASSIGN(SimpleTexturedElement); | 40 DISALLOW_COPY_AND_ASSIGN(SimpleTexturedElement); |
| 40 }; | 41 }; |
| 41 | 42 |
| 43 template <class T> |
| 44 class TransientSimpleTexturedElement : public SimpleTexturedElement<T> { |
| 45 public: |
| 46 TransientSimpleTexturedElement(int maximum_width, |
| 47 const base::TimeDelta& timeout) |
| 48 : SimpleTexturedElement<T>(maximum_width), transience_(this, timeout) {} |
| 49 |
| 50 ~TransientSimpleTexturedElement() override {} |
| 51 |
| 52 void SetEnabled(bool enabled) override { transience_.SetEnabled(enabled); } |
| 53 |
| 54 TransienceManager* transience() { return &transience_; } |
| 55 |
| 56 private: |
| 57 TransienceManager transience_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(TransientSimpleTexturedElement); |
| 60 }; |
| 61 |
| 42 typedef SimpleTexturedElement<ExitWarningTexture> ExitWarning; | 62 typedef SimpleTexturedElement<ExitWarningTexture> ExitWarning; |
| 43 typedef SimpleTexturedElement<InsecureContentPermanentTexture> | 63 typedef SimpleTexturedElement<InsecureContentPermanentTexture> |
| 44 PermanentSecurityWarning; | 64 PermanentSecurityWarning; |
| 45 typedef SimpleTexturedElement<InsecureContentTransientTexture> | 65 typedef TransientSimpleTexturedElement<InsecureContentTransientTexture> |
| 46 TransientSecurityWarning; | 66 TransientSecurityWarning; |
| 47 typedef SimpleTexturedElement<SplashScreenIconTexture> SplashScreenIcon; | 67 typedef SimpleTexturedElement<SplashScreenIconTexture> SplashScreenIcon; |
| 48 | 68 |
| 49 } // namespace vr_shell | 69 } // namespace vr_shell |
| 50 | 70 |
| 51 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_SIMPLE_TEXTURED_ELEMENT_H
_ | 71 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_SIMPLE_TEXTURED_ELEMENT_H
_ |
| OLD | NEW |