Commit ca595a12 authored by gajendra.n's avatar gajendra.n Committed by Commit bot

[MAC] Disable 'Import' button when visible checkboxes are unchecked.

In "Import bookmarks and settings" overlay, 'Import' button is disabled when
no checkboxes are checked. But for 'Safari' only 2 checkboxes are shown;
when other checkboxes are checked in background(not shown), it causes the button
to always be enabled regardless of visible checkboxes checked or unchecked.
This CL checks if a checkbox is both shown and checked, to enable the button.

BUG=275265
R=dbeam@chromium.org

TEST=
1.Launch chrome ,go to settings and click on 'Import bookmarks and settings' button under 'Users' section.
2.Select 'Safari' and Uncheck 'Browsing history' and 'Favorites/Bookmarks' option .
3.Observe the 'Import' button. The 'Import' button should be disabled.

Review URL: https://codereview.chromium.org/636933002

Cr-Commit-Position: refs/heads/master@{#299840}
parent 12c60083
......@@ -20,6 +20,14 @@ cr.define('options', function() {
cr.addSingletonGetter(ImportDataOverlay);
/**
* @param {string} type The type of data to import. Used in the element's ID.
*/
function importable(type) {
var id = 'import-' + type;
return $(id).checked && !$(id + '-with-label').hidden;
}
ImportDataOverlay.prototype = {
// Inherit from Page.
__proto__: Page.prototype,
......@@ -75,9 +83,9 @@ cr.define('options', function() {
*/
validateCommitButton_: function() {
var somethingToImport =
$('import-history').checked || $('import-favorites').checked ||
$('import-passwords').checked || $('import-search').checked ||
$('import-autofill-form-data').checked;
importable('history') || importable('favorites') ||
importable('passwords') || importable('search') ||
importable('autofill-form-data');
$('import-data-commit').disabled = !somethingToImport;
$('import-choose-file').disabled = !$('import-favorites').checked;
},
......@@ -128,11 +136,10 @@ cr.define('options', function() {
'search',
'autofill-form-data'];
for (var i = 0; i < importOptions.length; i++) {
var checkbox = $('import-' + importOptions[i]);
var id = 'import-' + importOptions[i];
var enable = browserProfile && browserProfile[importOptions[i]];
this.setUpCheckboxState_(checkbox, enable);
var checkboxWithLabel = $('import-' + importOptions[i] + '-with-label');
checkboxWithLabel.style.display = enable ? '' : 'none';
this.setUpCheckboxState_($(id), enable);
$(id + '-with-label').hidden = !enable;
}
},
......
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