OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 cr.define('options.search_engines', function() { | 5 cr.define('options.search_engines', function() { |
6 /** @const */ var ControlledSettingIndicator = | 6 /** @const */ var ControlledSettingIndicator = |
7 options.ControlledSettingIndicator; | 7 options.ControlledSettingIndicator; |
8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; | 8 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; |
9 /** @const */ var InlineEditableItem = options.InlineEditableItem; | 9 /** @const */ var InlineEditableItem = options.InlineEditableItem; |
10 /** @const */ var ListSelectionController = cr.ui.ListSelectionController; | 10 /** @const */ var ListSelectionController = cr.ui.ListSelectionController; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 nameColEl.appendChild(nameEl); | 109 nameColEl.appendChild(nameEl); |
110 | 110 |
111 // Then the keyword column. | 111 // Then the keyword column. |
112 var keywordEl = this.createEditableTextCell(engine.keyword); | 112 var keywordEl = this.createEditableTextCell(engine.keyword); |
113 keywordEl.className = 'keyword-column'; | 113 keywordEl.className = 'keyword-column'; |
114 keywordEl.classList.add('weakrtl'); | 114 keywordEl.classList.add('weakrtl'); |
115 this.contentElement.appendChild(keywordEl); | 115 this.contentElement.appendChild(keywordEl); |
116 | 116 |
117 // And the URL column. | 117 // And the URL column. |
118 var urlEl = this.createEditableTextCell(engine.url); | 118 var urlEl = this.createEditableTextCell(engine.url); |
119 var urlWithButtonEl = this.ownerDocument.createElement('div'); | 119 // Extensions should not display a URL column. |
120 urlWithButtonEl.appendChild(urlEl); | 120 if (!engine.isExtension) { |
121 urlWithButtonEl.className = 'url-column'; | 121 var urlWithButtonEl = this.ownerDocument.createElement('div'); |
122 urlWithButtonEl.classList.add('weakrtl'); | 122 urlWithButtonEl.appendChild(urlEl); |
123 this.contentElement.appendChild(urlWithButtonEl); | 123 urlWithButtonEl.className = 'url-column'; |
124 // Add the Make Default button. Temporary until drag-and-drop re-ordering | 124 urlWithButtonEl.classList.add('weakrtl'); |
125 // is implemented. When this is removed, remove the extra div above. | 125 this.contentElement.appendChild(urlWithButtonEl); |
126 if (engine.canBeDefault) { | 126 // Add the Make Default button. Temporary until drag-and-drop |
127 var makeDefaultButtonEl = this.ownerDocument.createElement('button'); | 127 // re-ordering is implemented. When this is removed, remove the extra |
128 makeDefaultButtonEl.className = 'custom-appearance list-inline-button'; | 128 // div above. |
129 makeDefaultButtonEl.textContent = | 129 if (engine.canBeDefault) { |
130 loadTimeData.getString('makeDefaultSearchEngineButton'); | 130 var makeDefaultButtonEl = this.ownerDocument.createElement('button'); |
131 makeDefaultButtonEl.onclick = function(e) { | 131 makeDefaultButtonEl.className = |
132 chrome.send('managerSetDefaultSearchEngine', [engine.modelIndex]); | 132 'custom-appearance list-inline-button'; |
133 }; | 133 makeDefaultButtonEl.textContent = |
134 // Don't select the row when clicking the button. | 134 loadTimeData.getString('makeDefaultSearchEngineButton'); |
135 makeDefaultButtonEl.onmousedown = function(e) { | 135 makeDefaultButtonEl.onclick = function(e) { |
136 e.stopPropagation(); | 136 chrome.send('managerSetDefaultSearchEngine', [engine.modelIndex]); |
137 }; | 137 }; |
138 urlWithButtonEl.appendChild(makeDefaultButtonEl); | 138 // Don't select the row when clicking the button. |
| 139 makeDefaultButtonEl.onmousedown = function(e) { |
| 140 e.stopPropagation(); |
| 141 }; |
| 142 urlWithButtonEl.appendChild(makeDefaultButtonEl); |
| 143 } |
139 } | 144 } |
140 | 145 |
141 // Do final adjustment to the input fields. | 146 // Do final adjustment to the input fields. |
142 this.nameField_ = nameEl.querySelector('input'); | 147 this.nameField_ = nameEl.querySelector('input'); |
143 // The editable field uses the raw name, not the display name. | 148 // The editable field uses the raw name, not the display name. |
144 this.nameField_.value = engine.name; | 149 this.nameField_.value = engine.name; |
145 this.keywordField_ = keywordEl.querySelector('input'); | 150 this.keywordField_ = keywordEl.querySelector('input'); |
146 this.urlField_ = urlEl.querySelector('input'); | 151 this.urlField_ = urlEl.querySelector('input'); |
147 | 152 |
148 if (engine.urlLocked) | 153 if (engine.urlLocked) |
149 this.urlField_.disabled = true; | 154 this.urlField_.disabled = true; |
150 | 155 |
| 156 if (engine.isExtension) |
| 157 this.nameField_.disabled = true; |
| 158 |
151 if (this.isPlaceholder) { | 159 if (this.isPlaceholder) { |
152 this.nameField_.placeholder = | 160 this.nameField_.placeholder = |
153 loadTimeData.getString('searchEngineTableNamePlaceholder'); | 161 loadTimeData.getString('searchEngineTableNamePlaceholder'); |
154 this.keywordField_.placeholder = | 162 this.keywordField_.placeholder = |
155 loadTimeData.getString('searchEngineTableKeywordPlaceholder'); | 163 loadTimeData.getString('searchEngineTableKeywordPlaceholder'); |
156 this.urlField_.placeholder = | 164 this.urlField_.placeholder = |
157 loadTimeData.getString('searchEngineTableURLPlaceholder'); | 165 loadTimeData.getString('searchEngineTableURLPlaceholder'); |
158 } | 166 } |
159 | 167 |
160 var fields = [this.nameField_, this.keywordField_, this.urlField_]; | 168 var fields = [this.nameField_, this.keywordField_, this.urlField_]; |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 }, | 326 }, |
319 }; | 327 }; |
320 | 328 |
321 // Export | 329 // Export |
322 return { | 330 return { |
323 SearchEngineList: SearchEngineList | 331 SearchEngineList: SearchEngineList |
324 }; | 332 }; |
325 | 333 |
326 }); | 334 }); |
327 | 335 |
OLD | NEW |