| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 var Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * ImportDataOverlay class | 10 * ImportDataOverlay class |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 checkboxes[i].customPrefChangeHandler = function(e) { | 43 checkboxes[i].customPrefChangeHandler = function(e) { |
| 44 options.PrefCheckbox.prototype.defaultPrefChangeHandler.call(this, e); | 44 options.PrefCheckbox.prototype.defaultPrefChangeHandler.call(this, e); |
| 45 self.validateCommitButton_(); | 45 self.validateCommitButton_(); |
| 46 return true; | 46 return true; |
| 47 }; | 47 }; |
| 48 } | 48 } |
| 49 | 49 |
| 50 $('import-browsers').onchange = function() { | 50 $('import-browsers').onchange = function() { |
| 51 self.updateCheckboxes_(); | 51 self.updateCheckboxes_(); |
| 52 self.validateCommitButton_(); | 52 self.validateCommitButton_(); |
| 53 self.updateBottomBar_(); | |
| 54 }; | 53 }; |
| 55 | 54 |
| 56 $('import-data-commit').onclick = function() { | 55 $('import-data-commit').onclick = function() { |
| 57 chrome.send('importData', [ | 56 chrome.send('importData', [ |
| 58 String($('import-browsers').selectedIndex), | 57 String($('import-browsers').selectedIndex), |
| 59 String($('import-history').checked), | 58 String($('import-history').checked), |
| 60 String($('import-favorites').checked), | 59 String($('import-favorites').checked), |
| 61 String($('import-passwords').checked), | 60 String($('import-passwords').checked), |
| 62 String($('import-search').checked), | 61 String($('import-search').checked), |
| 63 String($('import-autofill-form-data').checked)]); | 62 String($('import-autofill-form-data').checked)]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 * Sets the enabled state of all the checkboxes and the commit button. | 95 * Sets the enabled state of all the checkboxes and the commit button. |
| 97 * @private | 96 * @private |
| 98 */ | 97 */ |
| 99 setAllControlsEnabled_: function(enabled) { | 98 setAllControlsEnabled_: function(enabled) { |
| 100 var checkboxes = | 99 var checkboxes = |
| 101 document.querySelectorAll('#import-checkboxes input[type=checkbox]'); | 100 document.querySelectorAll('#import-checkboxes input[type=checkbox]'); |
| 102 for (var i = 0; i < checkboxes.length; i++) | 101 for (var i = 0; i < checkboxes.length; i++) |
| 103 this.setUpCheckboxState_(checkboxes[i], enabled); | 102 this.setUpCheckboxState_(checkboxes[i], enabled); |
| 104 $('import-data-commit').disabled = !enabled; | 103 $('import-data-commit').disabled = !enabled; |
| 105 $('import-choose-file').hidden = !enabled; | 104 $('import-choose-file').hidden = !enabled; |
| 106 <if expr="is_macosx"> | |
| 107 $('mac-password-keychain').hidden = !enabled; | |
| 108 </if> | |
| 109 }, | 105 }, |
| 110 | 106 |
| 111 /** | 107 /** |
| 112 * Sets the enabled state of a checkbox element. | 108 * Sets the enabled state of a checkbox element. |
| 113 * @param {Object} checkbox A checkbox element. | 109 * @param {Object} checkbox A checkbox element. |
| 114 * @param {boolean} enabled The enabled state of the checkbox. If false, | 110 * @param {boolean} enabled The enabled state of the checkbox. If false, |
| 115 * the checkbox is disabled. If true, the checkbox is enabled. | 111 * the checkbox is disabled. If true, the checkbox is enabled. |
| 116 * @private | 112 * @private |
| 117 */ | 113 */ |
| 118 setUpCheckboxState_: function(checkbox, enabled) { | 114 setUpCheckboxState_: function(checkbox, enabled) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 139 'autofill-form-data']; | 135 'autofill-form-data']; |
| 140 for (var i = 0; i < importOptions.length; i++) { | 136 for (var i = 0; i < importOptions.length; i++) { |
| 141 var id = 'import-' + importOptions[i]; | 137 var id = 'import-' + importOptions[i]; |
| 142 var enable = browserProfile && browserProfile[importOptions[i]]; | 138 var enable = browserProfile && browserProfile[importOptions[i]]; |
| 143 this.setUpCheckboxState_($(id), enable); | 139 this.setUpCheckboxState_($(id), enable); |
| 144 $(id + '-with-label').hidden = !enable; | 140 $(id + '-with-label').hidden = !enable; |
| 145 } | 141 } |
| 146 }, | 142 }, |
| 147 | 143 |
| 148 /** | 144 /** |
| 149 * Show or hide gray message at the bottom. | |
| 150 * @private | |
| 151 */ | |
| 152 updateBottomBar_: function() { | |
| 153 var index = $('import-browsers').selectedIndex; | |
| 154 var browserProfile; | |
| 155 if (this.browserProfiles.length > index) | |
| 156 browserProfile = this.browserProfiles[index]; | |
| 157 var enable = browserProfile && browserProfile['show_bottom_bar']; | |
| 158 <if expr="is_macosx"> | |
| 159 $('mac-password-keychain').hidden = !enable; | |
| 160 </if> | |
| 161 }, | |
| 162 | |
| 163 /** | |
| 164 * Update the supported browsers popup with given entries. | 145 * Update the supported browsers popup with given entries. |
| 165 * @param {Array} browsers List of supported browsers name. | 146 * @param {Array} browsers List of supported browsers name. |
| 166 * @private | 147 * @private |
| 167 */ | 148 */ |
| 168 updateSupportedBrowsers_: function(browsers) { | 149 updateSupportedBrowsers_: function(browsers) { |
| 169 this.browserProfiles = browsers; | 150 this.browserProfiles = browsers; |
| 170 var browserSelect = $('import-browsers'); | 151 var browserSelect = $('import-browsers'); |
| 171 browserSelect.remove(0); // Remove the 'Loading...' option. | 152 browserSelect.remove(0); // Remove the 'Loading...' option. |
| 172 browserSelect.textContent = ''; | 153 browserSelect.textContent = ''; |
| 173 var browserCount = browsers.length; | 154 var browserCount = browsers.length; |
| 174 | 155 |
| 175 if (browserCount == 0) { | 156 if (browserCount == 0) { |
| 176 var option = new Option(loadTimeData.getString('noProfileFound'), 0); | 157 var option = new Option(loadTimeData.getString('noProfileFound'), 0); |
| 177 browserSelect.appendChild(option); | 158 browserSelect.appendChild(option); |
| 178 | 159 |
| 179 this.setAllControlsEnabled_(false); | 160 this.setAllControlsEnabled_(false); |
| 180 } else { | 161 } else { |
| 181 this.setAllControlsEnabled_(true); | 162 this.setAllControlsEnabled_(true); |
| 182 for (var i = 0; i < browserCount; i++) { | 163 for (var i = 0; i < browserCount; i++) { |
| 183 var browser = browsers[i]; | 164 var browser = browsers[i]; |
| 184 var option = new Option(browser.name, browser.index); | 165 var option = new Option(browser.name, browser.index); |
| 185 browserSelect.appendChild(option); | 166 browserSelect.appendChild(option); |
| 186 } | 167 } |
| 187 | 168 |
| 188 this.updateCheckboxes_(); | 169 this.updateCheckboxes_(); |
| 189 this.validateCommitButton_(); | 170 this.validateCommitButton_(); |
| 190 this.updateBottomBar_(); | |
| 191 } | 171 } |
| 192 }, | 172 }, |
| 193 | 173 |
| 194 /** | 174 /** |
| 195 * Clear import prefs set when user checks/unchecks a checkbox so that each | 175 * Clear import prefs set when user checks/unchecks a checkbox so that each |
| 196 * checkbox goes back to the default "checked" state (or alternatively, to | 176 * checkbox goes back to the default "checked" state (or alternatively, to |
| 197 * the state set by a recommended policy). | 177 * the state set by a recommended policy). |
| 198 * @private | 178 * @private |
| 199 */ | 179 */ |
| 200 clearUserPrefs_: function() { | 180 clearUserPrefs_: function() { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 ImportDataOverlay.getInstance().validateCommitButton_(); | 259 ImportDataOverlay.getInstance().validateCommitButton_(); |
| 280 | 260 |
| 281 PageManager.showPageByName('importData'); | 261 PageManager.showPageByName('importData'); |
| 282 }; | 262 }; |
| 283 | 263 |
| 284 // Export | 264 // Export |
| 285 return { | 265 return { |
| 286 ImportDataOverlay: ImportDataOverlay | 266 ImportDataOverlay: ImportDataOverlay |
| 287 }; | 267 }; |
| 288 }); | 268 }); |
| OLD | NEW |