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 '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: { |
29 type: Object, | |
30 notify: true | |
31 }, | |
30 | 32 |
31 /** | 33 /** |
32 * Route for the page. | 34 * Route for the page. |
33 * | |
34 * @attribute route | |
35 * @type {string} | |
36 * @default '' | |
37 */ | 35 */ |
38 route: '', | 36 route: { |
37 type: String, | |
38 value: '' | |
39 }, | |
39 | 40 |
40 /** | 41 /** |
41 * Whether the page is a subpage. | 42 * Whether the page is a subpage. |
42 * | |
43 * @attribute subpage | |
44 * @type {boolean} | |
45 * @default true | |
46 */ | 43 */ |
47 subpage: true, | 44 subpage: { |
45 type: Boolean, | |
46 value: true, | |
47 readOnly: true | |
48 }, | |
48 | 49 |
49 /** | 50 /** |
50 * ID of the page. | 51 * ID of the page. |
51 * | |
52 * @attribute PAGE_ID | |
53 * @const {string} | |
54 * @default 'search' | |
55 */ | 52 */ |
56 PAGE_ID: 'search_engines', | 53 PAGE_ID: { |
54 type: String, | |
55 value: 'search_engines', | |
56 readOnly: true | |
57 }, | |
57 | 58 |
58 /** | 59 /** |
59 * Title for the page header and navigation menu. | 60 * Title for the page header and navigation menu. |
60 * | |
61 * @attribute pageTitle | |
62 * @type {string} | |
63 */ | 61 */ |
64 pageTitle: loadTimeData.getString('searchEnginesPageTitle'), | 62 pageTitle: { |
63 type: String, | |
64 value: loadTimeData.getString('searchEnginesPageTitle'), | |
65 readOnly: true | |
66 }, | |
65 | 67 |
66 /** | 68 /** |
67 * Name of the 'core-icon' to be shown in the settings-page-header. | 69 * Name of the 'core-icon' to be shown in the settings-page-header. |
68 * | |
69 * @attribute icon | |
70 * @type {string} | |
71 * @default 'search' | |
72 */ | 70 */ |
73 icon: 'search', | 71 icon: { |
72 type: String, | |
73 value: 'search', | |
74 readOnly: true | |
75 }, | |
74 | 76 |
75 /** | 77 /** |
76 * List of default search engines available. | 78 * List of default search engines available. |
77 * | 79 * @type {!Array<!SearchEngine>} |
78 * @attribute defaultSearchEngines | |
79 * @type {Array<!SearchEngine>} | |
80 * @default null | |
81 */ | 80 */ |
82 defaultSearchEngines: null, | 81 defaultSearchEngines: { |
82 type: Array, | |
83 value: function() { return []; } | |
84 }, | |
83 | 85 |
84 /** | 86 /** |
85 * List of other search engines available. | 87 * List of other search engines available. |
86 * | 88 * @type {!Array<!SearchEngine>} |
87 * @attribute otherSearchEngines | |
88 * @type {Array<!SearchEngine>} | |
89 * @default null | |
90 */ | 89 */ |
91 otherSearchEngines: null, | 90 otherSearchEngines: { |
91 type: Array, | |
92 value: function() { return []; } | |
93 }, | |
92 | 94 |
93 /** | 95 /** |
94 * GUID of the currently selected default search engine. | 96 * GUID of the currently selected default search engine. |
95 * | |
96 * @attribute defaultEngineGuid | |
97 * @type {string} | |
98 * @default '' | |
99 */ | 97 */ |
100 defaultEngineGuid: '', | 98 defaultEngineGuid: { |
99 type: String, | |
100 value: '', | |
101 observer: 'deafultEngineGuidChanged' | |
102 }, | |
101 }, | 103 }, |
102 | 104 |
103 /** @override */ | 105 /** @override */ |
104 created: function() { | |
105 this.searchEngines = []; | |
106 }, | |
107 | |
108 /** @override */ | |
109 domReady: function() { | 106 domReady: function() { |
Jeremy Klein
2015/05/13 00:19:54
I'm still in favor of killing all this dead code..
Kyle Horimoto
2015/05/13 02:38:28
Meh, I'll keep this in just because I know Oren wi
Jeremy Klein
2015/05/13 02:40:15
He won't need this. It's literally exactly the sam
Kyle Horimoto
2015/05/13 02:58:46
Done.
| |
110 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener( | 107 chrome.searchEnginesPrivate.onSearchEnginesChanged.addListener( |
111 this.updateSearchEngines_.bind(this)); | 108 this.updateSearchEngines_.bind(this)); |
112 chrome.searchEnginesPrivate.getSearchEngines( | 109 chrome.searchEnginesPrivate.getSearchEngines( |
113 this.updateSearchEngines_.bind(this)); | 110 this.updateSearchEngines_.bind(this)); |
114 }, | 111 }, |
115 | 112 |
116 /** | 113 /** |
117 * Persists the new default search engine back to Chrome. Called when the | 114 * Persists the new default search engine back to Chrome. Called when the |
118 * user selects a new default in the search engines dropdown. | 115 * user selects a new default in the search engines dropdown. |
119 */ | 116 */ |
120 defaultEngineGuidChanged: function() { | 117 defaultEngineGuidChanged: function() { |
121 chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid); | 118 chrome.searchEnginesPrivate.setSelectedSearchEngine(this.defaultEngineGuid); |
122 }, | 119 }, |
123 | 120 |
124 | |
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) { |
131 var defaultEngines = []; | 127 var defaultEngines = []; |
132 var otherEngines = []; | 128 var otherEngines = []; |
133 | 129 |
134 engines.forEach(function(engine) { | 130 engines.forEach(function(engine) { |
135 if (engine.type == | 131 if (engine.type == |
136 chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) { | 132 chrome.searchEnginesPrivate.SearchEngineType.DEFAULT) { |
137 defaultEngines.push(engine); | 133 defaultEngines.push(engine); |
138 if (engine.isSelected) { | 134 if (engine.isSelected) { |
139 this.defaultEngineGuid = engine.guid; | 135 this.defaultEngineGuid = engine.guid; |
140 } | 136 } |
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 }); |
OLD | NEW |