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, | |
| 20 }, | |
| 21 | |
| 22 /** @private {?settings.ImportDataBrowserProxy} */ | |
| 23 browserProxy_: null, | |
| 24 | |
| 25 /** @override */ | |
| 26 attached: function() { | |
| 27 this.$.dialog.showModal(); | |
| 28 }, | |
| 29 | |
| 30 /** @override */ | |
| 31 ready: function() { | |
|
tommycli
2016/11/14 18:15:57
nit: but when is the earliest that we could do thi
dpapad
2016/11/14 20:35:22
No good reason. Moved to attached.
| |
| 32 this.browserProxy_ = settings.ImportDataBrowserProxyImpl.getInstance(); | |
| 33 this.browserProxy_.initializeImportDialog().then(function(data) { | |
| 34 this.browserProfiles_ = data; | |
| 35 // TODO(dpapad): Check old options to determine whether it is possible | |
| 36 // that no browser profile is found (including the "import from file" | |
| 37 // option). | |
| 38 this.selected_ = this.browserProfiles_[0]; | |
| 39 }.bind(this)); | |
| 40 | |
| 41 this.addWebUIListener('import-data-status-changed', function(e) { | |
| 42 // TODO(dpapad): Handle events to show spinner or success message. | |
| 43 }); | |
| 44 }, | |
| 45 | |
| 46 /** @private */ | |
| 47 isImportFromFileSelected_: function() { | |
| 48 return this.selected_.index == this.browserProfiles_.length - 1; | |
|
tommycli
2016/11/14 18:15:57
The last item in the list of browser profiles is a
dpapad
2016/11/14 20:35:22
Did not look at the C++, but the old JS code impli
tommycli
2016/11/14 20:45:34
Hmm interesting. Maybe investigate and add a comme
dpapad
2016/11/14 21:47:57
Done. The answer is that the last browser profile
| |
| 49 }, | |
| 50 | |
| 51 /** | |
| 52 * @return {string} | |
| 53 * @private | |
| 54 */ | |
| 55 getActionButtonText_: function() { | |
| 56 return this.i18n(this.isImportFromFileSelected_() ? | |
| 57 'importChooseFile' : 'importCommit'); | |
| 58 }, | |
| 59 | |
| 60 /** @private */ | |
| 61 onChange_: function() { | |
| 62 this.selected_ = this.browserProfiles_[this.$$('select').selectedIndex]; | |
|
tommycli
2016/11/14 18:15:57
Maybe marginally faster to use event.target.value
dpapad
2016/11/14 20:35:22
In order to associate event.target.value with a se
| |
| 63 }, | |
| 64 | |
| 65 /** @private */ | |
| 66 onActionButtonTap_: function() { | |
| 67 if (this.isImportFromFileSelected_()) { | |
| 68 this.browserProxy_.importFromBookmarksFile(); | |
| 69 } else { | |
| 70 // TODO(dpapad): Implement this. | |
| 71 } | |
| 72 }, | |
| 73 | |
| 74 /** @private */ | |
| 75 onCancelTap_: function() { | |
| 76 this.$.dialog.close(); | |
| 77 }, | |
| 78 }); | |
| OLD | NEW |