Commit 890110a2 authored by Julian Watson's avatar Julian Watson Committed by Commit Bot

crostini: show confirmation dialog before starting import

BUG=chromium:978332

Change-Id: I7a2d955990caa7d80ebe48feddf78b4ae8e8cb3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1686969Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Dan Beam <dbeam@chromium.org>
Auto-Submit: Julian Watson <juwa@google.com>
Cr-Commit-Position: refs/heads/master@{#675836}
parent cf1fa051
......@@ -620,6 +620,12 @@
<message name="IDS_SETTINGS_CROSTINI_IMPORT_LABEL" desc="Description shown next to the button to import (restore) Crostini.">
Replace your Linux apps and files with a previous backup
</message>
<message name="IDS_SETTINGS_CROSTINI_CONFIRM_IMPORT_DIALOG_WINDOW_TITLE" desc="Title of the confirmation dialog displayed before container import begins.">
Confirm Restore
</message>
<message name="IDS_SETTINGS_CROSTINI_CONFIRM_IMPORT_DIALOG_WINDOW_MESSAGE" desc="Message of the confirmation dialog displayed before container import begins.">
Restoring will override your existing linux installation. Are you sure you wish to continue?
</message>
<message name="IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LABEL" desc="Label for managing shared USB devices.">
USB preferences
</message>
......
3f3a4b2a98a73d4de6e438e6c91bea5b7c3cb277
\ No newline at end of file
3f3a4b2a98a73d4de6e438e6c91bea5b7c3cb277
\ No newline at end of file
......@@ -3,6 +3,7 @@
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="crostini_browser_proxy.html">
<link rel="import" href="crostini_import_confirmation_dialog.html">
<link rel="import" href="../i18n_setup.html">
<link rel="import" href="../settings_shared_css.html">
......@@ -29,6 +30,11 @@
</cr-button>
</div>
</div>
<template is="dom-if" if="[[showImportConfirmationDialog_]]" restamp>
<settings-crostini-import-confirmation-dialog
on-close="onImportConfirmationDialogClose_">
</settings-crostini-import-confirmation-dialog>
</template>
</template>
<script src="crostini_export_import.js"></script>
</dom-module>
......@@ -11,6 +11,14 @@
Polymer({
is: 'settings-crostini-export-import',
properties: {
/** @private */
showImportConfirmationDialog_: {
type: Boolean,
value: false,
},
},
/** @private */
onExportClick_: function() {
settings.CrostiniBrowserProxyImpl.getInstance().exportCrostiniContainer();
......@@ -18,6 +26,11 @@ Polymer({
/** @private */
onImportClick_: function() {
settings.CrostiniBrowserProxyImpl.getInstance().importCrostiniContainer();
this.showImportConfirmationDialog_ = true;
},
/** @private */
onImportConfirmationDialogClose_: function() {
this.showImportConfirmationDialog_ = false;
},
});
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="crostini_browser_proxy.html">
<link rel="import" href="../settings_shared_css.html">
<dom-module id="settings-crostini-import-confirmation-dialog">
<template>
<style include="settings-shared"></style>
<cr-dialog id="dialog" close-text="$i18n{close}">
<div slot="title">$i18n{crostiniImportConfirmationDialogTitle}</div>
<div slot="body">$i18n{crostiniImportConfirmationDialogMessage}</div>
<div slot="button-container">
<cr-button id="cancel" class="cancel-button"
on-click="onCancelTap_">$i18n{cancel}</cr-button>
<cr-button id="continue" class="action-button"
on-click="onContinueTap_">$i18n{confirm}</cr-button>
</div>
</cr-dialog>
</template>
<script src="crostini_import_confirmation_dialog.js"></script>
</dom-module>
// Copyright 2019 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.
/**
* @fileoverview 'settings-crostini-import-confirmation-dialog' is a component
* warning the user that importing a container overrides the existing container.
* By clicking 'Continue', the user agrees to start the import.
*/
Polymer({
is: 'settings-crostini-import-confirmation-dialog',
/** @override */
attached: function() {
this.$.dialog.showModal();
},
/** @private */
onCancelTap_: function() {
this.$.dialog.close();
},
/** @private */
onContinueTap_: function() {
settings.CrostiniBrowserProxyImpl.getInstance().importCrostiniContainer();
this.$.dialog.close();
},
});
......@@ -1026,6 +1026,12 @@
type="chrome_html"
preprocess="true"
allowexternalscript="true" />
<structure name="IDR_SETTINGS_CROSTINI_IMPORT_CONFIRMATION_DIALOG_HTML"
file="crostini_page/crostini_import_confirmation_dialog.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_CROSTINI_IMPORT_CONFIRMATION_DIALOG_JS"
file="crostini_page/crostini_import_confirmation_dialog.js"
type="chrome_html" />
<structure name="IDR_OS_SETTINGS_BLUETOOTH_DEVICE_LIST_ITEM_HTML"
file="bluetooth_page/bluetooth_device_list_item.html"
type="chrome_html" />
......
......@@ -1362,6 +1362,12 @@
type="chrome_html"
preprocess="true"
allowexternalscript="true" />
<structure name="IDR_SETTINGS_CROSTINI_IMPORT_CONFIRMATION_DIALOG_HTML"
file="crostini_page/crostini_import_confirmation_dialog.html"
type="chrome_html" />
<structure name="IDR_SETTINGS_CROSTINI_IMPORT_CONFIRMATION_DIALOG_JS"
file="crostini_page/crostini_import_confirmation_dialog.js"
type="chrome_html" />
<structure name="IDR_SETTINGS_BLUETOOTH_DEVICE_LIST_ITEM_HTML"
file="bluetooth_page/bluetooth_device_list_item.html"
type="chrome_html" />
......
......@@ -530,6 +530,10 @@ void AddCrostiniStrings(content::WebUIDataSource* html_source,
{"crostiniExportLabel", IDS_SETTINGS_CROSTINI_EXPORT_LABEL},
{"crostiniImport", IDS_SETTINGS_CROSTINI_IMPORT},
{"crostiniImportLabel", IDS_SETTINGS_CROSTINI_IMPORT_LABEL},
{"crostiniImportConfirmationDialogTitle",
IDS_SETTINGS_CROSTINI_CONFIRM_IMPORT_DIALOG_WINDOW_TITLE},
{"crostiniImportConfirmationDialogMessage",
IDS_SETTINGS_CROSTINI_CONFIRM_IMPORT_DIALOG_WINDOW_MESSAGE},
{"crostiniRemoveButton", IDS_SETTINGS_CROSTINI_REMOVE_BUTTON},
{"crostiniSharedUsbDevicesLabel",
IDS_SETTINGS_CROSTINI_SHARED_USB_DEVICES_LABEL},
......
......@@ -135,13 +135,20 @@ suite('CrostiniPageTests', function() {
test('Import', function() {
assertTrue(!!subpage.$$('#crostini-export-import'));
subpage.$$('#crostini-export-import').click();
return flushAsync().then(() => {
subpage = crostiniPage.$$('settings-crostini-export-import');
assertTrue(!!subpage.$$('#import cr-button'));
subpage.$$('#import cr-button').click();
assertEquals(
1, crostiniBrowserProxy.getCallCount('importCrostiniContainer'));
});
return flushAsync()
.then(() => {
subpage = crostiniPage.$$('settings-crostini-export-import');
subpage.$$('#import cr-button').click();
return flushAsync();
})
.then(() => {
subpage =
subpage.$$('settings-crostini-import-confirmation-dialog');
subpage.$$('cr-dialog cr-button[id="continue"]').click();
assertEquals(
1,
crostiniBrowserProxy.getCallCount('importCrostiniContainer'));
});
});
test('Remove', function() {
......
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