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

Side by Side Diff: chrome/browser/resources/settings/people_page/import_data_dialog.js

Issue 2727513002: Revert of MD Settings: Stop using prefs to populate import data dialog. (Closed)
Patch Set: Created 3 years, 9 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 /** 5 /**
6 * @fileoverview 'settings-import-data-dialog' is a component for importing 6 * @fileoverview 'settings-import-data-dialog' is a component for importing
7 * bookmarks and other data from other sources. 7 * bookmarks and other data from other sources.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-import-data-dialog', 10 is: 'settings-import-data-dialog',
11 11
12 behaviors: [I18nBehavior, WebUIListenerBehavior], 12 behaviors: [I18nBehavior, WebUIListenerBehavior, PrefsBehavior],
13 13
14 properties: { 14 properties: {
15 /** @private {!Array<!settings.BrowserProfile>} */ 15 /** @private {!Array<!settings.BrowserProfile>} */
16 browserProfiles_: Array, 16 browserProfiles_: Array,
17 17
18 /** @private {!settings.BrowserProfile} */ 18 /** @private {!settings.BrowserProfile} */
19 selected_: Object, 19 selected_: Object,
20 20
21 /** 21 /**
22 * Whether none of the import data categories is selected. 22 * Whether none of the import data categories is selected.
(...skipping 11 matching lines...) Expand all
34 }, 34 },
35 35
36 /** 36 /**
37 * Mirroring the enum so that it can be used from HTML bindings. 37 * Mirroring the enum so that it can be used from HTML bindings.
38 * @private 38 * @private
39 */ 39 */
40 importStatusEnum_: { 40 importStatusEnum_: {
41 type: Object, 41 type: Object,
42 value: settings.ImportDataStatus, 42 value: settings.ImportDataStatus,
43 }, 43 },
44 },
44 45
45 /** @private */ 46 observers: [
46 showBookmarkSuccess_: Boolean, 47 'prefsChanged_(selected_, prefs.*)',
47 }, 48 ],
48 49
49 /** @private {?settings.ImportDataBrowserProxy} */ 50 /** @private {?settings.ImportDataBrowserProxy} */
50 browserProxy_: null, 51 browserProxy_: null,
51 52
52 /** @override */ 53 /** @override */
53 attached: function() { 54 attached: function() {
54 this.browserProxy_ = settings.ImportDataBrowserProxyImpl.getInstance(); 55 this.browserProxy_ = settings.ImportDataBrowserProxyImpl.getInstance();
55 this.browserProxy_.initializeImportDialog().then( 56 this.browserProxy_.initializeImportDialog().then(
56 /** @param {!Array<!settings.BrowserProfile>} data */ 57 /** @param {!Array<!settings.BrowserProfile>} data */
57 function(data) { 58 function(data) {
58 this.browserProfiles_ = data; 59 this.browserProfiles_ = data;
59 this.selected_ = this.browserProfiles_[0]; 60 this.selected_ = this.browserProfiles_[0];
60 61
61 // Show the dialog only after the browser profiles data is populated 62 // Show the dialog only after the browser profiles data is populated
62 // to avoid UI flicker. 63 // to avoid UI flicker.
63 this.$.dialog.showModal(); 64 this.$.dialog.showModal();
64 }.bind(this)); 65 }.bind(this));
65 66
66 this.addWebUIListener( 67 this.addWebUIListener(
67 'import-data-status-changed', 68 'import-data-status-changed',
68 /** @param {settings.ImportDataStatus} importStatus */ 69 /** @param {settings.ImportDataStatus} importStatus */
69 function(importStatus) { 70 function(importStatus) {
70 this.importStatus_ = importStatus; 71 this.importStatus_ = importStatus;
71 if (this.hasImportStatus_(settings.ImportDataStatus.SUCCEEDED)) {
72 this.showBookmarkSuccess_ =
73 this.$.favorites.checked && this.selected_.favorites;
74 }
75
76 if (this.hasImportStatus_(settings.ImportDataStatus.FAILED)) 72 if (this.hasImportStatus_(settings.ImportDataStatus.FAILED))
77 this.closeDialog_(); 73 this.closeDialog_();
78 }.bind(this)); 74 }.bind(this));
79 }, 75 },
80 76
81 /** @private */ 77 /** @private */
82 onCheckboxChange_: function() { 78 prefsChanged_: function() {
83 this.noImportDataTypeSelected_ = 79 this.noImportDataTypeSelected_ =
84 !(this.selected_.history && this.$.history.checked) && 80 !(this.getPref('import_history').value && this.selected_.history) &&
85 !(this.selected_.favorites && this.$.favorites.checked) && 81 !(this.getPref('import_bookmarks').value && this.selected_.favorites) &&
86 !(this.selected_.passwords && this.$.passwords.checked) && 82 !(this.getPref('import_saved_passwords').value &&
87 !(this.selected_.search && this.$.search.checked) && 83 this.selected_.passwords) &&
88 !(this.selected_.autofillFormData && this.$.autofillFormData.checked); 84 !(this.getPref('import_search_engine').value &&
85 this.selected_.search) &&
86 !(this.getPref('import_autofill_form_data').value &&
87 this.selected_.autofillFormData);
89 }, 88 },
90 89
91 /** 90 /**
92 * @param {!settings.ImportDataStatus} status 91 * @param {!settings.ImportDataStatus} status
93 * @return {boolean} Whether |status| is the current status. 92 * @return {boolean} Whether |status| is the current status.
94 * @private 93 * @private
95 */ 94 */
96 hasImportStatus_: function(status) { 95 hasImportStatus_: function(status) {
97 return this.importStatus_ == status; 96 return this.importStatus_ == status;
98 }, 97 },
(...skipping 10 matching lines...) Expand all
109 * @private 108 * @private
110 */ 109 */
111 getActionButtonText_: function() { 110 getActionButtonText_: function() {
112 return this.i18n(this.isImportFromFileSelected_() ? 111 return this.i18n(this.isImportFromFileSelected_() ?
113 'importChooseFile' : 'importCommit'); 112 'importChooseFile' : 'importCommit');
114 }, 113 },
115 114
116 /** @private */ 115 /** @private */
117 onBrowserProfileSelectionChange_: function() { 116 onBrowserProfileSelectionChange_: function() {
118 this.selected_ = this.browserProfiles_[this.$.browserSelect.selectedIndex]; 117 this.selected_ = this.browserProfiles_[this.$.browserSelect.selectedIndex];
119 this.onCheckboxChange_();
120 }, 118 },
121 119
122 /** @private */ 120 /** @private */
123 onActionButtonTap_: function() { 121 onActionButtonTap_: function() {
124 if (this.isImportFromFileSelected_()) 122 if (this.isImportFromFileSelected_())
125 this.browserProxy_.importFromBookmarksFile(); 123 this.browserProxy_.importFromBookmarksFile();
126 else 124 else
127 this.browserProxy_.importData(this.$.browserSelect.selectedIndex); 125 this.browserProxy_.importData(this.$.browserSelect.selectedIndex);
128 }, 126 },
129 127
130 /** @private */ 128 /** @private */
131 closeDialog_: function() { 129 closeDialog_: function() {
132 this.$.dialog.close(); 130 this.$.dialog.close();
133 }, 131 },
134 132
135 /** 133 /**
136 * @return {boolean} Whether the import button should be disabled. 134 * @return {boolean} Whether the import button should be disabled.
137 * @private 135 * @private
138 */ 136 */
139 shouldDisableImport_: function() { 137 shouldDisableImport_: function() {
140 return this.hasImportStatus_(settings.ImportDataStatus.IN_PROGRESS) || 138 return this.hasImportStatus_(settings.ImportDataStatus.IN_PROGRESS) ||
141 this.noImportDataTypeSelected_; 139 this.noImportDataTypeSelected_;
142 }, 140 },
143 }); 141 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698