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_shell.h" | |
| 14 | 16 |
| 15 namespace vr_shell { | 17 namespace vr_shell { |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 static constexpr int kWarningTimeoutSeconds = 30; | 21 static constexpr int kWarningTimeoutSeconds = 30; |
| 20 static constexpr float kWarningDistance = 0.7; | 22 static constexpr float kWarningDistance = 0.7; |
| 21 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; | 23 static constexpr float kWarningAngleRadians = 16.3 * M_PI / 180.0; |
| 22 static constexpr float kPermanentWarningHeight = 0.070f; | 24 static constexpr float kPermanentWarningHeight = 0.070f; |
| 23 static constexpr float kPermanentWarningWidth = 0.224f; | 25 static constexpr float kPermanentWarningWidth = 0.224f; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 35 static constexpr float kSceneHeight = 4.0; | 37 static constexpr float kSceneHeight = 4.0; |
| 36 static constexpr int kFloorGridlineCount = 40; | 38 static constexpr int kFloorGridlineCount = 40; |
| 37 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; | 39 static constexpr vr::Colorf kBackgroundHorizonColor = {0.57, 0.57, 0.57, 1.0}; |
| 38 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; | 40 static constexpr vr::Colorf kBackgroundCenterColor = {0.48, 0.48, 0.48, 1.0}; |
| 39 | 41 |
| 40 // Tiny distance to offset textures that should appear in the same plane. | 42 // Tiny distance to offset textures that should appear in the same plane. |
| 41 static constexpr float kTextureOffset = 0.01; | 43 static constexpr float kTextureOffset = 0.01; |
| 42 | 44 |
| 43 } // namespace | 45 } // namespace |
| 44 | 46 |
| 45 UiSceneManager::UiSceneManager(UiScene* scene) | 47 UiSceneManager::UiSceneManager(const base::WeakPtr<VrBrowserInterface>& browser, |
| 46 : scene_(scene), weak_ptr_factory_(this) { | 48 UiScene* scene) |
| 49 : browser_(browser), scene_(scene), weak_ptr_factory_(this) { | |
| 47 std::unique_ptr<UiElement> element; | 50 std::unique_ptr<UiElement> element; |
| 48 | 51 |
| 49 CreateBackground(); | 52 CreateBackground(); |
| 50 CreateContentQuad(); | 53 CreateContentQuad(); |
| 51 CreateSecurityWarnings(); | 54 CreateSecurityWarnings(); |
| 52 } | 55 } |
| 53 | 56 |
| 54 UiSceneManager::~UiSceneManager() {} | 57 UiSceneManager::~UiSceneManager() {} |
| 55 | 58 |
| 56 void UiSceneManager::CreateSecurityWarnings() { | 59 void UiSceneManager::CreateSecurityWarnings() { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 } | 180 } |
| 178 | 181 |
| 179 ConfigureSecurityWarnings(); | 182 ConfigureSecurityWarnings(); |
| 180 } | 183 } |
| 181 | 184 |
| 182 void UiSceneManager::SetWebVRSecureOrigin(bool secure) { | 185 void UiSceneManager::SetWebVRSecureOrigin(bool secure) { |
| 183 secure_origin_ = secure; | 186 secure_origin_ = secure; |
| 184 ConfigureSecurityWarnings(); | 187 ConfigureSecurityWarnings(); |
| 185 } | 188 } |
| 186 | 189 |
| 190 void UiSceneManager::OnAppButtonClicked() { | |
| 191 // Pressing the app button currenly pauses content rendering. Note: its still | |
| 192 // unclear what we want to do here and this will most likely change. | |
| 193 content_rendering_enabled_ = !content_rendering_enabled_; | |
| 194 scene_->SetWebVrRenderingEnabled(!content_rendering_enabled_); | |
| 195 browser_->OnContentPaused(content_rendering_enabled_); | |
|
mthiesse
2017/05/03 16:12:03
Need to check that this weak ptr isn't null before
ymalik
2017/05/03 20:26:38
Made it a raw ptr.
| |
| 196 } | |
| 197 | |
| 187 void UiSceneManager::ConfigureSecurityWarnings() { | 198 void UiSceneManager::ConfigureSecurityWarnings() { |
| 188 bool enabled = web_vr_mode_ && !secure_origin_; | 199 bool enabled = web_vr_mode_ && !secure_origin_; |
| 189 permanent_security_warning_->visible = enabled; | 200 permanent_security_warning_->visible = enabled; |
| 190 transient_security_warning_->visible = enabled; | 201 transient_security_warning_->visible = enabled; |
| 191 if (enabled) { | 202 if (enabled) { |
| 192 security_warning_timer_.Start( | 203 security_warning_timer_.Start( |
| 193 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, | 204 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, |
| 194 &UiSceneManager::OnSecurityWarningTimer); | 205 &UiSceneManager::OnSecurityWarningTimer); |
| 195 } else { | 206 } else { |
| 196 security_warning_timer_.Stop(); | 207 security_warning_timer_.Stop(); |
| 197 } | 208 } |
| 198 } | 209 } |
| 199 | 210 |
| 200 void UiSceneManager::OnSecurityWarningTimer() { | 211 void UiSceneManager::OnSecurityWarningTimer() { |
| 201 transient_security_warning_->visible = false; | 212 transient_security_warning_->visible = false; |
| 202 } | 213 } |
| 203 | 214 |
| 204 int UiSceneManager::AllocateId() { | 215 int UiSceneManager::AllocateId() { |
| 205 return next_available_id_++; | 216 return next_available_id_++; |
| 206 } | 217 } |
| 207 | 218 |
| 208 } // namespace vr_shell | 219 } // namespace vr_shell |
| OLD | NEW |