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 OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 | 7 |
8 /** | 8 /** |
9 * ImportDataOverlay class | 9 * ImportDataOverlay class |
10 * Encapsulated handling of the 'Import Data' overlay page. | 10 * Encapsulated handling of the 'Import Data' overlay page. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 var option = new Option(browser['name'], browser['index']); | 146 var option = new Option(browser['name'], browser['index']); |
147 browserSelect.appendChild(option); | 147 browserSelect.appendChild(option); |
148 } | 148 } |
149 | 149 |
150 this.updateCheckboxes_(); | 150 this.updateCheckboxes_(); |
151 this.validateCommitButton_(); | 151 this.validateCommitButton_(); |
152 } | 152 } |
153 }, | 153 }, |
154 | 154 |
155 /** | 155 /** |
156 * Clear import prefs set when user checks/unchecks a checkbox so that each | 156 * Clear import prefs set when user checks/unchecks a checkbox so that each |
157 * checkbox goes back to the default "checked" state (or alternatively, to | 157 * checkbox goes back to the default "checked" state (or alternatively, to |
158 * the state set by a recommended policy). | 158 * the state set by a recommended policy). |
159 * @private | 159 * @private |
160 */ | 160 */ |
161 clearUserPrefs_: function() { | 161 clearUserPrefs_: function() { |
162 var importPrefs = ['import_history', | 162 var importPrefs = ['import_history', |
163 'import_bookmarks', | 163 'import_bookmarks', |
164 'import_saved_passwords', | 164 'import_saved_passwords', |
165 'import_search_engine']; | 165 'import_search_engine']; |
166 for (var i = 0; i < importPrefs.length; i++) | 166 for (var i = 0; i < importPrefs.length; i++) |
167 Preferences.clearPref(importPrefs[i], undefined); | 167 Preferences.clearPref(importPrefs[i], undefined); |
168 }, | 168 }, |
| 169 |
| 170 /** |
| 171 * Update the dialog layout to reflect success state. |
| 172 * @param {boolean} success If true, show success dialog elements. |
| 173 * @private |
| 174 */ |
| 175 updateSuccessState_: function(success) { |
| 176 var sections = document.querySelectorAll('.import-data-configure'); |
| 177 for (var i = 0; i < sections.length; i++) |
| 178 sections[i].hidden = success; |
| 179 |
| 180 sections = document.querySelectorAll('.import-data-success'); |
| 181 for (var i = 0; i < sections.length; i++) |
| 182 sections[i].hidden = !success; |
| 183 }, |
169 }; | 184 }; |
170 | 185 |
171 ImportDataOverlay.clearUserPrefs = function() { | 186 ImportDataOverlay.clearUserPrefs = function() { |
172 ImportDataOverlay.getInstance().clearUserPrefs_(); | 187 ImportDataOverlay.getInstance().clearUserPrefs_(); |
173 }; | 188 }; |
174 | 189 |
175 /** | 190 /** |
176 * Update the supported browsers popup with given entries. | 191 * Update the supported browsers popup with given entries. |
177 * @param {array} list of supported browsers name. | 192 * @param {array} list of supported browsers name. |
178 */ | 193 */ |
(...skipping 24 matching lines...) Expand all Loading... |
203 ImportDataOverlay.clearUserPrefs(); | 218 ImportDataOverlay.clearUserPrefs(); |
204 OptionsPage.closeOverlay(); | 219 OptionsPage.closeOverlay(); |
205 }; | 220 }; |
206 | 221 |
207 /** | 222 /** |
208 * Show a message confirming the success of the import operation. | 223 * Show a message confirming the success of the import operation. |
209 */ | 224 */ |
210 ImportDataOverlay.confirmSuccess = function() { | 225 ImportDataOverlay.confirmSuccess = function() { |
211 var showBookmarksMessage = $('import-favorites').checked; | 226 var showBookmarksMessage = $('import-favorites').checked; |
212 ImportDataOverlay.setImportingState(false); | 227 ImportDataOverlay.setImportingState(false); |
213 $('import-data-configure').hidden = true; | |
214 $('import-data-success').hidden = false; | |
215 $('import-find-your-bookmarks').hidden = !showBookmarksMessage; | 228 $('import-find-your-bookmarks').hidden = !showBookmarksMessage; |
| 229 ImportDataOverlay.getInstance().updateSuccessState_(true); |
| 230 }; |
| 231 |
| 232 /** |
| 233 * Show the import data overlay. |
| 234 */ |
| 235 ImportDataOverlay.show = function() { |
| 236 // Make sure that any previous import success message is hidden, and |
| 237 // we're showing the UI to import further data. |
| 238 ImportDataOverlay.getInstance().updateSuccessState_(false); |
| 239 |
| 240 OptionsPage.navigateToPage('importData'); |
216 }; | 241 }; |
217 | 242 |
218 // Export | 243 // Export |
219 return { | 244 return { |
220 ImportDataOverlay: ImportDataOverlay | 245 ImportDataOverlay: ImportDataOverlay |
221 }; | 246 }; |
222 }); | 247 }); |
OLD | NEW |