Commit 783afea4 authored by Sarah Hu's avatar Sarah Hu Committed by Commit Bot

Show a loading UI when waiting for the sync consent screen to be ready

Bug: 837577
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I709b737af4e8b77de40be4f2798681ffa45532b4
Reviewed-on: https://chromium-review.googlesource.com/1097948Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Commit-Queue: Xiaoyin Hu <xiaoyinh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567117}
parent 213440d1
...@@ -57,12 +57,15 @@ void SyncConsentScreen::Show() { ...@@ -57,12 +57,15 @@ void SyncConsentScreen::Show() {
} }
shown_ = true; shown_ = true;
if (behavior_ == SyncScreenBehavior::SHOW) { if (behavior_ != SyncScreenBehavior::SHOW) {
view_->Show(); // Wait for updates and set the loading throbber to be visible.
} else { view_->SetThrobberVisible(true /*visible*/);
// Wait for updates if not shown.
GetSyncService(profile_)->AddObserver(this); GetSyncService(profile_)->AddObserver(this);
} }
// Show the entire screen.
// If SyncScreenBehavior is show, this should show the sync consent screen.
// If SyncScreenBehavior is unknown, this should show the loading throbber.
view_->Show();
} }
void SyncConsentScreen::Hide() { void SyncConsentScreen::Hide() {
...@@ -152,7 +155,7 @@ void SyncConsentScreen::UpdateScreen() { ...@@ -152,7 +155,7 @@ void SyncConsentScreen::UpdateScreen() {
Finish(ScreenExitCode::SYNC_CONSENT_FINISHED); Finish(ScreenExitCode::SYNC_CONSENT_FINISHED);
if (behavior_ == SyncScreenBehavior::SHOW) { if (behavior_ == SyncScreenBehavior::SHOW) {
view_->Show(); view_->SetThrobberVisible(false /*visible*/);
GetSyncService(profile_)->RemoveObserver(this); GetSyncService(profile_)->RemoveObserver(this);
} }
} }
......
...@@ -27,6 +27,10 @@ class SyncConsentScreenView { ...@@ -27,6 +27,10 @@ class SyncConsentScreenView {
// Hides the contents of the screen. // Hides the contents of the screen.
virtual void Hide() = 0; virtual void Hide() = 0;
// Controls if the loading throbber is visible. This is used when
// SyncScreenBehavior is unknown.
virtual void SetThrobberVisible(bool visible) = 0;
}; };
} // namespace chromeos } // namespace chromeos
......
<!-- Copyright 2017 The Chromium Authors. All rights reserved. <!-- Copyright 2017 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. --> found in the LICENSE file. -->
<link rel="import" href="chrome://oobe/custom_elements.html">
<div class="step right hidden" id="sync-consent" hidden> <div class="step right hidden" id="sync-consent" hidden>
<sync-consent id="sync-consent-impl"></sync-consent> <sync-consent id="sync-consent-impl"></sync-consent>
<oobe-dialog id="sync-loading" role="dialog" no-header no-footer-padding
hidden>
<div class="footer flex layout vertical center center-justified">
<throbber-notice i18n-values="text:gaiaLoading">
</throbber-notice>
</div>
</oobe-dialog>
</div> </div>
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
login.createScreen('SyncConsentScreen', 'sync-consent', function() { login.createScreen('SyncConsentScreen', 'sync-consent', function() {
return { return {
EXTERNAL_API: ['onUserSyncPrefsKnown'], EXTERNAL_API: ['onUserSyncPrefsKnown', 'setThrobberVisible'],
/** /**
* Returns the control which should receive initial focus. * Returns the control which should receive initial focus.
...@@ -25,6 +25,13 @@ login.createScreen('SyncConsentScreen', 'sync-consent', function() { ...@@ -25,6 +25,13 @@ login.createScreen('SyncConsentScreen', 'sync-consent', function() {
Oobe.getInstance().headerHidden = true; Oobe.getInstance().headerHidden = true;
}, },
/**
* Event handler that is invoked just before the screen is hidden.
*/
onBeforeHide: function() {
this.setThrobberVisible(false /*visible*/);
},
/** /**
* This is called after resources are updated. * This is called after resources are updated.
*/ */
...@@ -40,5 +47,14 @@ login.createScreen('SyncConsentScreen', 'sync-consent', function() { ...@@ -40,5 +47,14 @@ login.createScreen('SyncConsentScreen', 'sync-consent', function() {
onUserSyncPrefsKnown: function(sync_everything, is_managed) { onUserSyncPrefsKnown: function(sync_everything, is_managed) {
$('sync-consent-impl').onUserSyncPrefsKnown(sync_everything, is_managed); $('sync-consent-impl').onUserSyncPrefsKnown(sync_everything, is_managed);
}, },
/**
* This is called to show/hide the loading UI.
* @param {boolean} visible whether to show loading UI.
*/
setThrobberVisible: function(visible) {
$('sync-loading').hidden = !visible;
$('sync-consent-impl').hidden = visible;
},
}; };
}); });
...@@ -85,6 +85,10 @@ void SyncConsentScreenHandler::Show() { ...@@ -85,6 +85,10 @@ void SyncConsentScreenHandler::Show() {
void SyncConsentScreenHandler::Hide() {} void SyncConsentScreenHandler::Hide() {}
void SyncConsentScreenHandler::SetThrobberVisible(bool visible) {
CallJS("setThrobberVisible", visible);
}
void SyncConsentScreenHandler::Initialize() {} void SyncConsentScreenHandler::Initialize() {}
void SyncConsentScreenHandler::GetAdditionalParameters( void SyncConsentScreenHandler::GetAdditionalParameters(
......
...@@ -28,6 +28,7 @@ class SyncConsentScreenHandler : public BaseScreenHandler, ...@@ -28,6 +28,7 @@ class SyncConsentScreenHandler : public BaseScreenHandler,
void Bind(SyncConsentScreen* screen) override; void Bind(SyncConsentScreen* screen) override;
void Show() override; void Show() override;
void Hide() override; void Hide() override;
void SetThrobberVisible(bool visible) override;
private: private:
// BaseScreenHandler: // BaseScreenHandler:
......
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