| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 String($('import-history').checked), | 51 String($('import-history').checked), |
| 52 String($('import-favorites').checked), | 52 String($('import-favorites').checked), |
| 53 String($('import-passwords').checked), | 53 String($('import-passwords').checked), |
| 54 String($('import-search').checked)]); | 54 String($('import-search').checked)]); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 $('import-data-cancel').onclick = function() { | 57 $('import-data-cancel').onclick = function() { |
| 58 ImportDataOverlay.dismiss(); | 58 ImportDataOverlay.dismiss(); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 $('import-choose-file').onclick = function() { | |
| 62 chrome.send('chooseBookmarksFile'); | |
| 63 }; | |
| 64 | |
| 65 $('import-data-show-bookmarks-bar').onchange = function() { | 61 $('import-data-show-bookmarks-bar').onchange = function() { |
| 66 // Note: The callback 'toggleShowBookmarksBar' is handled within the | 62 // Note: The callback 'toggleShowBookmarksBar' is handled within the |
| 67 // browser options handler -- rather than the import data handler -- | 63 // browser options handler -- rather than the import data handler -- |
| 68 // as the implementation is shared by several clients. | 64 // as the implementation is shared by several clients. |
| 69 chrome.send('toggleShowBookmarksBar'); | 65 chrome.send('toggleShowBookmarksBar'); |
| 70 } | 66 } |
| 71 | 67 |
| 72 $('import-data-confirm').onclick = function() { | 68 $('import-data-confirm').onclick = function() { |
| 73 ImportDataOverlay.dismiss(); | 69 ImportDataOverlay.dismiss(); |
| 74 }; | 70 }; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 checkbox.setDisabled('noProfileData', !enabled); | 110 checkbox.setDisabled('noProfileData', !enabled); |
| 115 checkbox.checked = enabled; | 111 checkbox.checked = enabled; |
| 116 }, | 112 }, |
| 117 | 113 |
| 118 /** | 114 /** |
| 119 * Update the enabled and checked states of all checkboxes. | 115 * Update the enabled and checked states of all checkboxes. |
| 120 * @private | 116 * @private |
| 121 */ | 117 */ |
| 122 updateCheckboxes_: function() { | 118 updateCheckboxes_: function() { |
| 123 var index = $('import-browsers').selectedIndex; | 119 var index = $('import-browsers').selectedIndex; |
| 124 var bookmarksFileSelected = index == this.browserProfiles.length - 1; | |
| 125 $('import-choose-file').hidden = !bookmarksFileSelected; | |
| 126 $('import-data-commit').hidden = bookmarksFileSelected; | |
| 127 | |
| 128 var browserProfile; | 120 var browserProfile; |
| 129 if (this.browserProfiles.length > index) | 121 if (this.browserProfiles.length > index) |
| 130 browserProfile = this.browserProfiles[index]; | 122 browserProfile = this.browserProfiles[index]; |
| 131 var importOptions = ['history', 'favorites', 'passwords', 'search']; | 123 var importOptions = ['history', 'favorites', 'passwords', 'search']; |
| 132 for (var i = 0; i < importOptions.length; i++) { | 124 for (var i = 0; i < importOptions.length; i++) { |
| 133 var checkbox = $('import-' + importOptions[i]); | 125 var checkbox = $('import-' + importOptions[i]); |
| 134 var enable = browserProfile && browserProfile[importOptions[i]]; | 126 var enable = browserProfile && browserProfile[importOptions[i]]; |
| 135 checkbox.checked = enable; | |
| 136 this.setUpCheckboxState_(checkbox, enable); | 127 this.setUpCheckboxState_(checkbox, enable); |
| 137 var checkboxWithLabel = $('import-' + importOptions[i] + '-with-label'); | 128 var checkboxWithLabel = $('import-' + importOptions[i] + '-with-label'); |
| 138 checkboxWithLabel.style.display = enable ? '' : 'none'; | 129 checkboxWithLabel.style.display = enable ? '' : 'none'; |
| 139 } | 130 } |
| 140 }, | 131 }, |
| 141 | 132 |
| 142 /** | 133 /** |
| 143 * Show or hide gray message at the bottom. | 134 * Show or hide gray message at the bottom. |
| 144 * @private | 135 * @private |
| 145 */ | 136 */ |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 ImportDataOverlay.getInstance().validateCommitButton_(); | 261 ImportDataOverlay.getInstance().validateCommitButton_(); |
| 271 | 262 |
| 272 OptionsPage.navigateToPage('importData'); | 263 OptionsPage.navigateToPage('importData'); |
| 273 }; | 264 }; |
| 274 | 265 |
| 275 // Export | 266 // Export |
| 276 return { | 267 return { |
| 277 ImportDataOverlay: ImportDataOverlay | 268 ImportDataOverlay: ImportDataOverlay |
| 278 }; | 269 }; |
| 279 }); | 270 }); |
| OLD | NEW |