Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * @fileoverview 'settings-import-data-dialog' is a component for importing | |
| 7 * bookmarks and other data from other sources. | |
| 8 */ | |
| 9 Polymer({ | |
| 10 is: 'settings-import-data-dialog', | |
| 11 | |
| 12 behaviors: [I18nBehavior, WebUIListenerBehavior], | |
| 13 | |
| 14 properties: { | |
| 15 /** @private {!Array<!settings.BrowserProfile>} */ | |
| 16 browserProfiles_: Array, | |
| 17 | |
| 18 /** @private {!settings.BrowserProfile} */ | |
| 19 selected_: Object, | |
|
Dan Beam
2016/11/14 22:06:51
can we change this from a set of booleans to just
dpapad
2016/11/14 22:19:30
My plan was to investigate the prefs involved in f
dpapad
2016/11/14 23:18:03
Done, I added this in this CL. Checkboxes are now
| |
| 20 }, | |
| 21 | |
| 22 /** @private {?settings.ImportDataBrowserProxy} */ | |
| 23 browserProxy_: null, | |
| 24 | |
| 25 /** @override */ | |
| 26 attached: function() { | |
| 27 this.browserProxy_ = settings.ImportDataBrowserProxyImpl.getInstance(); | |
| 28 this.browserProxy_.initializeImportDialog().then(function(data) { | |
| 29 this.browserProfiles_ = data; | |
| 30 this.selected_ = this.browserProfiles_[0]; | |
| 31 }.bind(this)); | |
| 32 | |
| 33 this.addWebUIListener('import-data-status-changed', function(e) { | |
| 34 // TODO(dpapad): Handle events to show spinner or success message. | |
| 35 }); | |
| 36 | |
| 37 this.$.dialog.showModal(); | |
| 38 }, | |
| 39 | |
| 40 /** @private */ | |
| 41 isImportFromFileSelected_: function() { | |
| 42 // The last entry in |browserProfiles_| always refers to dummy profile for | |
| 43 // importing from a bookmarks file. | |
| 44 return this.selected_.index == this.browserProfiles_.length - 1; | |
| 45 }, | |
| 46 | |
| 47 /** | |
| 48 * @return {string} | |
| 49 * @private | |
| 50 */ | |
| 51 getActionButtonText_: function() { | |
| 52 return this.i18n(this.isImportFromFileSelected_() ? | |
| 53 'importChooseFile' : 'importCommit'); | |
| 54 }, | |
| 55 | |
| 56 /** @private */ | |
| 57 onChange_: function() { | |
| 58 this.selected_ = this.browserProfiles_[this.$.browserSelect.selectedIndex]; | |
| 59 }, | |
| 60 | |
| 61 /** @private */ | |
| 62 onActionButtonTap_: function() { | |
| 63 if (this.isImportFromFileSelected_()) { | |
| 64 this.browserProxy_.importFromBookmarksFile(); | |
| 65 } else { | |
| 66 // TODO(dpapad): Implement this. | |
| 67 } | |
| 68 }, | |
| 69 | |
| 70 /** @private */ | |
| 71 onCancelTap_: function() { | |
| 72 this.$.dialog.close(); | |
| 73 }, | |
| 74 }); | |
| OLD | NEW |