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

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

Issue 2955023002: VR: Factor transient timing out of UiSceneManager. (Closed)
Patch Set: 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 2258091639514f2298254f4f1e5da8238b9565e9..e58595c001cd6b011b63c123c342b33d426d710f 100644
--- a/chrome/browser/android/vr_shell/ui_scene_manager.cc
+++ b/chrome/browser/android/vr_shell/ui_scene_manager.cc
@@ -406,7 +406,8 @@ void UiSceneManager::CreateExitPrompt() {
}
void UiSceneManager::CreateToasts() {
- std::unique_ptr<UiElement> element = base::MakeUnique<PresentationToast>(512);
+ auto element = base::MakeUnique<PresentationToast>(
+ 512, base::TimeDelta::FromSeconds(kToastTimeoutSeconds));
element->set_debug_id(kPresentationToast);
element->set_id(AllocateId());
element->set_fill(vr_shell::Fill::NONE);
@@ -433,11 +434,16 @@ void UiSceneManager::SetWebVrMode(bool web_vr,
web_vr_mode_ = web_vr;
web_vr_autopresented_ = auto_presented;
web_vr_show_toast_ = show_toast;
- toast_state_ = SET_FOR_WEB_VR;
ConfigureScene();
ConfigureSecurityWarnings();
ConfigureTransientUrlBar();
- ConfigurePresentationToast();
+
+ if (!web_vr) {
+ // We may be returning to fullscreen, but we don't want to show the toast.
+ presentation_toast_->transience()->EndVisibility();
cjgrant 2017/06/26 20:39:35 Biao, please note the logic here. Basically, when
bshe 2017/06/27 14:57:09 It was previously hided I believe and I agree with
+ } else {
+ presentation_toast_->transience()->KickVisibility();
+ }
}
void UiSceneManager::ConfigureScene() {
@@ -499,6 +505,9 @@ void UiSceneManager::ConfigureScene() {
-kBackgroundDistanceMultiplier);
UpdateBackgroundColor();
+ presentation_toast_->SetEnabled((fullscreen_ && !web_vr_mode_) ||
+ (web_vr_mode_ && web_vr_show_toast_));
+
// Configure other subsystems here as well. Ultimately, it would be nice if we
// could configure all elements through ConfigureScene(), as the exact
// conditions that control each element are getting complicated. More systems
@@ -569,9 +578,8 @@ void UiSceneManager::SetFullscreen(bool fullscreen) {
if (fullscreen_ == fullscreen)
return;
fullscreen_ = fullscreen;
- toast_state_ = SET_FOR_FULLSCREEN;
ConfigureScene();
- ConfigurePresentationToast();
+ presentation_toast_->transience()->KickVisibility();
}
void UiSceneManager::ConfigureSecurityWarnings() {
@@ -579,6 +587,7 @@ void UiSceneManager::ConfigureSecurityWarnings() {
permanent_security_warning_->set_visible(enabled);
transient_security_warning_->set_visible(enabled);
if (enabled) {
+ security_warning_timer_.Stop();
security_warning_timer_.Start(
FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this,
&UiSceneManager::OnSecurityWarningTimer);
@@ -607,6 +616,7 @@ void UiSceneManager::ConfigureIndicators() {
total_width += indicator->size().x();
}
}
+
float x_position = -total_width / 2;
for (UiElement* indicator : system_indicators_) {
if (!indicator->visible())
@@ -619,30 +629,8 @@ void UiSceneManager::ConfigureIndicators() {
}
}
-void UiSceneManager::ConfigurePresentationToast() {
- bool toast_visible = false;
- switch (toast_state_) {
- case SET_FOR_WEB_VR:
- toast_visible = web_vr_show_toast_;
- break;
- case SET_FOR_FULLSCREEN:
- toast_visible = fullscreen_;
- break;
- case UNCHANGED:
- return;
- }
- presentation_toast_->set_visible(toast_visible);
- if (toast_visible) {
- presentation_toast_timer_.Start(
- FROM_HERE, base::TimeDelta::FromSeconds(kToastTimeoutSeconds), this,
- &UiSceneManager::OnPresentationToastTimer);
- } else {
- presentation_toast_timer_.Stop();
- }
- toast_state_ = UNCHANGED;
-}
-
void UiSceneManager::OnSecurityWarningTimer() {
+ // TODO: Also do this one!
transient_security_warning_->set_visible(false);
}
@@ -662,10 +650,6 @@ void UiSceneManager::OnTransientUrlBarTimer() {
transient_url_bar_->set_visible(false);
}
-void UiSceneManager::OnPresentationToastTimer() {
- presentation_toast_->set_visible(false);
-}
-
void UiSceneManager::OnBackButtonClicked() {
browser_->NavigateBack();
}
« 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