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

Side by Side Diff: chrome/browser/resources/settings/search_engines_page/search_engines_page.js

Issue 2300633006: MD Settings: Search Engine: Call iron-list notifyResize (Closed)
Patch Set: . Created 4 years, 3 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 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-engines-page' is the settings page 6 * @fileoverview 'settings-search-engines-page' is the settings page
7 * containing search engines settings. 7 * containing search engines settings.
8 */ 8 */
9 Polymer({ 9 Polymer({
10 is: 'settings-search-engines-page', 10 is: 'settings-search-engines-page',
11 11
12 behaviors: [WebUIListenerBehavior], 12 behaviors: [WebUIListenerBehavior],
13 13
14 properties: { 14 properties: {
15 /** @type {!Array<!SearchEngine>} */ 15 /** @type {!Array<!SearchEngine>} */
16 defaultEngines: { 16 defaultEngines: {
17 type: Array, 17 type: Array,
18 value: function() { return []; } 18 value: function() {
19 return [];
20 },
19 }, 21 },
20 22
21 /** @type {!Array<!SearchEngine>} */ 23 /** @type {!Array<!SearchEngine>} */
22 otherEngines: { 24 otherEngines: {
23 type: Array, 25 type: Array,
24 value: function() { return []; } 26 value: function() {
27 return [];
28 },
25 }, 29 },
26 30
27 /** @type {!Array<!SearchEngine>} */ 31 /** @type {!Array<!SearchEngine>} */
28 extensions: { 32 extensions: {
29 type: Array, 33 type: Array,
30 value: function() { return []; } 34 value: function() {
35 return [];
36 },
31 }, 37 },
32 38
33 /** @private {boolean} */ 39 /** @private {boolean} */
34 showAddSearchEngineDialog_: Boolean, 40 showAddSearchEngineDialog_: Boolean,
35 41
36 /** @private {boolean} */ 42 /** @private {boolean} */
37 showExtensionsList_: { 43 showExtensionsList_: {
38 type: Boolean, 44 type: Boolean,
39 computed: 'computeShowExtensionsList_(extensions)', 45 computed: 'computeShowExtensionsList_(extensions)',
40 } 46 }
41 }, 47 },
42 48
49 observers: ['extensionsChanged_(extensions, showExtensionsList_)'],
50
43 /** @override */ 51 /** @override */
44 ready: function() { 52 ready: function() {
45 settings.SearchEnginesBrowserProxyImpl.getInstance(). 53 settings.SearchEnginesBrowserProxyImpl.getInstance()
46 getSearchEnginesList().then(this.enginesChanged_.bind(this)); 54 .getSearchEnginesList()
dschuyler 2016/09/01 23:21:50 nit: How about moving this line up with the line a
55 .then(this.enginesChanged_.bind(this));
47 this.addWebUIListener( 56 this.addWebUIListener(
48 'search-engines-changed', this.enginesChanged_.bind(this)); 57 'search-engines-changed', this.enginesChanged_.bind(this));
49 }, 58 },
50 59
60 /** @private */
61 extensionsChanged_: function() {
62 if (this.showExtensionsList_)
63 this.$.extensions.notifyResize();
64 },
65
51 /** 66 /**
52 * @param {!SearchEnginesInfo} searchEnginesInfo 67 * @param {!SearchEnginesInfo} searchEnginesInfo
53 * @private 68 * @private
54 */ 69 */
55 enginesChanged_: function(searchEnginesInfo) { 70 enginesChanged_: function(searchEnginesInfo) {
56 this.defaultEngines = searchEnginesInfo['defaults']; 71 this.defaultEngines = searchEnginesInfo['defaults'];
57 this.otherEngines = searchEnginesInfo['others']; 72 this.otherEngines = searchEnginesInfo['others'];
58 this.extensions = searchEnginesInfo['extensions']; 73 this.extensions = searchEnginesInfo['extensions'];
Dan Beam 2016/09/02 00:41:11 doesn't this already accomplish what you're doing
Dan Beam 2016/09/02 00:42:19 oh, nevermind, this is when the list is unhidden.
59 }, 74 },
60 75
61 /** @private */ 76 /** @private */
62 onAddSearchEngineTap_: function() { 77 onAddSearchEngineTap_: function() {
63 this.showAddSearchEngineDialog_ = true; 78 this.showAddSearchEngineDialog_ = true;
64 this.async(function() { 79 this.async(function() {
65 var dialog = this.$$('settings-search-engine-dialog'); 80 var dialog = this.$$('settings-search-engine-dialog');
66 // Register listener to detect when the dialog is closed. Flip the boolean 81 // Register listener to detect when the dialog is closed. Flip the boolean
67 // once closed to force a restamp next time it is shown such that the 82 // once closed to force a restamp next time it is shown such that the
68 // previous dialog's contents are cleared. 83 // previous dialog's contents are cleared.
69 dialog.addEventListener('close', function() { 84 dialog.addEventListener('close', function() {
70 this.showAddSearchEngineDialog_ = false; 85 this.showAddSearchEngineDialog_ = false;
71 }.bind(this)); 86 }.bind(this));
72 }.bind(this)); 87 }.bind(this));
73 }, 88 },
74 89
75 /** @private */ 90 /** @private */
76 computeShowExtensionsList_: function() { 91 computeShowExtensionsList_: function() {
77 return this.extensions.length > 0; 92 return this.extensions.length > 0;
78 }, 93 },
79 }); 94 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698