OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 OptionsPage = options.OptionsPage; | 6 const OptionsPage = options.OptionsPage; |
7 const ArrayDataModel = cr.ui.ArrayDataModel; | 7 const ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 8 |
9 // | 9 // |
10 // BrowserOptions class | 10 // BrowserOptions class |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 // Ensure that changes are committed when closing the page. | 106 // Ensure that changes are committed when closing the page. |
107 window.addEventListener('unload', function() { | 107 window.addEventListener('unload', function() { |
108 if (document.activeElement == homepageField) | 108 if (document.activeElement == homepageField) |
109 homepageField.blur(); | 109 homepageField.blur(); |
110 }); | 110 }); |
111 | 111 |
112 if (!cr.isChromeOS) { | 112 if (!cr.isChromeOS) { |
113 $('defaultBrowserUseAsDefaultButton').onclick = function(event) { | 113 $('defaultBrowserUseAsDefaultButton').onclick = function(event) { |
114 chrome.send('becomeDefaultBrowser'); | 114 chrome.send('becomeDefaultBrowser'); |
115 }; | 115 }; |
| 116 |
| 117 $('autoLaunch').addEventListener('click', |
| 118 this.handleAutoLaunchChanged_); |
116 } | 119 } |
117 | 120 |
118 var startupPagesList = $('startupPagesList'); | 121 var startupPagesList = $('startupPagesList'); |
119 options.browser_options.StartupPageList.decorate(startupPagesList); | 122 options.browser_options.StartupPageList.decorate(startupPagesList); |
120 startupPagesList.autoExpands = true; | 123 startupPagesList.autoExpands = true; |
121 | 124 |
122 // Check if we are in the guest mode. | 125 // Check if we are in the guest mode. |
123 if (cr.commandLine && cr.commandLine.options['--bwsi']) { | 126 if (cr.commandLine && cr.commandLine.options['--bwsi']) { |
124 // Hide the startup section. | 127 // Hide the startup section. |
125 $('startupSection').hidden = true; | 128 $('startupSection').hidden = true; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 startupPagesList.disabled = disable; | 278 startupPagesList.disabled = disable; |
276 startupPagesList.setAttribute('tabindex', disable ? -1 : 0); | 279 startupPagesList.setAttribute('tabindex', disable ? -1 : 0); |
277 // Explicitly set disabled state for input text elements. | 280 // Explicitly set disabled state for input text elements. |
278 var inputs = startupPagesList.querySelectorAll("input[type='text']"); | 281 var inputs = startupPagesList.querySelectorAll("input[type='text']"); |
279 for (var i = 0; i < inputs.length; i++) | 282 for (var i = 0; i < inputs.length; i++) |
280 inputs[i].disabled = disable; | 283 inputs[i].disabled = disable; |
281 $('startupUseCurrentButton').disabled = disable; | 284 $('startupUseCurrentButton').disabled = disable; |
282 }, | 285 }, |
283 | 286 |
284 /** | 287 /** |
285 * Handle change events of the preference | 288 * Handles change events of the preference |
286 * 'session.urls_to_restore_on_startup'. | 289 * 'session.urls_to_restore_on_startup'. |
287 * @param {event} preference changed event. | 290 * @param {event} preference changed event. |
288 * @private | 291 * @private |
289 */ | 292 */ |
290 handleStartupPageListChange_: function(event) { | 293 handleStartupPageListChange_: function(event) { |
291 this.startup_pages_pref_.disabled = event.value['disabled']; | 294 this.startup_pages_pref_.disabled = event.value['disabled']; |
292 this.updateCustomStartupPageControlStates_(); | 295 this.updateCustomStartupPageControlStates_(); |
293 }, | 296 }, |
294 | 297 |
295 /** | 298 /** |
296 * Set the default search engine based on the popup selection. | 299 * Sets the default search engine based on the popup selection. |
297 */ | 300 */ |
298 setDefaultSearchEngine_: function() { | 301 setDefaultSearchEngine_: function() { |
299 var engineSelect = $('defaultSearchEngine'); | 302 var engineSelect = $('defaultSearchEngine'); |
300 var selectedIndex = engineSelect.selectedIndex; | 303 var selectedIndex = engineSelect.selectedIndex; |
301 if (selectedIndex >= 0) { | 304 if (selectedIndex >= 0) { |
302 var selection = engineSelect.options[selectedIndex]; | 305 var selection = engineSelect.options[selectedIndex]; |
303 chrome.send('setDefaultSearchEngine', [String(selection.value)]); | 306 chrome.send('setDefaultSearchEngine', [String(selection.value)]); |
304 } | 307 } |
305 }, | 308 }, |
306 | 309 |
307 /** | 310 /** |
| 311 * Sets or clear whether Chrome should Auto-launch on computer startup. |
| 312 */ |
| 313 handleAutoLaunchChanged_: function() { |
| 314 chrome.send('toggleAutoLaunch', [Boolean($('autoLaunch').checked)]); |
| 315 }, |
| 316 |
| 317 /** |
308 * Sends an asynchronous request for new autocompletion suggestions for the | 318 * Sends an asynchronous request for new autocompletion suggestions for the |
309 * the given query. When new suggestions are available, the C++ handler will | 319 * the given query. When new suggestions are available, the C++ handler will |
310 * call updateAutocompleteSuggestions_. | 320 * call updateAutocompleteSuggestions_. |
311 * @param {string} query List of autocomplete suggestions. | 321 * @param {string} query List of autocomplete suggestions. |
312 * @private | 322 * @private |
313 */ | 323 */ |
314 requestAutocompleteSuggestions_: function(query) { | 324 requestAutocompleteSuggestions_: function(query) { |
315 chrome.send('requestAutocompleteSuggestions', [query]); | 325 chrome.send('requestAutocompleteSuggestions', [query]); |
316 }, | 326 }, |
317 | 327 |
318 /** | 328 /** |
319 * Updates the autocomplete suggestion list with the given entries. | 329 * Updates the autocomplete suggestion list with the given entries. |
320 * @param {Array} pages List of autocomplete suggestions. | 330 * @param {Array} pages List of autocomplete suggestions. |
321 * @private | 331 * @private |
322 */ | 332 */ |
323 updateAutocompleteSuggestions_: function(suggestions) { | 333 updateAutocompleteSuggestions_: function(suggestions) { |
324 var list = this.autocompleteList_; | 334 var list = this.autocompleteList_; |
325 // If the trigger for this update was a value being selected from the | 335 // If the trigger for this update was a value being selected from the |
326 // current list, do nothing. | 336 // current list, do nothing. |
327 if (list.targetInput && list.selectedItem && | 337 if (list.targetInput && list.selectedItem && |
328 list.selectedItem['url'] == list.targetInput.value) | 338 list.selectedItem['url'] == list.targetInput.value) |
329 return; | 339 return; |
330 list.suggestions = suggestions; | 340 list.suggestions = suggestions; |
331 }, | 341 }, |
| 342 |
| 343 /** |
| 344 * Shows the autoLaunch preference and initializes its checkbox value. |
| 345 */ |
| 346 updateAutoLaunchState_: function(enabled) { |
| 347 $('autoLaunchOption').hidden = false; |
| 348 $('autoLaunch').checked = enabled; |
| 349 }, |
332 }; | 350 }; |
333 | 351 |
334 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault, | 352 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault, |
335 canBeDefault) { | 353 canBeDefault) { |
336 if (!cr.isChromeOS) { | 354 if (!cr.isChromeOS) { |
337 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString, | 355 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString, |
338 isDefault, | 356 isDefault, |
339 canBeDefault); | 357 canBeDefault); |
340 } | 358 } |
341 }; | 359 }; |
342 | 360 |
343 BrowserOptions.updateSearchEngines = function(engines, defaultValue, | 361 BrowserOptions.updateSearchEngines = function(engines, defaultValue, |
344 defaultManaged) { | 362 defaultManaged) { |
345 BrowserOptions.getInstance().updateSearchEngines_(engines, defaultValue, | 363 BrowserOptions.getInstance().updateSearchEngines_(engines, defaultValue, |
346 defaultManaged); | 364 defaultManaged); |
347 }; | 365 }; |
348 | 366 |
349 BrowserOptions.updateStartupPages = function(pages) { | 367 BrowserOptions.updateStartupPages = function(pages) { |
350 BrowserOptions.getInstance().updateStartupPages_(pages); | 368 BrowserOptions.getInstance().updateStartupPages_(pages); |
351 }; | 369 }; |
352 | 370 |
353 BrowserOptions.updateAutocompleteSuggestions = function(suggestions) { | 371 BrowserOptions.updateAutocompleteSuggestions = function(suggestions) { |
354 BrowserOptions.getInstance().updateAutocompleteSuggestions_(suggestions); | 372 BrowserOptions.getInstance().updateAutocompleteSuggestions_(suggestions); |
355 }; | 373 }; |
356 | 374 |
| 375 BrowserOptions.updateAutoLaunchState = function(enabled) { |
| 376 BrowserOptions.getInstance().updateAutoLaunchState_(enabled); |
| 377 }; |
| 378 |
357 BrowserOptions.setInstantFieldTrialStatus = function(enabled) { | 379 BrowserOptions.setInstantFieldTrialStatus = function(enabled) { |
358 BrowserOptions.getInstance().setInstantFieldTrialStatus_(enabled); | 380 BrowserOptions.getInstance().setInstantFieldTrialStatus_(enabled); |
359 }; | 381 }; |
360 | 382 |
361 // Export | 383 // Export |
362 return { | 384 return { |
363 BrowserOptions: BrowserOptions | 385 BrowserOptions: BrowserOptions |
364 }; | 386 }; |
365 | 387 |
366 }); | 388 }); |
OLD | NEW |