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

Unified Diff: chrome/browser/android/vr_shell/ui_scene_manager.cc

Issue 2913633002: [vr] Clicking on the security icon should prompt the user to bail out of VR (Closed)
Patch Set: address amp's comments 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 side-by-side diff with in-line comments
Download patch
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..50545c84d2414ffe1e5ee321597c30c1f09a535f 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"
@@ -46,6 +47,9 @@ static constexpr float kContentVerticalOffset = -0.1 * kContentDistance;
static constexpr float kBackplaneSize = 1000.0;
static constexpr float kBackgroundDistanceMultiplier = 1.414;
+static constexpr float kExitPromptWidth = 0.672 * kContentDistance;
+static constexpr float kExitPromptHeight = 0.2 * kContentDistance;
+
static constexpr float kUrlBarDistance = 2.4;
static constexpr float kUrlBarWidth = 0.672 * kUrlBarDistance;
static constexpr float kUrlBarHeight = 0.088 * kUrlBarDistance;
@@ -211,9 +215,26 @@ 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));
+ 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.0, 0.0, kTextureOffset});
+ element->set_parent_id(main_content_->id());
+ element->set_visible(false);
+ exit_prompt_ = element.get();
+ scene_->AddUiElement(std::move(element));
+
// Limit reticle distance to a sphere based on content distance.
scene_->SetBackgroundDistance(main_content_->translation().z() *
-kBackgroundDistanceMultiplier);
@@ -233,7 +254,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());
scene_->AddUiElement(std::move(element));
// Ceiling.
@@ -246,7 +267,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 +277,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 +333,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 reticle
+ // 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 =
cjgrant 2017/06/05 17:33:53 It looks like we now have two content elements, an
ymalik 2017/06/05 20:02:42 Totally, good catch.
+ 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 +452,24 @@ void UiSceneManager::OnBackButtonClicked() {
browser_->NavigateBack();
}
+void UiSceneManager::OnSecurityIconClicked() {
+ if (scene_->is_prompting_to_exit())
cjgrant 2017/06/05 17:33:53 In this method and the next, why is the initial if
ymalik 2017/06/05 20:02:42 This is there for safety and you're right that thi
+ return;
+ scene_->set_is_prompting_to_exit(true);
+ 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);
}

Powered by Google App Engine
This is Rietveld 408576698