Chromium Code Reviews| Index: chrome/browser/android/vr_shell/ui_scene_manager.cc |
| diff --git a/chrome/browser/android/vr_shell/ui_scene_manager.cc b/chrome/browser/android/vr_shell/ui_scene_manager.cc |
| index 1734db13ddd38b47d00d907076a0055a06404e86..7e4d8f6c344e645f2a18124d4bb70d01349d4fff 100644 |
| --- a/chrome/browser/android/vr_shell/ui_scene_manager.cc |
| +++ b/chrome/browser/android/vr_shell/ui_scene_manager.cc |
| @@ -18,6 +18,7 @@ |
| #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/screen_capture_indicator.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/screen_dimmer.h" |
| +#include "chrome/browser/android/vr_shell/ui_elements/splash_screen_icon.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/transient_url_bar.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| @@ -87,6 +88,15 @@ static constexpr float kTransientUrlBarVerticalOffset = |
| -0.2 * kTransientUrlBarDistance; |
| static constexpr int kTransientUrlBarTimeoutSeconds = 6; |
| +static constexpr float kSplashScreenDistance = 1; |
| +static constexpr float kSplashScreenIconDMM = 0.12; |
| +static constexpr float kSplashScreenIconHeight = |
| + kSplashScreenIconDMM * kSplashScreenDistance; |
| +static constexpr float kSplashScreenIconWidth = |
| + kSplashScreenIconDMM * kSplashScreenDistance; |
| +static constexpr float kSplashScreenIconVerticalOffset = |
| + 0.2 * kSplashScreenDistance; |
| + |
| static constexpr float kCloseButtonDistance = 2.4; |
| static constexpr float kCloseButtonHeight = |
| kUrlBarHeightDMM * kCloseButtonDistance; |
| @@ -120,13 +130,14 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser, |
| UiScene* scene, |
| bool in_cct, |
| bool in_web_vr, |
| - bool web_vr_autopresented) |
| + bool web_vr_autopresentation_expected) |
| : browser_(browser), |
| scene_(scene), |
| in_cct_(in_cct), |
| web_vr_mode_(in_web_vr), |
| - web_vr_autopresented_(web_vr_autopresented), |
| + web_vr_autopresentation_expected_(web_vr_autopresentation_expected), |
| weak_ptr_factory_(this) { |
| + CreateSplashScreen(); |
| CreateBackground(); |
| CreateContentQuad(); |
| CreateSecurityWarnings(); |
| @@ -137,9 +148,10 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser, |
| CreateScreenDimmer(); |
| CreateExitPrompt(); |
| + 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.
|
| + |
| ConfigureScene(); |
| ConfigureSecurityWarnings(); |
| - ConfigureTransientUrlBar(); |
| } |
| UiSceneManager::~UiSceneManager() {} |
| @@ -280,6 +292,20 @@ void UiSceneManager::CreateContentQuad() { |
| -kBackgroundDistanceMultiplier); |
| } |
| +void UiSceneManager::CreateSplashScreen() { |
| + // Chrome icon. |
| + std::unique_ptr<SplashScreenIcon> icon = |
| + base::MakeUnique<SplashScreenIcon>(256); |
| + icon->set_debug_id(kSplashScreenIcon); |
| + icon->set_id(AllocateId()); |
| + icon->set_hit_testable(false); |
| + icon->set_size({kSplashScreenIconWidth, kSplashScreenIconHeight, 1.0}); |
| + icon->set_translation( |
| + {0, kSplashScreenIconVerticalOffset, -kSplashScreenDistance}); |
| + splash_screen_icon_ = icon.get(); |
| + scene_->AddUiElement(std::move(icon)); |
| +} |
| + |
| void UiSceneManager::CreateBackground() { |
| std::unique_ptr<UiElement> element; |
| @@ -412,45 +438,52 @@ base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { |
| return weak_ptr_factory_.GetWeakPtr(); |
| } |
| -void UiSceneManager::SetWebVrMode(bool web_vr, bool auto_presented) { |
| +void UiSceneManager::SetWebVrMode(bool web_vr) { |
| if (web_vr_mode_ == web_vr) |
| return; |
| web_vr_mode_ = web_vr; |
| - web_vr_autopresented_ = auto_presented; |
| + scene_->set_showing_splash_screen(false); |
| + |
| ConfigureScene(); |
| ConfigureSecurityWarnings(); |
| ConfigureTransientUrlBar(); |
| audio_capture_indicator_->set_visible(!web_vr && audio_capturing_); |
| video_capture_indicator_->set_visible(!web_vr && video_capturing_); |
| screen_capture_indicator_->set_visible(!web_vr && screen_capturing_); |
| + web_vr_autopresentation_expected_ = false; |
| } |
| void UiSceneManager::ConfigureScene() { |
| - exit_warning_->SetEnabled(scene_->is_exiting()); |
| - screen_dimmer_->SetEnabled(scene_->is_exiting()); |
| + splash_screen_icon_->SetEnabled(!web_vr_mode_ && |
| + scene_->showing_splash_screen()); |
| + |
| + bool browsing_mode = !web_vr_mode_ && !scene_->showing_splash_screen(); |
| + // 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.
|
| + exit_warning_->SetEnabled(scene_->is_exiting() && browsing_mode); |
| + 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
|
| // Controls (URL bar, loading progress, etc). |
| - bool controls_visible = !web_vr_mode_ && !fullscreen_; |
| + bool controls_visible = browsing_mode && !fullscreen_; |
| for (UiElement* element : control_elements_) { |
| element->SetEnabled(controls_visible && !scene_->is_prompting_to_exit()); |
| } |
| // Close button is a special control element that needs to be hidden when in |
| // WebVR, but it needs to be visible when in cct or fullscreen. |
| - close_button_->SetEnabled(!web_vr_mode_ && (fullscreen_ || in_cct_)); |
| + close_button_->SetEnabled(browsing_mode && (fullscreen_ || in_cct_)); |
| // Content elements. |
| for (UiElement* element : content_elements_) { |
| - element->SetEnabled(!web_vr_mode_ && !scene_->is_prompting_to_exit()); |
| + element->SetEnabled(browsing_mode && !scene_->is_prompting_to_exit()); |
| } |
| // Background elements. |
| for (UiElement* element : background_elements_) { |
| - element->SetEnabled(!web_vr_mode_); |
| + element->SetEnabled(browsing_mode); |
| } |
| // Exit prompt. |
| - bool showExitPrompt = !web_vr_mode_ && scene_->is_prompting_to_exit(); |
| + bool showExitPrompt = browsing_mode && scene_->is_prompting_to_exit(); |
| exit_prompt_->SetEnabled(showExitPrompt); |
| exit_prompt_backplane_->SetEnabled(showExitPrompt); |
| @@ -495,6 +528,11 @@ void UiSceneManager::UpdateBackgroundColor() { |
| floor_->set_grid_color(color_scheme().floor_grid); |
| } |
| +void UiSceneManager::SetSplashScreenIcon(const SkBitmap& bitmap) { |
| + 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
|
| + ConfigureScene(); |
| +} |
| + |
| void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { |
| audio_capturing_ = enabled; |
| audio_capture_indicator_->set_visible(enabled && !web_vr_mode_); |
| @@ -556,7 +594,7 @@ void UiSceneManager::OnSecurityWarningTimer() { |
| } |
| void UiSceneManager::ConfigureTransientUrlBar() { |
| - bool enabled = web_vr_mode_ && web_vr_autopresented_; |
| + bool enabled = web_vr_mode_ && web_vr_autopresentation_expected_; |
| transient_url_bar_->set_visible(enabled); |
| if (enabled) { |
| transient_url_bar_timer_.Start( |