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

Side by Side Diff: chrome/browser/resources/options/browser_options.js

Issue 8729009: Implement an AutoLaunch experiment for Chrome for certain brand codes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
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
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.options['--bwsi']) { 126 if (cr.commandLine.options['--bwsi']) {
124 // Hide the startup section. 127 // Hide the startup section.
125 $('startupSection').hidden = true; 128 $('startupSection').hidden = true;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 var startupPagesList = $('startupPagesList'); 277 var startupPagesList = $('startupPagesList');
275 startupPagesList.disabled = disable; 278 startupPagesList.disabled = disable;
276 // Explicitly set disabled state for input text elements. 279 // Explicitly set disabled state for input text elements.
277 var inputs = startupPagesList.querySelectorAll("input[type='text']"); 280 var inputs = startupPagesList.querySelectorAll("input[type='text']");
278 for (var i = 0; i < inputs.length; i++) 281 for (var i = 0; i < inputs.length; i++)
279 inputs[i].disabled = disable; 282 inputs[i].disabled = disable;
280 $('startupUseCurrentButton').disabled = disable; 283 $('startupUseCurrentButton').disabled = disable;
281 }, 284 },
282 285
283 /** 286 /**
284 * Handle change events of the preference 287 * Handles change events of the preference
285 * 'session.urls_to_restore_on_startup'. 288 * 'session.urls_to_restore_on_startup'.
286 * @param {event} preference changed event. 289 * @param {event} preference changed event.
287 * @private 290 * @private
288 */ 291 */
289 handleStartupPageListChange_: function(event) { 292 handleStartupPageListChange_: function(event) {
290 this.startup_pages_pref_.controlledBy = event.value['controlledBy']; 293 this.startup_pages_pref_.controlledBy = event.value['controlledBy'];
291 this.updateCustomStartupPageControlStates_(); 294 this.updateCustomStartupPageControlStates_();
292 }, 295 },
293 296
294 /** 297 /**
295 * Set the default search engine based on the popup selection. 298 * Sets the default search engine based on the popup selection.
296 */ 299 */
297 setDefaultSearchEngine_: function() { 300 setDefaultSearchEngine_: function() {
298 var engineSelect = $('defaultSearchEngine'); 301 var engineSelect = $('defaultSearchEngine');
299 var selectedIndex = engineSelect.selectedIndex; 302 var selectedIndex = engineSelect.selectedIndex;
300 if (selectedIndex >= 0) { 303 if (selectedIndex >= 0) {
301 var selection = engineSelect.options[selectedIndex]; 304 var selection = engineSelect.options[selectedIndex];
302 chrome.send('setDefaultSearchEngine', [String(selection.value)]); 305 chrome.send('setDefaultSearchEngine', [String(selection.value)]);
303 } 306 }
304 }, 307 },
305 308
306 /** 309 /**
310 * Sets or clear whether Chrome should Auto-launch on computer startup.
311 */
312 handleAutoLaunchChanged_: function() {
313 chrome.send('toggleAutoLaunch', [Boolean($('autoLaunch').checked)]);
314 },
315
316 /**
307 * Sends an asynchronous request for new autocompletion suggestions for the 317 * Sends an asynchronous request for new autocompletion suggestions for the
308 * the given query. When new suggestions are available, the C++ handler will 318 * the given query. When new suggestions are available, the C++ handler will
309 * call updateAutocompleteSuggestions_. 319 * call updateAutocompleteSuggestions_.
310 * @param {string} query List of autocomplete suggestions. 320 * @param {string} query List of autocomplete suggestions.
311 * @private 321 * @private
312 */ 322 */
313 requestAutocompleteSuggestions_: function(query) { 323 requestAutocompleteSuggestions_: function(query) {
314 chrome.send('requestAutocompleteSuggestions', [query]); 324 chrome.send('requestAutocompleteSuggestions', [query]);
315 }, 325 },
316 326
317 /** 327 /**
318 * Updates the autocomplete suggestion list with the given entries. 328 * Updates the autocomplete suggestion list with the given entries.
319 * @param {Array} pages List of autocomplete suggestions. 329 * @param {Array} pages List of autocomplete suggestions.
320 * @private 330 * @private
321 */ 331 */
322 updateAutocompleteSuggestions_: function(suggestions) { 332 updateAutocompleteSuggestions_: function(suggestions) {
323 var list = this.autocompleteList_; 333 var list = this.autocompleteList_;
324 // If the trigger for this update was a value being selected from the 334 // If the trigger for this update was a value being selected from the
325 // current list, do nothing. 335 // current list, do nothing.
326 if (list.targetInput && list.selectedItem && 336 if (list.targetInput && list.selectedItem &&
327 list.selectedItem['url'] == list.targetInput.value) 337 list.selectedItem['url'] == list.targetInput.value)
328 return; 338 return;
329 list.suggestions = suggestions; 339 list.suggestions = suggestions;
330 }, 340 },
341
342 /**
343 * Shows the autoLaunch preference and initializes its checkbox value.
344 */
345 updateAutoLaunchState_: function(enabled) {
346 $('autoLaunchOption').hidden = false;
347 $('autoLaunch').checked = enabled;
348 },
331 }; 349 };
332 350
333 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault, 351 BrowserOptions.updateDefaultBrowserState = function(statusString, isDefault,
334 canBeDefault) { 352 canBeDefault) {
335 if (!cr.isChromeOS) { 353 if (!cr.isChromeOS) {
336 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString, 354 BrowserOptions.getInstance().updateDefaultBrowserState_(statusString,
337 isDefault, 355 isDefault,
338 canBeDefault); 356 canBeDefault);
339 } 357 }
340 }; 358 };
341 359
342 BrowserOptions.updateSearchEngines = function(engines, defaultValue, 360 BrowserOptions.updateSearchEngines = function(engines, defaultValue,
343 defaultManaged) { 361 defaultManaged) {
344 BrowserOptions.getInstance().updateSearchEngines_(engines, defaultValue, 362 BrowserOptions.getInstance().updateSearchEngines_(engines, defaultValue,
345 defaultManaged); 363 defaultManaged);
346 }; 364 };
347 365
348 BrowserOptions.updateStartupPages = function(pages) { 366 BrowserOptions.updateStartupPages = function(pages) {
349 BrowserOptions.getInstance().updateStartupPages_(pages); 367 BrowserOptions.getInstance().updateStartupPages_(pages);
350 }; 368 };
351 369
352 BrowserOptions.updateAutocompleteSuggestions = function(suggestions) { 370 BrowserOptions.updateAutocompleteSuggestions = function(suggestions) {
353 BrowserOptions.getInstance().updateAutocompleteSuggestions_(suggestions); 371 BrowserOptions.getInstance().updateAutocompleteSuggestions_(suggestions);
354 }; 372 };
355 373
374 BrowserOptions.updateAutoLaunchState = function(enabled) {
375 BrowserOptions.getInstance().updateAutoLaunchState_(enabled);
376 };
377
356 BrowserOptions.setInstantFieldTrialStatus = function(enabled) { 378 BrowserOptions.setInstantFieldTrialStatus = function(enabled) {
357 BrowserOptions.getInstance().setInstantFieldTrialStatus_(enabled); 379 BrowserOptions.getInstance().setInstantFieldTrialStatus_(enabled);
358 }; 380 };
359 381
360 // Export 382 // Export
361 return { 383 return {
362 BrowserOptions: BrowserOptions 384 BrowserOptions: BrowserOptions
363 }; 385 };
364 386
365 }); 387 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698