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