| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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-search-engine-entry' is a component for showing a | 6 * @fileoverview 'settings-search-engine-entry' is a component for showing a |
| 7 * search engine with its name, domain and query URL. | 7 * search engine with its name, domain and query URL. |
| 8 * | 8 * |
| 9 * @group Chrome Settings Elements | 9 * @group Chrome Settings Elements |
| 10 * @element settings-search-engine-entry | 10 * @element settings-search-engine-entry |
| 11 */ | 11 */ |
| 12 Polymer({ | 12 Polymer({ |
| 13 is: 'settings-search-engine-entry', | 13 is: 'settings-search-engine-entry', |
| 14 | 14 |
| 15 properties: { | 15 properties: { |
| 16 /** @type {!SearchEngine} */ | 16 /** @type {!SearchEngine} */ |
| 17 engine: Object | 17 engine: Object, |
| 18 |
| 19 /** @private {boolean} */ |
| 20 showEditSearchEngineDialog_: Boolean, |
| 21 }, |
| 22 |
| 23 /** @private {!settings.SearchEnginesBrowserProxy} */ |
| 24 browserProxy_: null, |
| 25 |
| 26 created: function() { |
| 27 this.browserProxy_ = settings.SearchEnginesBrowserProxyImpl.getInstance(); |
| 18 }, | 28 }, |
| 19 | 29 |
| 20 /** @private */ | 30 /** @private */ |
| 21 onDeleteTap_: function() { | 31 onDeleteTap_: function() { |
| 22 chrome.searchEnginesPrivate.removeSearchEngine(this.engine.guid); | 32 this.browserProxy_.removeSearchEngine(this.engine.modelIndex); |
| 23 }, | 33 }, |
| 24 | 34 |
| 25 /** @private */ | 35 /** @private */ |
| 26 onEditTap_: function() { | 36 onEditTap_: function() { |
| 27 // TODO(dpapad): Implement edit mode. | 37 this.closePopupMenu_(); |
| 38 |
| 39 this.showEditSearchEngineDialog_ = true; |
| 40 this.async(function() { |
| 41 var dialog = this.$$('settings-search-engine-dialog'); |
| 42 // Register listener to detect when the dialog is closed. Flip the boolean |
| 43 // once closed to force a restamp next time it is shown such that the |
| 44 // previous dialog's contents are cleared. |
| 45 dialog.addEventListener('iron-overlay-closed', function() { |
| 46 this.showEditSearchEngineDialog_ = false; |
| 47 }.bind(this)); |
| 48 }.bind(this)); |
| 28 }, | 49 }, |
| 29 | 50 |
| 30 /** @private */ | 51 /** @private */ |
| 31 onMakeDefaultTap_: function() { | 52 onMakeDefaultTap_: function() { |
| 32 chrome.searchEnginesPrivate.setSelectedSearchEngine(this.engine.guid); | 53 this.closePopupMenu_(); |
| 33 var popupMenu = this.$$('iron-dropdown'); | 54 this.browserProxy_.setDefaultSearchEngine(this.engine.modelIndex); |
| 34 popupMenu.close(); | 55 }, |
| 56 |
| 57 /** @private */ |
| 58 closePopupMenu_: function() { |
| 59 this.$$('iron-dropdown').close(); |
| 35 }, | 60 }, |
| 36 }); | 61 }); |
| OLD | NEW |