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 4a6f45111f69e8ebe27183bd15d848582c585597..5cfb00397937a5dbaf4e1716679bdde911057a7c 100644 |
| --- a/chrome/browser/android/vr_shell/ui_scene_manager.cc |
| +++ b/chrome/browser/android/vr_shell/ui_scene_manager.cc |
| @@ -10,6 +10,7 @@ |
| #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/button.h" |
| +#include "chrome/browser/android/vr_shell/ui_elements/exit_prompt.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/exit_warning.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" |
| #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning.h" |
| @@ -35,6 +36,11 @@ static constexpr float kPermanentWarningWidth = 0.224f; |
| static constexpr float kTransientWarningHeight = 0.160; |
| static constexpr float kTransientWarningWidth = 0.512; |
| +static constexpr float kExitPromptDistance = 2.5; |
| +static constexpr float kExitPromptWidth = 0.672 * kExitPromptDistance; |
| +static constexpr float kExitPromptHeight = 0.2 * kExitPromptDistance; |
| +static constexpr float kExitPromptVerticalOffset = -0.1 * kExitPromptDistance; |
| + |
| static constexpr float kExitWarningDistance = 0.6; |
| static constexpr float kExitWarningHeight = 0.160; |
| static constexpr float kExitWarningWidth = 0.512; |
| @@ -153,6 +159,22 @@ void UiSceneManager::CreateSecurityWarnings() { |
| element->set_lock_to_fov(true); |
| exit_warning_ = element.get(); |
| scene_->AddUiElement(std::move(element)); |
| + |
| + element = base::MakeUnique<ExitPrompt>( |
| + 512, |
| + base::Bind(&UiSceneManager::OnExitPromptPrimaryButtonClicked, |
| + base::Unretained(this)), |
| + base::Bind(&UiSceneManager::OnExitPromptSecondaryButtonClicked, |
| + base::Unretained(this))); |
| + element->set_debug_id(kExitPrompt); |
| + element->set_id(AllocateId()); |
| + element->set_fill(vr_shell::Fill::NONE); |
| + element->set_size({kExitPromptWidth, kExitPromptHeight, 1}); |
| + element->set_translation( |
| + {0, kExitPromptVerticalOffset, -kExitPromptDistance}); |
| + element->set_visible(false); |
| + exit_prompt_ = element.get(); |
| + scene_->AddUiElement(std::move(element)); |
| } |
| void UiSceneManager::CreateSystemIndicators() { |
| @@ -211,6 +233,7 @@ void UiSceneManager::CreateContentQuad() { |
| element->set_size({kBackplaneSize, kBackplaneSize, 1.0}); |
| element->set_translation({0.0, 0.0, -kTextureOffset}); |
| element->set_parent_id(main_content_->id()); |
| + main_content_backplane_ = element.get(); |
| content_elements_.push_back(element.get()); |
| scene_->AddUiElement(std::move(element)); |
| @@ -233,7 +256,7 @@ void UiSceneManager::CreateBackground() { |
| element->set_draw_phase(0); |
| element->set_gridline_count(kFloorGridlineCount); |
| floor_ = element.get(); |
| - content_elements_.push_back(element.get()); |
| + background_elements_.push_back(element.get()); |
|
amp
2017/06/02 20:37:01
This is going to confuse the unit tests for transi
ymalik
2017/06/04 04:08:56
I ran all the vr unit tests and they seem to pass.
amp
2017/06/05 16:44:57
Sorry, ignore this. I was misremembering an older
|
| scene_->AddUiElement(std::move(element)); |
| // Ceiling. |
| @@ -246,7 +269,7 @@ void UiSceneManager::CreateBackground() { |
| element->set_fill(vr_shell::Fill::OPAQUE_GRADIENT); |
| element->set_draw_phase(0); |
| ceiling_ = element.get(); |
| - content_elements_.push_back(element.get()); |
| + background_elements_.push_back(element.get()); |
| scene_->AddUiElement(std::move(element)); |
| UpdateBackgroundColor(); |
| @@ -256,13 +279,14 @@ void UiSceneManager::CreateUrlBar() { |
| // TODO(cjgrant): Incorporate final size and position. |
| auto url_bar = base::MakeUnique<UrlBar>( |
| 512, |
| + base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this)), |
| + base::Bind(&UiSceneManager::OnSecurityIconClicked, |
| + base::Unretained(this)), |
| base::Bind(&UiSceneManager::OnUnsupportedMode, base::Unretained(this))); |
| url_bar->set_debug_id(kUrlBar); |
| url_bar->set_id(AllocateId()); |
| url_bar->set_translation({0, kUrlBarVerticalOffset, -kUrlBarDistance}); |
| url_bar->set_size({kUrlBarWidth, kUrlBarHeight, 1}); |
| - url_bar->SetBackButtonCallback( |
| - base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); |
| url_bar_ = url_bar.get(); |
| control_elements_.push_back(url_bar.get()); |
| scene_->AddUiElement(std::move(url_bar)); |
| @@ -311,16 +335,29 @@ void UiSceneManager::SetWebVrMode(bool web_vr) { |
| void UiSceneManager::ConfigureScene() { |
| exit_warning_->SetEnabled(scene_->is_exiting()); |
| + exit_prompt_->SetEnabled(scene_->is_prompting_to_exit()); |
| screen_dimmer_->SetEnabled(scene_->is_exiting()); |
| // Controls (URL bar, loading progress, etc). |
| bool controls_visible = !web_vr_mode_ && !fullscreen_; |
| for (UiElement* element : control_elements_) { |
| - element->SetEnabled(controls_visible); |
| + element->SetEnabled(controls_visible && !scene_->is_prompting_to_exit()); |
| } |
| // Content elements. |
| for (UiElement* element : content_elements_) { |
| + // We don't want to show the content elements when the exit prompt is |
| + // visible. The only content element visible in this case is the invisible |
| + // backplane that we add right behind the content rect so that the rectile |
|
cjgrant
2017/06/02 04:16:36
s/rectile/reticle/
ymalik
2017/06/02 21:14:31
Done.
|
| + // doesn't jump when it transitions between the content rect (and the exit |
| + // prompt in this case) and the background. |
| + bool disabled_for_exit_prompt = |
| + element != main_content_backplane_ && scene_->is_prompting_to_exit(); |
| + element->SetEnabled(!web_vr_mode_ && !disabled_for_exit_prompt); |
| + } |
| + |
| + // Background elements. |
| + for (UiElement* element : background_elements_) { |
| element->SetEnabled(!web_vr_mode_); |
| } |
| @@ -417,6 +454,24 @@ void UiSceneManager::OnBackButtonClicked() { |
| browser_->NavigateBack(); |
| } |
| +void UiSceneManager::OnSecurityIconClicked() { |
| + if (scene_->is_prompting_to_exit()) |
| + return; |
| + scene_->set_is_prompting_to_exit(true); |
|
cjgrant
2017/06/02 04:16:36
I need to look at this tomorrow, but I don't get w
ymalik
2017/06/04 04:08:56
The prompt is a part of the scene so it should kno
|
| + ConfigureScene(); |
| +} |
| + |
| +void UiSceneManager::OnExitPromptPrimaryButtonClicked() { |
| + if (!scene_->is_prompting_to_exit()) |
| + return; |
| + scene_->set_is_prompting_to_exit(false); |
| + ConfigureScene(); |
| +} |
| + |
| +void UiSceneManager::OnExitPromptSecondaryButtonClicked() { |
| + OnUnsupportedMode(UiUnsupportedMode::kUnhandledPageInfo); |
| +} |
| + |
| void UiSceneManager::SetURL(const GURL& gurl) { |
| url_bar_->SetURL(gurl); |
| } |