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

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

Issue 2955483003: Show splash screen when entering VR from a deep-link (Closed)
Patch Set: . Created 3 years, 6 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/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" 9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h"
10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" 10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h"
11 #include "chrome/browser/android/vr_shell/ui_browser_interface.h" 11 #include "chrome/browser/android/vr_shell/ui_browser_interface.h"
12 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" 12 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h"
13 #include "chrome/browser/android/vr_shell/ui_elements/button.h" 13 #include "chrome/browser/android/vr_shell/ui_elements/button.h"
14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h"
15 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h" 15 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h"
16 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" 16 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h"
17 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" 17 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h"
18 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" 18 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h"
19 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h " 19 #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h "
20 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" 20 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h"
21 #include "chrome/browser/android/vr_shell/ui_elements/splash_screen_icon.h"
21 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" 22 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h"
22 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" 23 #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h"
23 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" 24 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h"
24 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h" 25 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_debug_id.h"
25 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" 26 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h"
26 #include "chrome/browser/android/vr_shell/ui_elements/video_capture_indicator.h" 27 #include "chrome/browser/android/vr_shell/ui_elements/video_capture_indicator.h"
27 #include "chrome/browser/android/vr_shell/ui_scene.h" 28 #include "chrome/browser/android/vr_shell/ui_scene.h"
28 29
29 namespace vr_shell { 30 namespace vr_shell {
30 31
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 81
81 static constexpr float kTransientUrlBarDistance = 1.4; 82 static constexpr float kTransientUrlBarDistance = 1.4;
82 static constexpr float kTransientUrlBarWidth = 83 static constexpr float kTransientUrlBarWidth =
83 kUrlBarWidthDMM * kTransientUrlBarDistance; 84 kUrlBarWidthDMM * kTransientUrlBarDistance;
84 static constexpr float kTransientUrlBarHeight = 85 static constexpr float kTransientUrlBarHeight =
85 kUrlBarHeightDMM * kTransientUrlBarDistance; 86 kUrlBarHeightDMM * kTransientUrlBarDistance;
86 static constexpr float kTransientUrlBarVerticalOffset = 87 static constexpr float kTransientUrlBarVerticalOffset =
87 -0.2 * kTransientUrlBarDistance; 88 -0.2 * kTransientUrlBarDistance;
88 static constexpr int kTransientUrlBarTimeoutSeconds = 6; 89 static constexpr int kTransientUrlBarTimeoutSeconds = 6;
89 90
91 static constexpr float kSplashScreenDistance = 1;
92 static constexpr float kSplashScreenIconDMM = 0.12;
93 static constexpr float kSplashScreenIconHeight =
94 kSplashScreenIconDMM * kSplashScreenDistance;
95 static constexpr float kSplashScreenIconWidth =
96 kSplashScreenIconDMM * kSplashScreenDistance;
97 static constexpr float kSplashScreenIconVerticalOffset =
98 0.2 * kSplashScreenDistance;
99
90 static constexpr float kCloseButtonDistance = 2.4; 100 static constexpr float kCloseButtonDistance = 2.4;
91 static constexpr float kCloseButtonHeight = 101 static constexpr float kCloseButtonHeight =
92 kUrlBarHeightDMM * kCloseButtonDistance; 102 kUrlBarHeightDMM * kCloseButtonDistance;
93 static constexpr float kCloseButtonWidth = 103 static constexpr float kCloseButtonWidth =
94 kUrlBarHeightDMM * kCloseButtonDistance; 104 kUrlBarHeightDMM * kCloseButtonDistance;
95 static constexpr float kCloseButtonFullscreenDistance = 2.9; 105 static constexpr float kCloseButtonFullscreenDistance = 2.9;
96 static constexpr float kCloseButtonFullscreenHeight = 106 static constexpr float kCloseButtonFullscreenHeight =
97 kUrlBarHeightDMM * kCloseButtonDistance; 107 kUrlBarHeightDMM * kCloseButtonDistance;
98 static constexpr float kCloseButtonFullscreenWidth = 108 static constexpr float kCloseButtonFullscreenWidth =
99 kUrlBarHeightDMM * kCloseButtonDistance; 109 kUrlBarHeightDMM * kCloseButtonDistance;
(...skipping 13 matching lines...) Expand all
113 123
114 // Tiny distance to offset textures that should appear in the same plane. 124 // Tiny distance to offset textures that should appear in the same plane.
115 static constexpr float kTextureOffset = 0.01; 125 static constexpr float kTextureOffset = 0.01;
116 126
117 } // namespace 127 } // namespace
118 128
119 UiSceneManager::UiSceneManager(UiBrowserInterface* browser, 129 UiSceneManager::UiSceneManager(UiBrowserInterface* browser,
120 UiScene* scene, 130 UiScene* scene,
121 bool in_cct, 131 bool in_cct,
122 bool in_web_vr, 132 bool in_web_vr,
123 bool web_vr_autopresented) 133 bool web_vr_autopresentation_expected)
124 : browser_(browser), 134 : browser_(browser),
125 scene_(scene), 135 scene_(scene),
126 in_cct_(in_cct), 136 in_cct_(in_cct),
127 web_vr_mode_(in_web_vr), 137 web_vr_mode_(in_web_vr),
128 web_vr_autopresented_(web_vr_autopresented), 138 web_vr_autopresentation_expected_(web_vr_autopresentation_expected),
129 weak_ptr_factory_(this) { 139 weak_ptr_factory_(this) {
140 CreateSplashScreen();
130 CreateBackground(); 141 CreateBackground();
131 CreateContentQuad(); 142 CreateContentQuad();
132 CreateSecurityWarnings(); 143 CreateSecurityWarnings();
133 CreateSystemIndicators(); 144 CreateSystemIndicators();
134 CreateUrlBar(); 145 CreateUrlBar();
135 CreateTransientUrlBar(); 146 CreateTransientUrlBar();
136 CreateCloseButton(); 147 CreateCloseButton();
137 CreateScreenDimmer(); 148 CreateScreenDimmer();
138 CreateExitPrompt(); 149 CreateExitPrompt();
139 150
151 scene_->set_showing_splash_screen(web_vr_autopresentation_expected_);
cjgrant 2017/06/23 19:26:32 Why is this not in ConfigureScene()?
ymalik 2017/06/25 20:27:14 Done.
152
140 ConfigureScene(); 153 ConfigureScene();
141 ConfigureSecurityWarnings(); 154 ConfigureSecurityWarnings();
142 ConfigureTransientUrlBar();
143 } 155 }
144 156
145 UiSceneManager::~UiSceneManager() {} 157 UiSceneManager::~UiSceneManager() {}
146 158
147 void UiSceneManager::CreateScreenDimmer() { 159 void UiSceneManager::CreateScreenDimmer() {
148 std::unique_ptr<UiElement> element; 160 std::unique_ptr<UiElement> element;
149 element = base::MakeUnique<ScreenDimmer>(); 161 element = base::MakeUnique<ScreenDimmer>();
150 element->set_debug_id(kScreenDimmer); 162 element->set_debug_id(kScreenDimmer);
151 element->set_id(AllocateId()); 163 element->set_id(AllocateId());
152 element->set_fill(vr_shell::Fill::NONE); 164 element->set_fill(vr_shell::Fill::NONE);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 element->set_translation({0.0, 0.0, -kTextureOffset}); 285 element->set_translation({0.0, 0.0, -kTextureOffset});
274 element->set_parent_id(main_content_->id()); 286 element->set_parent_id(main_content_->id());
275 content_elements_.push_back(element.get()); 287 content_elements_.push_back(element.get());
276 scene_->AddUiElement(std::move(element)); 288 scene_->AddUiElement(std::move(element));
277 289
278 // Limit reticle distance to a sphere based on content distance. 290 // Limit reticle distance to a sphere based on content distance.
279 scene_->SetBackgroundDistance(main_content_->translation().z() * 291 scene_->SetBackgroundDistance(main_content_->translation().z() *
280 -kBackgroundDistanceMultiplier); 292 -kBackgroundDistanceMultiplier);
281 } 293 }
282 294
295 void UiSceneManager::CreateSplashScreen() {
296 // Chrome icon.
297 std::unique_ptr<SplashScreenIcon> icon =
298 base::MakeUnique<SplashScreenIcon>(256);
299 icon->set_debug_id(kSplashScreenIcon);
300 icon->set_id(AllocateId());
301 icon->set_hit_testable(false);
302 icon->set_size({kSplashScreenIconWidth, kSplashScreenIconHeight, 1.0});
303 icon->set_translation(
304 {0, kSplashScreenIconVerticalOffset, -kSplashScreenDistance});
305 splash_screen_icon_ = icon.get();
306 scene_->AddUiElement(std::move(icon));
307 }
308
283 void UiSceneManager::CreateBackground() { 309 void UiSceneManager::CreateBackground() {
284 std::unique_ptr<UiElement> element; 310 std::unique_ptr<UiElement> element;
285 311
286 // Floor. 312 // Floor.
287 element = base::MakeUnique<UiElement>(); 313 element = base::MakeUnique<UiElement>();
288 element->set_debug_id(kFloor); 314 element->set_debug_id(kFloor);
289 element->set_id(AllocateId()); 315 element->set_id(AllocateId());
290 element->set_size({kSceneSize, kSceneSize, 1.0}); 316 element->set_size({kSceneSize, kSceneSize, 1.0});
291 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); 317 element->set_translation({0.0, -kSceneHeight / 2, 0.0});
292 element->set_rotation(gfx::Quaternion(gfx::Vector3dF(1, 0, 0), -M_PI / 2)); 318 element->set_rotation(gfx::Quaternion(gfx::Vector3dF(1, 0, 0), -M_PI / 2));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 element->set_parent_id(exit_prompt_->id()); 431 element->set_parent_id(exit_prompt_->id());
406 exit_prompt_backplane_ = element.get(); 432 exit_prompt_backplane_ = element.get();
407 content_elements_.push_back(element.get()); 433 content_elements_.push_back(element.get());
408 scene_->AddUiElement(std::move(element)); 434 scene_->AddUiElement(std::move(element));
409 } 435 }
410 436
411 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 437 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
412 return weak_ptr_factory_.GetWeakPtr(); 438 return weak_ptr_factory_.GetWeakPtr();
413 } 439 }
414 440
415 void UiSceneManager::SetWebVrMode(bool web_vr, bool auto_presented) { 441 void UiSceneManager::SetWebVrMode(bool web_vr) {
416 if (web_vr_mode_ == web_vr) 442 if (web_vr_mode_ == web_vr)
417 return; 443 return;
418 web_vr_mode_ = web_vr; 444 web_vr_mode_ = web_vr;
419 web_vr_autopresented_ = auto_presented; 445 scene_->set_showing_splash_screen(false);
446
420 ConfigureScene(); 447 ConfigureScene();
421 ConfigureSecurityWarnings(); 448 ConfigureSecurityWarnings();
422 ConfigureTransientUrlBar(); 449 ConfigureTransientUrlBar();
423 audio_capture_indicator_->set_visible(!web_vr && audio_capturing_); 450 audio_capture_indicator_->set_visible(!web_vr && audio_capturing_);
424 video_capture_indicator_->set_visible(!web_vr && video_capturing_); 451 video_capture_indicator_->set_visible(!web_vr && video_capturing_);
425 screen_capture_indicator_->set_visible(!web_vr && screen_capturing_); 452 screen_capture_indicator_->set_visible(!web_vr && screen_capturing_);
453 web_vr_autopresentation_expected_ = false;
426 } 454 }
427 455
428 void UiSceneManager::ConfigureScene() { 456 void UiSceneManager::ConfigureScene() {
429 exit_warning_->SetEnabled(scene_->is_exiting()); 457 splash_screen_icon_->SetEnabled(!web_vr_mode_ &&
430 screen_dimmer_->SetEnabled(scene_->is_exiting()); 458 scene_->showing_splash_screen());
459
460 bool browsing_mode = !web_vr_mode_ && !scene_->showing_splash_screen();
461 // Exit warning.
cjgrant 2017/06/23 19:26:32 New-line before // Exit warning, as others below?
ymalik 2017/06/25 20:27:14 Done.
462 exit_warning_->SetEnabled(scene_->is_exiting() && browsing_mode);
463 screen_dimmer_->SetEnabled(scene_->is_exiting() && browsing_mode);
cjgrant 2017/06/23 19:26:33 Why are these changing to not show in WebVR?
ymalik 2017/06/25 20:27:14 You're right. this shouldn't be the case. We can b
431 464
432 // Controls (URL bar, loading progress, etc). 465 // Controls (URL bar, loading progress, etc).
433 bool controls_visible = !web_vr_mode_ && !fullscreen_; 466 bool controls_visible = browsing_mode && !fullscreen_;
434 for (UiElement* element : control_elements_) { 467 for (UiElement* element : control_elements_) {
435 element->SetEnabled(controls_visible && !scene_->is_prompting_to_exit()); 468 element->SetEnabled(controls_visible && !scene_->is_prompting_to_exit());
436 } 469 }
437 470
438 // Close button is a special control element that needs to be hidden when in 471 // Close button is a special control element that needs to be hidden when in
439 // WebVR, but it needs to be visible when in cct or fullscreen. 472 // WebVR, but it needs to be visible when in cct or fullscreen.
440 close_button_->SetEnabled(!web_vr_mode_ && (fullscreen_ || in_cct_)); 473 close_button_->SetEnabled(browsing_mode && (fullscreen_ || in_cct_));
441 474
442 // Content elements. 475 // Content elements.
443 for (UiElement* element : content_elements_) { 476 for (UiElement* element : content_elements_) {
444 element->SetEnabled(!web_vr_mode_ && !scene_->is_prompting_to_exit()); 477 element->SetEnabled(browsing_mode && !scene_->is_prompting_to_exit());
445 } 478 }
446 479
447 // Background elements. 480 // Background elements.
448 for (UiElement* element : background_elements_) { 481 for (UiElement* element : background_elements_) {
449 element->SetEnabled(!web_vr_mode_); 482 element->SetEnabled(browsing_mode);
450 } 483 }
451 484
452 // Exit prompt. 485 // Exit prompt.
453 bool showExitPrompt = !web_vr_mode_ && scene_->is_prompting_to_exit(); 486 bool showExitPrompt = browsing_mode && scene_->is_prompting_to_exit();
454 exit_prompt_->SetEnabled(showExitPrompt); 487 exit_prompt_->SetEnabled(showExitPrompt);
455 exit_prompt_backplane_->SetEnabled(showExitPrompt); 488 exit_prompt_backplane_->SetEnabled(showExitPrompt);
456 489
457 // Update content quad parameters depending on fullscreen. 490 // Update content quad parameters depending on fullscreen.
458 // TODO(http://crbug.com/642937): Animate fullscreen transitions. 491 // TODO(http://crbug.com/642937): Animate fullscreen transitions.
459 if (fullscreen_) { 492 if (fullscreen_) {
460 main_content_->set_translation( 493 main_content_->set_translation(
461 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); 494 {0, kFullscreenVerticalOffset, -kFullscreenDistance});
462 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); 495 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1});
463 496
(...skipping 24 matching lines...) Expand all
488 void UiSceneManager::UpdateBackgroundColor() { 521 void UiSceneManager::UpdateBackgroundColor() {
489 // TODO(vollick): it would be nice if ceiling, floor and the grid were 522 // TODO(vollick): it would be nice if ceiling, floor and the grid were
490 // UiElement subclasses and could respond to the OnSetMode signal. 523 // UiElement subclasses and could respond to the OnSetMode signal.
491 ceiling_->set_center_color(color_scheme().ceiling); 524 ceiling_->set_center_color(color_scheme().ceiling);
492 ceiling_->set_edge_color(color_scheme().world_background); 525 ceiling_->set_edge_color(color_scheme().world_background);
493 floor_->set_center_color(color_scheme().floor); 526 floor_->set_center_color(color_scheme().floor);
494 floor_->set_edge_color(color_scheme().world_background); 527 floor_->set_edge_color(color_scheme().world_background);
495 floor_->set_grid_color(color_scheme().floor_grid); 528 floor_->set_grid_color(color_scheme().floor_grid);
496 } 529 }
497 530
531 void UiSceneManager::SetSplashScreenIcon(const SkBitmap& bitmap) {
532 splash_screen_icon_->SetSplashScreenIcon(bitmap);
cjgrant 2017/06/23 19:26:32 SetSplashScreenBitmap() for clarity? As is you're
ymalik 2017/06/25 20:27:14 The "icon" here refers to the actual logo. SplashS
533 ConfigureScene();
534 }
535
498 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { 536 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) {
499 audio_capturing_ = enabled; 537 audio_capturing_ = enabled;
500 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_); 538 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_);
501 } 539 }
502 540
503 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { 541 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) {
504 video_capturing_ = enabled; 542 video_capturing_ = enabled;
505 video_capture_indicator_->set_visible(enabled && !web_vr_mode_); 543 video_capture_indicator_->set_visible(enabled && !web_vr_mode_);
506 } 544 }
507 545
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 } else { 587 } else {
550 security_warning_timer_.Stop(); 588 security_warning_timer_.Stop();
551 } 589 }
552 } 590 }
553 591
554 void UiSceneManager::OnSecurityWarningTimer() { 592 void UiSceneManager::OnSecurityWarningTimer() {
555 transient_security_warning_->set_visible(false); 593 transient_security_warning_->set_visible(false);
556 } 594 }
557 595
558 void UiSceneManager::ConfigureTransientUrlBar() { 596 void UiSceneManager::ConfigureTransientUrlBar() {
559 bool enabled = web_vr_mode_ && web_vr_autopresented_; 597 bool enabled = web_vr_mode_ && web_vr_autopresentation_expected_;
560 transient_url_bar_->set_visible(enabled); 598 transient_url_bar_->set_visible(enabled);
561 if (enabled) { 599 if (enabled) {
562 transient_url_bar_timer_.Start( 600 transient_url_bar_timer_.Start(
563 FROM_HERE, base::TimeDelta::FromSeconds(kTransientUrlBarTimeoutSeconds), 601 FROM_HERE, base::TimeDelta::FromSeconds(kTransientUrlBarTimeoutSeconds),
564 this, &UiSceneManager::OnTransientUrlBarTimer); 602 this, &UiSceneManager::OnTransientUrlBarTimer);
565 } else { 603 } else {
566 transient_url_bar_timer_.Stop(); 604 transient_url_bar_timer_.Stop();
567 } 605 }
568 } 606 }
569 607
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if (fullscreen_) 700 if (fullscreen_)
663 return ColorScheme::kModeFullscreen; 701 return ColorScheme::kModeFullscreen;
664 return ColorScheme::kModeNormal; 702 return ColorScheme::kModeNormal;
665 } 703 }
666 704
667 const ColorScheme& UiSceneManager::color_scheme() const { 705 const ColorScheme& UiSceneManager::color_scheme() const {
668 return ColorScheme::GetColorScheme(mode()); 706 return ColorScheme::GetColorScheme(mode());
669 } 707 }
670 708
671 } // namespace vr_shell 709 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698