Chromium Code Reviews| 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 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" | 5 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 8 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" | 9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" |
| 10 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h" | 10 #include "chrome/browser/android/vr_shell/ui_elements/textured_element.h" |
| 11 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" | 11 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" |
| 12 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 12 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| 13 #include "chrome/browser/android/vr_shell/ui_scene.h" | 13 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| 14 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" | |
| 15 #include "chrome/browser/android/vr_shell/vr_gl_thread.h" | |
|
cjgrant
2017/05/02 18:07:05
Is the thread header needed?
ymalik
2017/05/02 20:28:39
Totally not. thanks!
| |
| 16 #include "chrome/browser/android/vr_shell/vr_shell.h" | |
| 14 | 17 |
| 15 namespace vr_shell { | 18 namespace vr_shell { |
| 16 | 19 |
| 17 namespace { | 20 namespace { |
| 18 | 21 |
| 19 static constexpr int kWarningTimeoutSeconds = 30; | 22 static constexpr int kWarningTimeoutSeconds = 30; |
| 20 static constexpr float kWarningDistance = 0.7; | 23 static constexpr float kWarningDistance = 0.7; |
| 21 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; | 24 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; |
| 22 | 25 |
| 23 static constexpr float kPermanentWarningHeight = 0.226; | 26 static constexpr float kPermanentWarningHeight = 0.226; |
| 24 static constexpr float kPermanentWarningWidth = 0.078; | 27 static constexpr float kPermanentWarningWidth = 0.078; |
| 25 static constexpr float kTransientWarningHeight = 0.512; | 28 static constexpr float kTransientWarningHeight = 0.512; |
| 26 static constexpr float kTransientWarningWidth = 0.160; | 29 static constexpr float kTransientWarningWidth = 0.160; |
| 27 | 30 |
| 28 static constexpr float kContentHeight = 2.4; | 31 static constexpr float kContentHeight = 2.4; |
| 29 static constexpr float kContentWidth = 1.6; | 32 static constexpr float kContentWidth = 1.6; |
| 30 static constexpr float kContentDistance = 2.5; | 33 static constexpr float kContentDistance = 2.5; |
| 31 static constexpr float kContentVerticalOffset = -0.26; | 34 static constexpr float kContentVerticalOffset = -0.26; |
| 32 | 35 |
| 33 } // namespace | 36 } // namespace |
| 34 | 37 |
| 35 UiSceneManager::UiSceneManager(UiScene* scene) | 38 UiSceneManager::UiSceneManager( |
| 36 : scene_(scene), weak_ptr_factory_(this) { | 39 const base::WeakPtr<VrBrowserInterface>& weak_browser_interface, |
| 40 UiScene* scene) | |
| 41 : weak_browser_interface_(weak_browser_interface), | |
|
cjgrant
2017/05/02 18:07:06
s/weak_browser_interface_/browser_/ or /shell_/? I
ymalik
2017/05/02 20:28:39
Done here and VrShellGl
| |
| 42 scene_(scene), | |
| 43 weak_ptr_factory_(this) { | |
| 37 std::unique_ptr<UiElement> element; | 44 std::unique_ptr<UiElement> element; |
| 38 | 45 |
| 39 // For now, use an ID range that does not conflict with the HTML UI. | 46 // For now, use an ID range that does not conflict with the HTML UI. |
| 40 int id = 1000; | 47 int id = 1000; |
| 41 | 48 |
| 42 // Permanent WebVR security warning. | 49 // Permanent WebVR security warning. |
| 43 // TODO(mthiesse): Programatically compute the proper texture size for these | 50 // TODO(mthiesse): Programatically compute the proper texture size for these |
| 44 // textured UI elements. | 51 // textured UI elements. |
| 45 element = base::MakeUnique<PermanentSecurityWarning>(512); | 52 element = base::MakeUnique<PermanentSecurityWarning>(512); |
| 46 element->id = id++; | 53 element->id = id++; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 web_vr_mode_ = web_vr; | 100 web_vr_mode_ = web_vr; |
| 94 main_content_->visible = !web_vr_mode_; | 101 main_content_->visible = !web_vr_mode_; |
| 95 ConfigureSecurityWarnings(); | 102 ConfigureSecurityWarnings(); |
| 96 } | 103 } |
| 97 | 104 |
| 98 void UiSceneManager::SetWebVRSecureOrigin(bool secure) { | 105 void UiSceneManager::SetWebVRSecureOrigin(bool secure) { |
| 99 secure_origin_ = secure; | 106 secure_origin_ = secure; |
| 100 ConfigureSecurityWarnings(); | 107 ConfigureSecurityWarnings(); |
| 101 } | 108 } |
| 102 | 109 |
| 110 void UiSceneManager::AppButtonPressed() { | |
| 111 // Pressing the app button currenly pauses content rendering. Note: its still | |
| 112 // unclear what we want to do here and this will most likely change. | |
| 113 content_rendering_enabled_ = !content_rendering_enabled_; | |
| 114 scene_->SetWebVrRenderingEnabled(!content_rendering_enabled_); | |
| 115 weak_browser_interface_->OnContentPaused(content_rendering_enabled_); | |
| 116 } | |
| 117 | |
| 103 void UiSceneManager::ConfigureSecurityWarnings() { | 118 void UiSceneManager::ConfigureSecurityWarnings() { |
| 104 bool enabled = web_vr_mode_ && !secure_origin_; | 119 bool enabled = web_vr_mode_ && !secure_origin_; |
| 105 permanent_security_warning_->visible = enabled; | 120 permanent_security_warning_->visible = enabled; |
| 106 transient_security_warning_->visible = enabled; | 121 transient_security_warning_->visible = enabled; |
| 107 if (enabled) { | 122 if (enabled) { |
| 108 security_warning_timer_.Start( | 123 security_warning_timer_.Start( |
| 109 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, | 124 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, |
| 110 &UiSceneManager::OnSecurityWarningTimer); | 125 &UiSceneManager::OnSecurityWarningTimer); |
| 111 } else { | 126 } else { |
| 112 security_warning_timer_.Stop(); | 127 security_warning_timer_.Stop(); |
| 113 } | 128 } |
| 114 } | 129 } |
| 115 | 130 |
| 116 void UiSceneManager::OnSecurityWarningTimer() { | 131 void UiSceneManager::OnSecurityWarningTimer() { |
| 117 transient_security_warning_->visible = false; | 132 transient_security_warning_->visible = false; |
| 118 } | 133 } |
| 119 | 134 |
| 120 } // namespace vr_shell | 135 } // namespace vr_shell |
| OLD | NEW |