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() {
}
shown_ = true;
if (behavior_ == SyncScreenBehavior::SHOW) {
view_->Show();
} else {
// Wait for updates if not shown.
if (behavior_ != SyncScreenBehavior::SHOW) {
// Wait for updates and set the loading throbber to be visible.
view_->SetThrobberVisible(true /*visible*/);
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() {
......@@ -152,7 +155,7 @@ void SyncConsentScreen::UpdateScreen() {
Finish(ScreenExitCode::SYNC_CONSENT_FINISHED);
if (behavior_ == SyncScreenBehavior::SHOW) {
view_->Show();
view_->SetThrobberVisible(false /*visible*/);
GetSyncService(profile_)->RemoveObserver(this);
}
}
......
......@@ -27,6 +27,10 @@ class SyncConsentScreenView {
// Hides the contents of the screen.
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
......
<!-- Copyright 2017 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<link rel="import" href="chrome://oobe/custom_elements.html">
<div class="step right hidden" id="sync-consent" hidden>
<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>
......@@ -8,7 +8,7 @@
login.createScreen('SyncConsentScreen', 'sync-consent', function() {
return {
EXTERNAL_API: ['onUserSyncPrefsKnown'],
EXTERNAL_API: ['onUserSyncPrefsKnown', 'setThrobberVisible'],
/**
* Returns the control which should receive initial focus.
......@@ -25,6 +25,13 @@ login.createScreen('SyncConsentScreen', 'sync-consent', function() {
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.
*/
......@@ -40,5 +47,14 @@ login.createScreen('SyncConsentScreen', 'sync-consent', function() {
onUserSyncPrefsKnown: function(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() {
void SyncConsentScreenHandler::Hide() {}
void SyncConsentScreenHandler::SetThrobberVisible(bool visible) {
CallJS("setThrobberVisible", visible);
}
void SyncConsentScreenHandler::Initialize() {}
void SyncConsentScreenHandler::GetAdditionalParameters(
......
......@@ -28,6 +28,7 @@ class SyncConsentScreenHandler : public BaseScreenHandler,
void Bind(SyncConsentScreen* screen) override;
void Show() override;
void Hide() override;
void SetThrobberVisible(bool visible) override;
private:
// 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