OLD | NEW |
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', |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 observers: [ | 46 observers: [ |
47 'prefsChanged_(selected_, prefs.*)', | 47 'prefsChanged_(selected_, prefs.*)', |
48 ], | 48 ], |
49 | 49 |
50 /** @private {?settings.ImportDataBrowserProxy} */ | 50 /** @private {?settings.ImportDataBrowserProxy} */ |
51 browserProxy_: null, | 51 browserProxy_: null, |
52 | 52 |
53 /** @override */ | 53 /** @override */ |
54 attached: function() { | 54 attached: function() { |
55 this.browserProxy_ = settings.ImportDataBrowserProxyImpl.getInstance(); | 55 this.browserProxy_ = settings.ImportDataBrowserProxyImpl.getInstance(); |
56 this.browserProxy_.initializeImportDialog().then( | 56 this.browserProxy_.initializeImportDialog().then(data => { |
57 /** @param {!Array<!settings.BrowserProfile>} data */ | 57 this.browserProfiles_ = data; |
58 function(data) { | 58 this.selected_ = this.browserProfiles_[0]; |
59 this.browserProfiles_ = data; | |
60 this.selected_ = this.browserProfiles_[0]; | |
61 | 59 |
62 // Show the dialog only after the browser profiles data is populated | 60 // Show the dialog only after the browser profiles data is populated |
63 // to avoid UI flicker. | 61 // to avoid UI flicker. |
64 this.$.dialog.showModal(); | 62 this.$.dialog.showModal(); |
65 }.bind(this)); | 63 }); |
66 | 64 |
67 this.addWebUIListener( | 65 this.addWebUIListener('import-data-status-changed', importStatus => { |
68 'import-data-status-changed', | 66 this.importStatus_ = importStatus; |
69 /** @param {settings.ImportDataStatus} importStatus */ | 67 if (this.hasImportStatus_(settings.ImportDataStatus.FAILED)) |
70 function(importStatus) { | 68 this.closeDialog_(); |
71 this.importStatus_ = importStatus; | 69 }); |
72 if (this.hasImportStatus_(settings.ImportDataStatus.FAILED)) | |
73 this.closeDialog_(); | |
74 }.bind(this)); | |
75 }, | 70 }, |
76 | 71 |
77 /** @private */ | 72 /** @private */ |
78 prefsChanged_: function() { | 73 prefsChanged_: function() { |
79 this.noImportDataTypeSelected_ = | 74 this.noImportDataTypeSelected_ = |
80 !(this.getPref('import_dialog_history').value && | 75 !(this.getPref('import_dialog_history').value && |
81 this.selected_.history) && | 76 this.selected_.history) && |
82 !(this.getPref('import_dialog_bookmarks').value && | 77 !(this.getPref('import_dialog_bookmarks').value && |
83 this.selected_.favorites) && | 78 this.selected_.favorites) && |
84 !(this.getPref('import_dialog_saved_passwords').value && | 79 !(this.getPref('import_dialog_saved_passwords').value && |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 129 |
135 /** | 130 /** |
136 * @return {boolean} Whether the import button should be disabled. | 131 * @return {boolean} Whether the import button should be disabled. |
137 * @private | 132 * @private |
138 */ | 133 */ |
139 shouldDisableImport_: function() { | 134 shouldDisableImport_: function() { |
140 return this.hasImportStatus_(settings.ImportDataStatus.IN_PROGRESS) || | 135 return this.hasImportStatus_(settings.ImportDataStatus.IN_PROGRESS) || |
141 this.noImportDataTypeSelected_; | 136 this.noImportDataTypeSelected_; |
142 }, | 137 }, |
143 }); | 138 }); |
OLD | NEW |