Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: chrome/browser/resources/options/import_data_overlay.js

Issue 480953002: Implement "Autofill form data" import for Firefox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review feedback (simplify Read method) Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 self.validateCommitButton_(); 42 self.validateCommitButton_();
43 self.updateBottomBar_(); 43 self.updateBottomBar_();
44 }; 44 };
45 45
46 $('import-data-commit').onclick = function() { 46 $('import-data-commit').onclick = function() {
47 chrome.send('importData', [ 47 chrome.send('importData', [
48 String($('import-browsers').selectedIndex), 48 String($('import-browsers').selectedIndex),
49 String($('import-history').checked), 49 String($('import-history').checked),
50 String($('import-favorites').checked), 50 String($('import-favorites').checked),
51 String($('import-passwords').checked), 51 String($('import-passwords').checked),
52 String($('import-search').checked)]); 52 String($('import-search').checked),
53 String($('import-autofill-form-data').checked)]);
53 }; 54 };
54 55
55 $('import-data-cancel').onclick = function() { 56 $('import-data-cancel').onclick = function() {
56 ImportDataOverlay.dismiss(); 57 ImportDataOverlay.dismiss();
57 }; 58 };
58 59
59 $('import-choose-file').onclick = function() { 60 $('import-choose-file').onclick = function() {
60 chrome.send('chooseBookmarksFile'); 61 chrome.send('chooseBookmarksFile');
61 }; 62 };
62 63
63 $('import-data-confirm').onclick = function() { 64 $('import-data-confirm').onclick = function() {
64 ImportDataOverlay.dismiss(); 65 ImportDataOverlay.dismiss();
65 }; 66 };
66 67
67 // Form controls are disabled until the profile list has been loaded. 68 // Form controls are disabled until the profile list has been loaded.
68 self.setAllControlsEnabled_(false); 69 self.setAllControlsEnabled_(false);
69 }, 70 },
70 71
71 /** 72 /**
72 * Sets the enabled and checked state of the commit button. 73 * Sets the enabled and checked state of the commit button.
73 * @private 74 * @private
74 */ 75 */
75 validateCommitButton_: function() { 76 validateCommitButton_: function() {
76 var somethingToImport = 77 var somethingToImport =
77 $('import-history').checked || $('import-favorites').checked || 78 $('import-history').checked || $('import-favorites').checked ||
78 $('import-passwords').checked || $('import-search').checked; 79 $('import-passwords').checked || $('import-search').checked ||
80 $('import-autofill-form-data').checked;
79 $('import-data-commit').disabled = !somethingToImport; 81 $('import-data-commit').disabled = !somethingToImport;
80 $('import-choose-file').disabled = !$('import-favorites').checked; 82 $('import-choose-file').disabled = !$('import-favorites').checked;
81 }, 83 },
82 84
83 /** 85 /**
84 * Sets the enabled state of all the checkboxes and the commit button. 86 * Sets the enabled state of all the checkboxes and the commit button.
85 * @private 87 * @private
86 */ 88 */
87 setAllControlsEnabled_: function(enabled) { 89 setAllControlsEnabled_: function(enabled) {
88 var checkboxes = 90 var checkboxes =
(...skipping 24 matching lines...) Expand all
113 */ 115 */
114 updateCheckboxes_: function() { 116 updateCheckboxes_: function() {
115 var index = $('import-browsers').selectedIndex; 117 var index = $('import-browsers').selectedIndex;
116 var bookmarksFileSelected = index == this.browserProfiles.length - 1; 118 var bookmarksFileSelected = index == this.browserProfiles.length - 1;
117 $('import-choose-file').hidden = !bookmarksFileSelected; 119 $('import-choose-file').hidden = !bookmarksFileSelected;
118 $('import-data-commit').hidden = bookmarksFileSelected; 120 $('import-data-commit').hidden = bookmarksFileSelected;
119 121
120 var browserProfile; 122 var browserProfile;
121 if (this.browserProfiles.length > index) 123 if (this.browserProfiles.length > index)
122 browserProfile = this.browserProfiles[index]; 124 browserProfile = this.browserProfiles[index];
123 var importOptions = ['history', 'favorites', 'passwords', 'search']; 125 var importOptions = ['history',
126 'favorites',
127 'passwords',
128 'search',
129 'autofill-form-data'];
124 for (var i = 0; i < importOptions.length; i++) { 130 for (var i = 0; i < importOptions.length; i++) {
125 var checkbox = $('import-' + importOptions[i]); 131 var checkbox = $('import-' + importOptions[i]);
126 var enable = browserProfile && browserProfile[importOptions[i]]; 132 var enable = browserProfile && browserProfile[importOptions[i]];
127 this.setUpCheckboxState_(checkbox, enable); 133 this.setUpCheckboxState_(checkbox, enable);
128 var checkboxWithLabel = $('import-' + importOptions[i] + '-with-label'); 134 var checkboxWithLabel = $('import-' + importOptions[i] + '-with-label');
129 checkboxWithLabel.style.display = enable ? '' : 'none'; 135 checkboxWithLabel.style.display = enable ? '' : 'none';
130 } 136 }
131 }, 137 },
132 138
133 /** 139 /**
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 /** 185 /**
180 * Clear import prefs set when user checks/unchecks a checkbox so that each 186 * Clear import prefs set when user checks/unchecks a checkbox so that each
181 * checkbox goes back to the default "checked" state (or alternatively, to 187 * checkbox goes back to the default "checked" state (or alternatively, to
182 * the state set by a recommended policy). 188 * the state set by a recommended policy).
183 * @private 189 * @private
184 */ 190 */
185 clearUserPrefs_: function() { 191 clearUserPrefs_: function() {
186 var importPrefs = ['import_history', 192 var importPrefs = ['import_history',
187 'import_bookmarks', 193 'import_bookmarks',
188 'import_saved_passwords', 194 'import_saved_passwords',
189 'import_search_engine']; 195 'import_search_engine',
196 'import_autofill_form_data'];
190 for (var i = 0; i < importPrefs.length; i++) 197 for (var i = 0; i < importPrefs.length; i++)
191 Preferences.clearPref(importPrefs[i], true); 198 Preferences.clearPref(importPrefs[i], true);
192 }, 199 },
193 200
194 /** 201 /**
195 * Update the dialog layout to reflect success state. 202 * Update the dialog layout to reflect success state.
196 * @param {boolean} success If true, show success dialog elements. 203 * @param {boolean} success If true, show success dialog elements.
197 * @private 204 * @private
198 */ 205 */
199 updateSuccessState_: function(success) { 206 updateSuccessState_: function(success) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 ImportDataOverlay.getInstance().validateCommitButton_(); 270 ImportDataOverlay.getInstance().validateCommitButton_();
264 271
265 PageManager.showPageByName('importData'); 272 PageManager.showPageByName('importData');
266 }; 273 };
267 274
268 // Export 275 // Export
269 return { 276 return {
270 ImportDataOverlay: ImportDataOverlay 277 ImportDataOverlay: ImportDataOverlay
271 }; 278 };
272 }); 279 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/import_data_overlay.html ('k') | chrome/browser/ui/browser_ui_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698