Commit c1116d78 authored by Ian Vollick's avatar Ian Vollick Committed by Commit Bot

[vr] Don't show security indicators after hosted UI

When in WebVR presentation, if we transition to metaworld to accept a
permission, when we return we should not show the permissions.

Bug: 827304,827306
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_vr;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I9280a04950dcc24f163be9f58fbf27c14c9ab6bd
Reviewed-on: https://chromium-review.googlesource.com/986290
Commit-Queue: Ian Vollick <vollick@chromium.org>
Reviewed-by: default avatarChristopher Grant <cjgrant@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547080}
parent b5205c1e
...@@ -2831,23 +2831,32 @@ void UiSceneCreator::CreateWebVrOverlayElements() { ...@@ -2831,23 +2831,32 @@ void UiSceneCreator::CreateWebVrOverlayElements() {
parent = CreateTransientParent(kWebVrIndicatorTransience, parent = CreateTransientParent(kWebVrIndicatorTransience,
kToastTimeoutSeconds, true); kToastTimeoutSeconds, true);
parent->AddBinding(std::make_unique<Binding<std::pair<bool, bool>>>( parent->AddBinding(std::make_unique<Binding<std::tuple<bool, bool, bool>>>(
VR_BIND_LAMBDA( VR_BIND_LAMBDA(
[](Model* model, UiElement* splash_screen) { [](Model* model, UiElement* splash_screen) {
return std::make_pair(model->web_vr_enabled() && return std::tuple<bool, bool, bool>(
model->web_vr.presenting_web_vr() && model->web_vr_enabled() && model->web_vr.presenting_web_vr() &&
model->web_vr.has_received_permissions && model->web_vr.has_received_permissions &&
splash_screen->GetTargetOpacity() == 0.f, splash_screen->GetTargetOpacity() == 0.f,
model->controller.app_button_long_pressed); model->controller.app_button_long_pressed,
model->web_vr.showing_hosted_ui);
}, },
base::Unretained(model_), base::Unretained(model_),
base::Unretained( base::Unretained(
scene_->GetUiElementByName(kSplashScreenTransientParent))), scene_->GetUiElementByName(kSplashScreenTransientParent))),
VR_BIND_LAMBDA( VR_BIND_LAMBDA(
[](TransientElement* e, Model* model, UiScene* scene, [](TransientElement* e, Model* model, UiScene* scene,
const base::Optional<std::pair<bool, bool>>& last_value, const base::Optional<std::tuple<bool, bool, bool>>& last_value,
const std::pair<bool, bool>& value) { const std::tuple<bool, bool, bool>& value) {
if (!value.first) { const bool in_web_vr_presentation = std::get<0>(value);
const bool in_long_press = std::get<1>(value);
const bool showing_hosted_ui = std::get<2>(value);
const bool was_in_long_press =
last_value && std::get<1>(last_value.value());
const bool was_showing_hosted_ui =
last_value && std::get<2>(last_value.value());
if (!in_web_vr_presentation) {
e->SetVisibleImmediately(false); e->SetVisibleImmediately(false);
return; return;
} }
...@@ -2856,7 +2865,12 @@ void UiSceneCreator::CreateWebVrOverlayElements() { ...@@ -2856,7 +2865,12 @@ void UiSceneCreator::CreateWebVrOverlayElements() {
// situation where the app button has been released after a long // situation where the app button has been released after a long
// press, and the situation when we want to initially show the // press, and the situation when we want to initially show the
// indicators. // indicators.
if (last_value && last_value.value().second && !value.second) if (was_in_long_press && !in_long_press)
return;
// Similarly, we need to know when we've finished presenting hosted
// ui because we should not show indicators then.
if (was_showing_hosted_ui && !showing_hosted_ui)
return; return;
e->SetVisible(true); e->SetVisible(true);
...@@ -2864,7 +2878,7 @@ void UiSceneCreator::CreateWebVrOverlayElements() { ...@@ -2864,7 +2878,7 @@ void UiSceneCreator::CreateWebVrOverlayElements() {
SetVisibleInLayout( SetVisibleInLayout(
scene->GetUiElementByName(kWebVrExclusiveScreenToast), scene->GetUiElementByName(kWebVrExclusiveScreenToast),
!model->web_vr_autopresentation_enabled() && !model->web_vr_autopresentation_enabled() &&
!model->browsing_disabled && !value.second); !model->browsing_disabled && !in_long_press);
SetVisibleInLayout(scene->GetUiElementByName(kWebVrUrlToast), SetVisibleInLayout(scene->GetUiElementByName(kWebVrUrlToast),
model->web_vr_autopresentation_enabled() && model->web_vr_autopresentation_enabled() &&
model->toolbar_state.should_display_url); model->toolbar_state.should_display_url);
...@@ -2879,7 +2893,8 @@ void UiSceneCreator::CreateWebVrOverlayElements() { ...@@ -2879,7 +2893,8 @@ void UiSceneCreator::CreateWebVrOverlayElements() {
} }
e->RemoveKeyframeModels(TRANSFORM); e->RemoveKeyframeModels(TRANSFORM);
if (value.second) { if (in_long_press) {
// We do not do a translation animation for long press.
e->SetTranslate(0, 0, 0); e->SetTranslate(0, 0, 0);
return; return;
} }
......
...@@ -1382,6 +1382,24 @@ TEST_F(UiTest, RepositionHostedUi) { ...@@ -1382,6 +1382,24 @@ TEST_F(UiTest, RepositionHostedUi) {
EXPECT_EQ(original, hosted_ui->world_space_transform()); EXPECT_EQ(original, hosted_ui->world_space_transform());
} }
// Ensures that permissions do not appear after showing hosted UI.
TEST_F(UiTest, DoNotShowIndicatorsAfterHostedUi) {
CreateScene(kNotInCct, kInWebVr);
ui_->SetWebVrMode(true);
EXPECT_FALSE(IsVisible(kWebVrExclusiveScreenToast));
ui_->OnWebVrFrameAvailable();
ui_->SetCapturingState(CapturingStateModel());
OnBeginFrame();
EXPECT_TRUE(IsVisible(kWebVrExclusiveScreenToast));
RunFor(MsToDelta(8000));
EXPECT_FALSE(IsVisible(kWebVrExclusiveScreenToast));
model_->web_vr.showing_hosted_ui = true;
OnBeginFrame();
model_->web_vr.showing_hosted_ui = false;
OnBeginFrame();
EXPECT_FALSE(IsVisible(kWebVrExclusiveScreenToast));
}
// Ensures that permissions appear on long press, and that when the app button // Ensures that permissions appear on long press, and that when the app button
// is released that we do not show the exclusive screen toast. Distinguishing // is released that we do not show the exclusive screen toast. Distinguishing
// these cases requires knowledge of the previous state. // these cases requires knowledge of the previous state.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment