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

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: fix compile error on bots Created 3 years, 5 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/button.h" 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h"
13 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" 13 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h"
14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h" 14 #include "chrome/browser/android/vr_shell/ui_elements/exit_prompt_backplane.h"
15 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" 15 #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h"
16 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" 16 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h"
17 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" 17 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h"
18 #include "chrome/browser/android/vr_shell/ui_elements/presentation_toast.h" 18 #include "chrome/browser/android/vr_shell/ui_elements/presentation_toast.h"
19 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" 19 #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h"
20 #include "chrome/browser/android/vr_shell/ui_elements/splash_screen_icon.h"
20 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.h" 21 #include "chrome/browser/android/vr_shell/ui_elements/system_indicator.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_scene.h" 27 #include "chrome/browser/android/vr_shell/ui_scene.h"
27 #include "chrome/grit/generated_resources.h" 28 #include "chrome/grit/generated_resources.h"
28 #include "components/vector_icons/vector_icons.h" 29 #include "components/vector_icons/vector_icons.h"
29 #include "ui/vector_icons/vector_icons.h" 30 #include "ui/vector_icons/vector_icons.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 kUrlBarHeightDMM * kTransientUrlBarDistance; 83 kUrlBarHeightDMM * kTransientUrlBarDistance;
83 static constexpr float kTransientUrlBarVerticalOffset = 84 static constexpr float kTransientUrlBarVerticalOffset =
84 -0.2 * kTransientUrlBarDistance; 85 -0.2 * kTransientUrlBarDistance;
85 static constexpr int kTransientUrlBarTimeoutSeconds = 6; 86 static constexpr int kTransientUrlBarTimeoutSeconds = 6;
86 87
87 static constexpr float kToastDistance = 1.4; 88 static constexpr float kToastDistance = 1.4;
88 static constexpr float kToastWidth = 0.512 * kToastDistance; 89 static constexpr float kToastWidth = 0.512 * kToastDistance;
89 static constexpr float kToastHeight = 0.16 * kToastDistance; 90 static constexpr float kToastHeight = 0.16 * kToastDistance;
90 static constexpr int kToastTimeoutSeconds = kTransientUrlBarTimeoutSeconds; 91 static constexpr int kToastTimeoutSeconds = kTransientUrlBarTimeoutSeconds;
91 92
93 static constexpr float kSplashScreenDistance = 1;
94 static constexpr float kSplashScreenIconDMM = 0.12;
95 static constexpr float kSplashScreenIconHeight =
96 kSplashScreenIconDMM * kSplashScreenDistance;
97 static constexpr float kSplashScreenIconWidth =
98 kSplashScreenIconDMM * kSplashScreenDistance;
99 static constexpr float kSplashScreenIconVerticalOffset =
100 0.2 * kSplashScreenDistance;
101
92 static constexpr float kCloseButtonDistance = 2.4; 102 static constexpr float kCloseButtonDistance = 2.4;
93 static constexpr float kCloseButtonHeight = 103 static constexpr float kCloseButtonHeight =
94 kUrlBarHeightDMM * kCloseButtonDistance; 104 kUrlBarHeightDMM * kCloseButtonDistance;
95 static constexpr float kCloseButtonWidth = 105 static constexpr float kCloseButtonWidth =
96 kUrlBarHeightDMM * kCloseButtonDistance; 106 kUrlBarHeightDMM * kCloseButtonDistance;
97 static constexpr float kCloseButtonFullscreenDistance = 2.9; 107 static constexpr float kCloseButtonFullscreenDistance = 2.9;
98 static constexpr float kCloseButtonFullscreenHeight = 108 static constexpr float kCloseButtonFullscreenHeight =
99 kUrlBarHeightDMM * kCloseButtonFullscreenDistance; 109 kUrlBarHeightDMM * kCloseButtonFullscreenDistance;
100 static constexpr float kCloseButtonFullscreenWidth = 110 static constexpr float kCloseButtonFullscreenWidth =
101 kUrlBarHeightDMM * kCloseButtonFullscreenDistance; 111 kUrlBarHeightDMM * kCloseButtonFullscreenDistance;
(...skipping 13 matching lines...) Expand all
115 125
116 // Tiny distance to offset textures that should appear in the same plane. 126 // Tiny distance to offset textures that should appear in the same plane.
117 static constexpr float kTextureOffset = 0.01; 127 static constexpr float kTextureOffset = 0.01;
118 128
119 } // namespace 129 } // namespace
120 130
121 UiSceneManager::UiSceneManager(UiBrowserInterface* browser, 131 UiSceneManager::UiSceneManager(UiBrowserInterface* browser,
122 UiScene* scene, 132 UiScene* scene,
123 bool in_cct, 133 bool in_cct,
124 bool in_web_vr, 134 bool in_web_vr,
125 bool web_vr_autopresented) 135 bool web_vr_autopresentation_expected)
126 : browser_(browser), 136 : browser_(browser),
127 scene_(scene), 137 scene_(scene),
128 in_cct_(in_cct), 138 in_cct_(in_cct),
129 web_vr_mode_(in_web_vr), 139 web_vr_mode_(in_web_vr),
130 web_vr_autopresented_(web_vr_autopresented), 140 web_vr_autopresentation_expected_(web_vr_autopresentation_expected),
131 weak_ptr_factory_(this) { 141 weak_ptr_factory_(this) {
142 CreateSplashScreen();
132 CreateBackground(); 143 CreateBackground();
133 CreateContentQuad(); 144 CreateContentQuad();
134 CreateSecurityWarnings(); 145 CreateSecurityWarnings();
135 CreateSystemIndicators(); 146 CreateSystemIndicators();
136 CreateUrlBar(); 147 CreateUrlBar();
137 CreateTransientUrlBar(); 148 CreateTransientUrlBar();
138 CreateCloseButton(); 149 CreateCloseButton();
139 CreateScreenDimmer(); 150 CreateScreenDimmer();
140 CreateExitPrompt(); 151 CreateExitPrompt();
141 CreateToasts(); 152 CreateToasts();
142 153
143 ConfigureScene(); 154 ConfigureScene();
144 ConfigureSecurityWarnings(); 155 ConfigureSecurityWarnings();
145 ConfigureTransientUrlBar();
146 } 156 }
147 157
148 UiSceneManager::~UiSceneManager() {} 158 UiSceneManager::~UiSceneManager() {}
149 159
150 void UiSceneManager::CreateScreenDimmer() { 160 void UiSceneManager::CreateScreenDimmer() {
151 std::unique_ptr<UiElement> element; 161 std::unique_ptr<UiElement> element;
152 element = base::MakeUnique<ScreenDimmer>(); 162 element = base::MakeUnique<ScreenDimmer>();
153 element->set_debug_id(kScreenDimmer); 163 element->set_debug_id(kScreenDimmer);
154 element->set_id(AllocateId()); 164 element->set_id(AllocateId());
155 element->set_fill(vr_shell::Fill::NONE); 165 element->set_fill(vr_shell::Fill::NONE);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 element->set_translation({0.0, 0.0, -kTextureOffset}); 279 element->set_translation({0.0, 0.0, -kTextureOffset});
270 element->set_parent_id(main_content_->id()); 280 element->set_parent_id(main_content_->id());
271 content_elements_.push_back(element.get()); 281 content_elements_.push_back(element.get());
272 scene_->AddUiElement(std::move(element)); 282 scene_->AddUiElement(std::move(element));
273 283
274 // Limit reticle distance to a sphere based on content distance. 284 // Limit reticle distance to a sphere based on content distance.
275 scene_->SetBackgroundDistance(main_content_->translation().z() * 285 scene_->SetBackgroundDistance(main_content_->translation().z() *
276 -kBackgroundDistanceMultiplier); 286 -kBackgroundDistanceMultiplier);
277 } 287 }
278 288
289 void UiSceneManager::CreateSplashScreen() {
290 // Chrome icon.
291 std::unique_ptr<SplashScreenIcon> icon =
292 base::MakeUnique<SplashScreenIcon>(256);
293 icon->set_debug_id(kSplashScreenIcon);
294 icon->set_id(AllocateId());
295 icon->set_hit_testable(false);
296 icon->set_size({kSplashScreenIconWidth, kSplashScreenIconHeight, 1.0});
297 icon->set_translation(
298 {0, kSplashScreenIconVerticalOffset, -kSplashScreenDistance});
299 splash_screen_icon_ = icon.get();
300 scene_->AddUiElement(std::move(icon));
301 }
302
279 void UiSceneManager::CreateBackground() { 303 void UiSceneManager::CreateBackground() {
280 std::unique_ptr<UiElement> element; 304 std::unique_ptr<UiElement> element;
281 305
282 // Floor. 306 // Floor.
283 element = base::MakeUnique<UiElement>(); 307 element = base::MakeUnique<UiElement>();
284 element->set_debug_id(kFloor); 308 element->set_debug_id(kFloor);
285 element->set_id(AllocateId()); 309 element->set_id(AllocateId());
286 element->set_size({kSceneSize, kSceneSize, 1.0}); 310 element->set_size({kSceneSize, kSceneSize, 1.0});
287 element->set_translation({0.0, -kSceneHeight / 2, 0.0}); 311 element->set_translation({0.0, -kSceneHeight / 2, 0.0});
288 element->set_rotation(gfx::Quaternion(gfx::Vector3dF(1, 0, 0), -M_PI / 2)); 312 element->set_rotation(gfx::Quaternion(gfx::Vector3dF(1, 0, 0), -M_PI / 2));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 element->set_hit_testable(false); 440 element->set_hit_testable(false);
417 element->set_lock_to_fov(true); 441 element->set_lock_to_fov(true);
418 presentation_toast_ = element.get(); 442 presentation_toast_ = element.get();
419 scene_->AddUiElement(std::move(element)); 443 scene_->AddUiElement(std::move(element));
420 } 444 }
421 445
422 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 446 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
423 return weak_ptr_factory_.GetWeakPtr(); 447 return weak_ptr_factory_.GetWeakPtr();
424 } 448 }
425 449
426 void UiSceneManager::SetWebVrMode(bool web_vr, 450 void UiSceneManager::SetWebVrMode(bool web_vr, bool show_toast) {
427 bool auto_presented, 451 if (web_vr_mode_ == web_vr && web_vr_show_toast_ == show_toast) {
428 bool show_toast) {
429 if (web_vr_mode_ == web_vr && web_vr_autopresented_ == auto_presented &&
430 web_vr_show_toast_ == show_toast) {
431 return; 452 return;
432 } 453 }
433 web_vr_mode_ = web_vr; 454 web_vr_mode_ = web_vr;
434 web_vr_autopresented_ = auto_presented; 455 ConfigureTransientUrlBar();
456 scene_->set_showing_splash_screen(false);
457 web_vr_autopresentation_expected_ = false;
435 web_vr_show_toast_ = show_toast; 458 web_vr_show_toast_ = show_toast;
436 toast_state_ = SET_FOR_WEB_VR; 459 toast_state_ = SET_FOR_WEB_VR;
437 ConfigureScene(); 460 ConfigureScene();
438 ConfigureSecurityWarnings(); 461 ConfigureSecurityWarnings();
439 ConfigureTransientUrlBar();
440 ConfigurePresentationToast(); 462 ConfigurePresentationToast();
441 } 463 }
442 464
443 void UiSceneManager::ConfigureScene() { 465 void UiSceneManager::ConfigureScene() {
466 // Splash screen.
467 scene_->set_showing_splash_screen(web_vr_autopresentation_expected_);
468 splash_screen_icon_->SetEnabled(!web_vr_mode_ &&
469 web_vr_autopresentation_expected_);
470
471 // Exit warning.
444 exit_warning_->SetEnabled(scene_->is_exiting()); 472 exit_warning_->SetEnabled(scene_->is_exiting());
445 screen_dimmer_->SetEnabled(scene_->is_exiting()); 473 screen_dimmer_->SetEnabled(scene_->is_exiting());
446 474
475 bool browsing_mode = !web_vr_mode_ && !scene_->showing_splash_screen();
476
447 // Controls (URL bar, loading progress, etc). 477 // Controls (URL bar, loading progress, etc).
448 bool controls_visible = !web_vr_mode_ && !fullscreen_; 478 bool controls_visible = browsing_mode && !fullscreen_;
449 for (UiElement* element : control_elements_) { 479 for (UiElement* element : control_elements_) {
450 element->SetEnabled(controls_visible && !scene_->is_prompting_to_exit()); 480 element->SetEnabled(controls_visible && !scene_->is_prompting_to_exit());
451 } 481 }
452 482
453 // Close button is a special control element that needs to be hidden when in 483 // Close button is a special control element that needs to be hidden when in
454 // WebVR, but it needs to be visible when in cct or fullscreen. 484 // WebVR, but it needs to be visible when in cct or fullscreen.
455 close_button_->SetEnabled(!web_vr_mode_ && (fullscreen_ || in_cct_)); 485 close_button_->SetEnabled(browsing_mode && (fullscreen_ || in_cct_));
456 486
457 // Content elements. 487 // Content elements.
458 for (UiElement* element : content_elements_) { 488 for (UiElement* element : content_elements_) {
459 element->SetEnabled(!web_vr_mode_ && !scene_->is_prompting_to_exit()); 489 element->SetEnabled(browsing_mode && !scene_->is_prompting_to_exit());
460 } 490 }
461 491
462 // Background elements. 492 // Background elements.
463 for (UiElement* element : background_elements_) { 493 for (UiElement* element : background_elements_) {
464 element->SetEnabled(!web_vr_mode_); 494 element->SetEnabled(browsing_mode);
465 } 495 }
466 496
467 // Exit prompt. 497 // Exit prompt.
468 bool showExitPrompt = !web_vr_mode_ && scene_->is_prompting_to_exit(); 498 bool showExitPrompt = browsing_mode && scene_->is_prompting_to_exit();
469 exit_prompt_->SetEnabled(showExitPrompt); 499 exit_prompt_->SetEnabled(showExitPrompt);
470 exit_prompt_backplane_->SetEnabled(showExitPrompt); 500 exit_prompt_backplane_->SetEnabled(showExitPrompt);
471 501
472 // Update content quad parameters depending on fullscreen. 502 // Update content quad parameters depending on fullscreen.
473 // TODO(http://crbug.com/642937): Animate fullscreen transitions. 503 // TODO(http://crbug.com/642937): Animate fullscreen transitions.
474 if (fullscreen_) { 504 if (fullscreen_) {
475 main_content_->set_translation( 505 main_content_->set_translation(
476 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); 506 {0, kFullscreenVerticalOffset, -kFullscreenDistance});
477 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); 507 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1});
478 508
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 void UiSceneManager::UpdateBackgroundColor() { 541 void UiSceneManager::UpdateBackgroundColor() {
512 // TODO(vollick): it would be nice if ceiling, floor and the grid were 542 // TODO(vollick): it would be nice if ceiling, floor and the grid were
513 // UiElement subclasses and could respond to the OnSetMode signal. 543 // UiElement subclasses and could respond to the OnSetMode signal.
514 ceiling_->set_center_color(color_scheme().ceiling); 544 ceiling_->set_center_color(color_scheme().ceiling);
515 ceiling_->set_edge_color(color_scheme().world_background); 545 ceiling_->set_edge_color(color_scheme().world_background);
516 floor_->set_center_color(color_scheme().floor); 546 floor_->set_center_color(color_scheme().floor);
517 floor_->set_edge_color(color_scheme().world_background); 547 floor_->set_edge_color(color_scheme().world_background);
518 floor_->set_grid_color(color_scheme().floor_grid); 548 floor_->set_grid_color(color_scheme().floor_grid);
519 } 549 }
520 550
551 void UiSceneManager::SetSplashScreenIcon(const SkBitmap& bitmap) {
552 splash_screen_icon_->SetSplashScreenIconBitmap(bitmap);
553 ConfigureScene();
554 }
555
521 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { 556 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) {
522 audio_capturing_ = enabled; 557 audio_capturing_ = enabled;
523 ConfigureIndicators(); 558 ConfigureIndicators();
524 } 559 }
525 560
526 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) { 561 void UiSceneManager::SetVideoCapturingIndicator(bool enabled) {
527 video_capturing_ = enabled; 562 video_capturing_ = enabled;
528 ConfigureIndicators(); 563 ConfigureIndicators();
529 } 564 }
530 565
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 presentation_toast_timer_.Stop(); 675 presentation_toast_timer_.Stop();
641 } 676 }
642 toast_state_ = UNCHANGED; 677 toast_state_ = UNCHANGED;
643 } 678 }
644 679
645 void UiSceneManager::OnSecurityWarningTimer() { 680 void UiSceneManager::OnSecurityWarningTimer() {
646 transient_security_warning_->set_visible(false); 681 transient_security_warning_->set_visible(false);
647 } 682 }
648 683
649 void UiSceneManager::ConfigureTransientUrlBar() { 684 void UiSceneManager::ConfigureTransientUrlBar() {
650 bool enabled = web_vr_mode_ && web_vr_autopresented_; 685 bool enabled = web_vr_mode_ && web_vr_autopresentation_expected_;
651 transient_url_bar_->set_visible(enabled); 686 transient_url_bar_->set_visible(enabled);
652 if (enabled) { 687 if (enabled) {
653 transient_url_bar_timer_.Start( 688 transient_url_bar_timer_.Start(
654 FROM_HERE, base::TimeDelta::FromSeconds(kTransientUrlBarTimeoutSeconds), 689 FROM_HERE, base::TimeDelta::FromSeconds(kTransientUrlBarTimeoutSeconds),
655 this, &UiSceneManager::OnTransientUrlBarTimer); 690 this, &UiSceneManager::OnTransientUrlBarTimer);
656 } else { 691 } else {
657 transient_url_bar_timer_.Stop(); 692 transient_url_bar_timer_.Stop();
658 } 693 }
659 } 694 }
660 695
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 if (fullscreen_) 793 if (fullscreen_)
759 return ColorScheme::kModeFullscreen; 794 return ColorScheme::kModeFullscreen;
760 return ColorScheme::kModeNormal; 795 return ColorScheme::kModeNormal;
761 } 796 }
762 797
763 const ColorScheme& UiSceneManager::color_scheme() const { 798 const ColorScheme& UiSceneManager::color_scheme() const {
764 return ColorScheme::GetColorScheme(mode()); 799 return ColorScheme::GetColorScheme(mode());
765 } 800 }
766 801
767 } // namespace vr_shell 802 } // 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