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', function() { | 5 cr.define('options', function() { |
6 /** @const */ var Page = cr.ui.pageManager.Page; | 6 /** @const */ var Page = cr.ui.pageManager.Page; |
7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; | 7 /** @const */ var PageManager = cr.ui.pageManager.PageManager; |
8 | 8 |
9 /** | 9 /** |
10 * Encapsulated handling of a search bubble. | 10 * Encapsulated handling of a search bubble. |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 * Update the UI to reflect whether we are in a search state. | 180 * Update the UI to reflect whether we are in a search state. |
181 * @param {boolean} active True if we are on the search page. | 181 * @param {boolean} active True if we are on the search page. |
182 * @private | 182 * @private |
183 */ | 183 */ |
184 setSearchActive_: function(active) { | 184 setSearchActive_: function(active) { |
185 // It's fine to exit if search wasn't active and we're not going to | 185 // It's fine to exit if search wasn't active and we're not going to |
186 // activate it now. | 186 // activate it now. |
187 if (!this.searchActive_ && !active) | 187 if (!this.searchActive_ && !active) |
188 return; | 188 return; |
189 | 189 |
190 // Guest users should never have active search | |
Evan Stade
2014/08/19 17:49:13
nit: final punctuation
Mike Lerman
2014/08/19 20:34:12
Done.
| |
191 if (loadTimeData.getBoolean('profileIsGuest')) | |
192 return; | |
193 | |
190 this.searchActive_ = active; | 194 this.searchActive_ = active; |
191 | 195 |
192 if (active) { | 196 if (active) { |
193 var hash = location.hash; | 197 var hash = location.hash; |
194 if (hash) { | 198 if (hash) { |
195 this.searchField.value = | 199 this.searchField.value = |
196 decodeURIComponent(hash.slice(1).replace(/\+/g, ' ')); | 200 decodeURIComponent(hash.slice(1).replace(/\+/g, ' ')); |
197 } else if (!this.searchField.value) { | 201 } else if (!this.searchField.value) { |
198 // This should only happen if the user goes directly to | 202 // This should only happen if the user goes directly to |
199 // chrome://settings-frame/search | 203 // chrome://settings-frame/search |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
253 } | 257 } |
254 } | 258 } |
255 }, | 259 }, |
256 | 260 |
257 /** | 261 /** |
258 * Set the current search criteria. | 262 * Set the current search criteria. |
259 * @param {string} text Search text. | 263 * @param {string} text Search text. |
260 * @private | 264 * @private |
261 */ | 265 */ |
262 setSearchText_: function(text) { | 266 setSearchText_: function(text) { |
267 // Guest users should never have search text. | |
268 if (loadTimeData.getBoolean('profileIsGuest')) | |
269 return; | |
270 | |
263 // Prevent recursive execution of this method. | 271 // Prevent recursive execution of this method. |
264 if (this.insideSetSearchText_) return; | 272 if (this.insideSetSearchText_) return; |
265 this.insideSetSearchText_ = true; | 273 this.insideSetSearchText_ = true; |
266 | 274 |
267 // Cleanup the search query string. | 275 // Cleanup the search query string. |
268 text = SearchPage.canonicalizeQuery(text); | 276 text = SearchPage.canonicalizeQuery(text); |
269 | 277 |
270 // Set the hash on the current page, and the enclosing uber page. Only do | 278 // Set the hash on the current page, and the enclosing uber page. Only do |
271 // this if the page is not current. See https://crbug.com/401004. | 279 // this if the page is not current. See https://crbug.com/401004. |
272 var hash = text ? '#' + encodeURIComponent(text) : ''; | 280 var hash = text ? '#' + encodeURIComponent(text) : ''; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
568 // Trim beginning and ending whitespace. | 576 // Trim beginning and ending whitespace. |
569 return text.replace(/^\s+|\s+$/g, ''); | 577 return text.replace(/^\s+|\s+$/g, ''); |
570 }; | 578 }; |
571 | 579 |
572 // Export | 580 // Export |
573 return { | 581 return { |
574 SearchPage: SearchPage | 582 SearchPage: SearchPage |
575 }; | 583 }; |
576 | 584 |
577 }); | 585 }); |
OLD | NEW |