Index: chrome/browser/resources/options/import_data_overlay.js |
diff --git a/chrome/browser/resources/options/import_data_overlay.js b/chrome/browser/resources/options/import_data_overlay.js |
index 71c8b42ff2930f70d420fb6f7f320dd1e9c1c08b..cbd9a9df404975684ab8922e7753ef7f2eda214b 100644 |
--- a/chrome/browser/resources/options/import_data_overlay.js |
+++ b/chrome/browser/resources/options/import_data_overlay.js |
@@ -88,10 +88,11 @@ cr.define('options', function() { |
* @private |
*/ |
setControlsSensitive_: function(sensitive) { |
- var checkboxes = |
- document.querySelectorAll('#import-checkboxes input[type=checkbox]'); |
- for (var i = 0; i < checkboxes.length; i++) |
- this.setUpCheckboxState_(checkboxes[i], sensitive); |
+ var importOptions = ['history', 'favorites', 'passwords', 'search']; |
James Hawkins
2011/08/01 19:41:51
Why did you change this? This is fragile and does
simo
2011/08/02 09:08:14
Yes, you're right, I had changed this function aro
|
+ for (var i = 0; i < importOptions.length; i++) { |
+ var checkbox = $('import-' + importOptions[i]); |
+ this.setUpCheckboxState_(checkbox, sensitive); |
+ } |
$('import-data-commit').disabled = !sensitive; |
}, |
@@ -102,8 +103,7 @@ cr.define('options', function() { |
* @private |
*/ |
setUpCheckboxState_: function(checkbox, enabled) { |
- checkbox.disabled = !enabled; |
- checkbox.checked = enabled; |
+ checkbox.setDisabled("noProfileData", !enabled); |
}, |
/** |
@@ -118,8 +118,8 @@ cr.define('options', function() { |
var importOptions = ['history', 'favorites', 'passwords', 'search']; |
for (var i = 0; i < importOptions.length; i++) { |
var checkbox = $('import-' + importOptions[i]); |
- this.setUpCheckboxState_(checkbox, |
- browserProfile ? browserProfile[importOptions[i]] : false); |
+ var enable = browserProfile && browserProfile[importOptions[i]]; |
+ this.setUpCheckboxState_(checkbox, enable); |
} |
}, |
@@ -152,6 +152,25 @@ cr.define('options', function() { |
this.validateCommitButton_(); |
} |
}, |
+ |
+ /** |
+ * Clear import prefs set when user checks/unchecks a checkbox so that each |
+ * checkbox goes back to the default "checked" state (or alternatively, to |
+ * the state set by a recommended policy). |
+ * @private |
+ */ |
+ clearUserPrefs_: function() { |
+ var importPrefs = ['import_history', |
+ 'import_bookmarks', |
+ 'import_saved_passwords', |
+ 'import_search_engine']; |
+ for (var i = 0; i < importPrefs.length; i++) |
+ Preferences.clearPref(importPrefs[i], undefined); |
+ }, |
+ }; |
+ |
+ ImportDataOverlay.clearUserPrefs = function() { |
+ ImportDataOverlay.getInstance().clearUserPrefs_(); |
}; |
/** |
@@ -167,13 +186,15 @@ cr.define('options', function() { |
* @param {boolean} state True if an import operation is in progress. |
*/ |
ImportDataOverlay.setImportingState = function(state) { |
+ var checkboxes = |
+ document.querySelectorAll('#import-checkboxes input[type=checkbox]'); |
if (state) { |
- var checkboxes = |
- document.querySelectorAll('#import-checkboxes input[type=checkbox]'); |
for (var i = 0; i < checkboxes.length; i++) { |
- checkboxes[i].disabled = true; |
+ checkboxes[i].setDisabled("Importing", true); |
} |
} else { |
+ for (var i = 0; i < checkboxes.length; i++) |
+ checkboxes[i].setDisabled("Importing", false); |
ImportDataOverlay.getInstance().updateCheckboxes_(); |
} |
$('import-browsers').disabled = state; |
@@ -185,6 +206,7 @@ cr.define('options', function() { |
* Remove the import overlay from display. |
*/ |
ImportDataOverlay.dismiss = function() { |
+ ImportDataOverlay.clearUserPrefs(); |
OptionsPage.closeOverlay(); |
}; |