Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene_manager.cc

Issue 2833773005: Pause drawing webvr when the App button is pressed (Closed)
Patch Set: make UiBrowserInterface a raw ptr Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(VrBrowserInterface* browser, UiScene* scene)
46 : scene_(scene), weak_ptr_factory_(this) { 48 : browser_(browser), scene_(scene), weak_ptr_factory_(this) {
47 std::unique_ptr<UiElement> element; 49 std::unique_ptr<UiElement> element;
48 50
49 CreateBackground(); 51 CreateBackground();
50 CreateContentQuad(); 52 CreateContentQuad();
51 CreateSecurityWarnings(); 53 CreateSecurityWarnings();
52 } 54 }
53 55
54 UiSceneManager::~UiSceneManager() {} 56 UiSceneManager::~UiSceneManager() {}
55 57
56 void UiSceneManager::CreateSecurityWarnings() { 58 void UiSceneManager::CreateSecurityWarnings() {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 179 }
178 180
179 ConfigureSecurityWarnings(); 181 ConfigureSecurityWarnings();
180 } 182 }
181 183
182 void UiSceneManager::SetWebVRSecureOrigin(bool secure) { 184 void UiSceneManager::SetWebVRSecureOrigin(bool secure) {
183 secure_origin_ = secure; 185 secure_origin_ = secure;
184 ConfigureSecurityWarnings(); 186 ConfigureSecurityWarnings();
185 } 187 }
186 188
189 void UiSceneManager::OnAppButtonClicked() {
190 // Pressing the app button currenly pauses content rendering. Note: its still
191 // unclear what we want to do here and this will most likely change.
192 content_rendering_enabled_ = !content_rendering_enabled_;
193 scene_->SetWebVrRenderingEnabled(content_rendering_enabled_);
194 browser_->OnContentPaused(!content_rendering_enabled_);
195 }
196
187 void UiSceneManager::ConfigureSecurityWarnings() { 197 void UiSceneManager::ConfigureSecurityWarnings() {
188 bool enabled = web_vr_mode_ && !secure_origin_; 198 bool enabled = web_vr_mode_ && !secure_origin_;
189 permanent_security_warning_->visible = enabled; 199 permanent_security_warning_->visible = enabled;
190 transient_security_warning_->visible = enabled; 200 transient_security_warning_->visible = enabled;
191 if (enabled) { 201 if (enabled) {
192 security_warning_timer_.Start( 202 security_warning_timer_.Start(
193 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, 203 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this,
194 &UiSceneManager::OnSecurityWarningTimer); 204 &UiSceneManager::OnSecurityWarningTimer);
195 } else { 205 } else {
196 security_warning_timer_.Stop(); 206 security_warning_timer_.Stop();
197 } 207 }
198 } 208 }
199 209
200 void UiSceneManager::OnSecurityWarningTimer() { 210 void UiSceneManager::OnSecurityWarningTimer() {
201 transient_security_warning_->visible = false; 211 transient_security_warning_->visible = false;
202 } 212 }
203 213
204 int UiSceneManager::AllocateId() { 214 int UiSceneManager::AllocateId() {
205 return next_available_id_++; 215 return next_available_id_++;
206 } 216 }
207 217
208 } // namespace vr_shell 218 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.h ('k') | chrome/browser/android/vr_shell/ui_scene_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698