Commit 4eca71ab authored by Nicholas Hollingum's avatar Nicholas Hollingum Committed by Commit Bot

Reland "Crostini Upgrader: Do not proceed if user cancels backup"

This is a reland of 9b8ade13

Original change's description:
> Crostini Upgrader: Do not proceed if user cancels backup
> 
> Previously if the user cancelled the backup, we would proceed with the
> upgrade as though the user had elected not to backup at all.
> 
> With this change, the flow will instead return to the initial screen
> when the user cancels, rather than proceed.
> 
> Bug: 1061203
> Change-Id: I7be99a2c7a6caa4b5fd143def5ba0c6f9b4d5004
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2102935
> Reviewed-by: Nicholas Verne <nverne@chromium.org>
> Commit-Queue: Nic Hollingum <hollingum@google.com>
> Cr-Commit-Position: refs/heads/master@{#750833}

Bug: 1061203
Change-Id: I983fc82b74db8cba6f2d2acf6997c8d0a2a25bc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2109431Reviewed-by: default avatarNicholas Verne <nverne@chromium.org>
Commit-Queue: Nic Hollingum <hollingum@google.com>
Cr-Commit-Position: refs/heads/master@{#751593}
parent abf8d983
......@@ -123,11 +123,10 @@ void CrostiniUpgrader::StatusTracker::SetStatusDoneUI() {
}
void CrostiniUpgrader::StatusTracker::SetStatusCancelledUI() {
// Successfully canceled backup/restore. Upgrade can continue but we will not
// use that backup to restore from.
if (type() == ExportImportType::EXPORT) {
upgrader_->OnBackup(CrostiniResult::SUCCESS, base::nullopt);
} else {
// Cancelling the restore results in "success" i.e. we successfully didn't try
// to restore. Cancelling the backup is a no-op that returns you to the
// original screen.
if (type() == ExportImportType::IMPORT) {
upgrader_->OnRestore(CrostiniResult::SUCCESS);
}
for (auto& observer : upgrader_->upgrader_observers_) {
......
......@@ -106,7 +106,7 @@ Polymer({
this.listenerIds_ = [
callbackRouter.onBackupProgress.addListener((percent) => {
assert(this.state_ === State.BACKUP);
this.state_ = State.BACKUP;
this.backupProgress_ = percent;
}),
callbackRouter.onBackupSucceeded.addListener((wasCancelled) => {
......@@ -256,7 +256,6 @@ Polymer({
* @private
*/
startBackup_(showFileChooser) {
this.state_ = State.BACKUP;
BrowserProxy.getInstance().handler.backup(showFileChooser);
},
......
......@@ -137,7 +137,11 @@ suite('<crostini-upgrader-app>', () => {
expectFalse(app.$$('#prompt-message').hidden);
expectEquals(fakeBrowserProxy.handler.getCallCount('backup'), 0);
// The page will not register that backup has started until the first
// progress message.
await clickAction();
fakeBrowserProxy.page.onBackupProgress(0);
await flushTasks();
expectFalse(getProgressMessage().hidden);
expectEquals(fakeBrowserProxy.handler.getCallCount('backup'), 1);
expectTrue(getActionButton().hidden);
......@@ -177,7 +181,11 @@ suite('<crostini-upgrader-app>', () => {
expectFalse(app.$$('#prompt-message').hidden);
expectEquals(fakeBrowserProxy.handler.getCallCount('backup'), 0);
// The page will not register that backup has started until the first
// progress message.
await clickAction();
fakeBrowserProxy.page.onBackupProgress(0);
await flushTasks();
expectFalse(getProgressMessage().hidden);
expectEquals(fakeBrowserProxy.handler.getCallCount('backup'), 1);
expectTrue(getActionButton().hidden);
......
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