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

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

Issue 1128313004: Convert search_engines_page (and search_engine-adder) to be compatible with Polymer 0.8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 'cr-settings-search-engines-page' is the settings page 6 * @fileoverview 'cr-settings-search-engines-page' is the settings page
7 * containing search engines settings. 7 * containing search engines settings.
8 * 8 *
9 * Example: 9 * Example:
10 * 10 *
11 * <core-animated-pages> 11 * <core-animated-pages>
12 * <cr-settings-search-engines-page prefs="{{prefs}}"> 12 * <cr-settings-search-engines-page prefs="{{prefs}}">
13 * </cr-settings-search-engines-page> 13 * </cr-settings-search-engines-page>
14 * ... other pages ... 14 * ... other pages ...
15 * </core-animated-pages> 15 * </core-animated-pages>
16 * 16 *
17 * @group Chrome Settings Elements 17 * @group Chrome Settings Elements
18 * @element cr-settings-search-engines-page 18 * @element cr-settings-search-engines-page
19 */ 19 */
20 Polymer('cr-settings-search-engines-page', { 20 Polymer({
21 publish: { 21 is: 'cr-settings-search-engines-page',
22
23 properties: {
22 /** 24 /**
23 * Preferences state. 25 * Preferences state.
24 * 26 * @type {?CrSettingsPrefsElement}
25 * @attribute prefs
26 * @type {CrSettingsPrefsElement}
27 * @default null
28 */ 27 */
29 prefs: null, 28 prefs: null,
Jeremy Klein 2015/05/12 21:02:36 Object, notify:true.
Kyle Horimoto 2015/05/12 21:41:52 Done.
30 29
31 /** 30 /**
32 * Route for the page. 31 * Route for the page.
33 *
34 * @attribute route
35 * @type {string} 32 * @type {string}
36 * @default ''
37 */ 33 */
38 route: '', 34 route: {
35 type: String,
36 value: ''
37 },
39 38
40 /** 39 /**
41 * Whether the page is a subpage. 40 * Whether the page is a subpage.
42 *
43 * @attribute subpage
44 * @type {boolean} 41 * @type {boolean}
Jeremy Klein 2015/05/12 21:02:36 nit: Remove unnecessary @type on primitives.
Kyle Horimoto 2015/05/12 21:41:53 Done.
45 * @default true
46 */ 42 */
47 subpage: true, 43 subpage: {
Jeremy Klein 2015/05/12 21:02:36 Make this, PAGE_ID, and icon readOnly: true.
Kyle Horimoto 2015/05/12 21:41:53 Done.
44 type: Boolean,
45 value: true
46 },
48 47
49 /** 48 /**
50 * ID of the page. 49 * ID of the page.
51 *
52 * @attribute PAGE_ID
53 * @const {string} 50 * @const {string}
54 * @default 'search'
55 */ 51 */
56 PAGE_ID: 'search_engines', 52 PAGE_ID: {
53 type: String,
54 value: 'search_engines',
55 readOnly: true
56 },
57 57
58 /** 58 /**
59 * Title for the page header and navigation menu. 59 * Title for the page header and navigation menu.
60 *
61 * @attribute pageTitle
62 * @type {string} 60 * @type {string}
63 */ 61 */
64 pageTitle: loadTimeData.getString('searchEnginesPageTitle'), 62 pageTitle: {
63 type: String,
64 value: loadTimeData.getString('searchEnginesPageTitle')
65 },
65 66
66 /** 67 /**
67 * Name of the 'core-icon' to be shown in the settings-page-header. 68 * Name of the 'core-icon' to be shown in the settings-page-header.
68 *
69 * @attribute icon
70 * @type {string} 69 * @type {string}
71 * @default 'search'
72 */ 70 */
73 icon: 'search', 71 icon: {
72 type: String,
73 value: 'search'
74 },
74 75
75 /** 76 /**
76 * List of default search engines available. 77 * List of default search engines available.
77 * 78 * @type {!Array<!SearchEngine>}
78 * @attribute defaultSearchEngines
79 * @type {Array<!SearchEngine>}
80 * @default null
81 */ 79 */
82 defaultSearchEngines: null, 80 defaultSearchEngines: {
81 type: Array,
82 value: function() { return []; }
83 },
83 84
84 /** 85 /**
85 * List of other search engines available. 86 * List of other search engines available.
86 * 87 * @type {!Array<!SearchEngine>}
87 * @attribute otherSearchEngines
88 * @type {Array<!SearchEngine>}
89 * @default null
90 */ 88 */
91 otherSearchEngines: null, 89 otherSearchEngines: {
90 type: Array,
91 value: function() { return []; }
92 },
92 93
93 /** 94 /**
94 * GUID of the currently selected default search engine. 95 * GUID of the currently selected default search engine.
95 *
96 * @attribute defaultEngineGuid
97 * @type {string} 96 * @type {string}
98 * @default ''
99 */ 97 */
100 defaultEngineGuid: '', 98 defaultEngineGuid: {
99 type: String,
100 value: ''
101 },
101 }, 102 },
102 103
103 /** @override */ 104 /** @override */
104 created: function() {
105 this.searchEngines = [];
106 },
107
108 /** @override */
109 domReady: function() { 105 domReady: function() {
110 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener( 106 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener(
111 this.updateSearchEngines_.bind(this)); 107 this.updateSearchEngines_.bind(this));
112 chrome.searchEnginesPrivate.getSearchEngines( 108 chrome.searchEnginesPrivate.getSearchEngines(
113 this.updateSearchEngines_.bind(this)); 109 this.updateSearchEngines_.bind(this));
114 }, 110 },
115 111
116 /** 112 /**
117 * Persists the new default search engine back to Chrome. Called when the 113 * Persists the new default search engine back to Chrome. Called when the
118 * user selects a new default in the search engines dropdown. 114 * user selects a new default in the search engines dropdown.
119 */ 115 */
120 defaultEngineGuidChanged: function() { 116 defaultEngineGuidChanged: function() {
Jeremy Klein 2015/05/12 21:02:36 Well... Seems like half this file isn't used. Hoor
Kyle Horimoto 2015/05/12 21:41:52 Lame. Added a TODO in the HTML file for Oren to fi
121 chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid); 117 chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid);
122 }, 118 },
123 119
124 120
125 /** 121 /**
126 * Updates the lists of search engines based on the given |engines|. 122 * Updates the lists of search engines based on the given |engines|.
127 * @param {!Array<!SearchEngine>} engines All the search engines. 123 * @param {!Array<!SearchEngine>} engines All the search engines.
128 * @private 124 * @private
129 */ 125 */
130 updateSearchEngines_: function(engines) { 126 updateSearchEngines_: function(engines) {
(...skipping 10 matching lines...) Expand all
141 } else if (engine.type == 137 } else if (engine.type ==
142 chrome.searchEnginesPrivate.SearchEngineType.OTHER) { 138 chrome.searchEnginesPrivate.SearchEngineType.OTHER) {
143 otherEngines.push(engine); 139 otherEngines.push(engine);
144 } 140 }
145 }, this); 141 }, this);
146 142
147 this.defaultSearchEngines = defaultEngines; 143 this.defaultSearchEngines = defaultEngines;
148 this.otherSearchEngines = otherEngines; 144 this.otherSearchEngines = otherEngines;
149 } 145 }
150 }); 146 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698