| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 }, | 215 }, |
| 216 | 216 |
| 217 /** | 217 /** |
| 218 * Returns true if the custom startup page control block should | 218 * Returns true if the custom startup page control block should |
| 219 * be enabled. | 219 * be enabled. |
| 220 * @returns {boolean} Whether the startup page controls should be | 220 * @returns {boolean} Whether the startup page controls should be |
| 221 * enabled. | 221 * enabled. |
| 222 */ | 222 */ |
| 223 shouldEnableCustomStartupPageControls: function(pages) { | 223 shouldEnableCustomStartupPageControls: function(pages) { |
| 224 return $('startupShowPagesButton').checked && | 224 return $('startupShowPagesButton').checked && |
| 225 !this.startup_pages_pref_.managed; | 225 !this.startup_pages_pref_.controlledBy; |
| 226 }, | 226 }, |
| 227 | 227 |
| 228 /** | 228 /** |
| 229 * Updates the startup pages list with the given entries. | 229 * Updates the startup pages list with the given entries. |
| 230 * @param {Array} pages List of startup pages. | 230 * @param {Array} pages List of startup pages. |
| 231 * @private | 231 * @private |
| 232 */ | 232 */ |
| 233 updateStartupPages_: function(pages) { | 233 updateStartupPages_: function(pages) { |
| 234 var model = new ArrayDataModel(pages); | 234 var model = new ArrayDataModel(pages); |
| 235 // Add a "new page" row. | 235 // Add a "new page" row. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 chrome.send('setHomePage', [homepageField.value, doFixup]); | 268 chrome.send('setHomePage', [homepageField.value, doFixup]); |
| 269 }, | 269 }, |
| 270 | 270 |
| 271 /** | 271 /** |
| 272 * Handle change events of the preference 'homepage'. | 272 * Handle change events of the preference 'homepage'. |
| 273 * @param {event} preference changed event. | 273 * @param {event} preference changed event. |
| 274 * @private | 274 * @private |
| 275 */ | 275 */ |
| 276 handleHomepageChange_: function(event) { | 276 handleHomepageChange_: function(event) { |
| 277 this.homepage_pref_.value = event.value['value']; | 277 this.homepage_pref_.value = event.value['value']; |
| 278 this.homepage_pref_.managed = event.value['managed']; | 278 this.homepage_pref_.controlledBy = event.value['controlledBy']; |
| 279 if (this.isHomepageURLNewTabPageURL_() && !this.homepage_pref_.managed && | 279 if (this.isHomepageURLNewTabPageURL_() && |
| 280 !this.homepage_is_newtabpage_pref_.managed) { | 280 !this.homepage_pref_.controlledBy && |
| 281 !this.homepage_is_newtabpage_pref_.controlledBy) { |
| 281 var useNewTabPage = this.isHomepageIsNewTabPageChoiceSelected_(); | 282 var useNewTabPage = this.isHomepageIsNewTabPageChoiceSelected_(); |
| 282 Preferences.setStringPref(this.homepage_pref_.name, '') | 283 Preferences.setStringPref(this.homepage_pref_.name, '') |
| 283 Preferences.setBooleanPref(this.homepage_is_newtabpage_pref_.name, | 284 Preferences.setBooleanPref(this.homepage_is_newtabpage_pref_.name, |
| 284 useNewTabPage) | 285 useNewTabPage) |
| 285 } | 286 } |
| 286 this.updateHomepageControlStates_(); | 287 this.updateHomepageControlStates_(); |
| 287 }, | 288 }, |
| 288 | 289 |
| 289 /** | 290 /** |
| 290 * Handle change events of the preference homepage_is_newtabpage. | 291 * Handle change events of the preference homepage_is_newtabpage. |
| 291 * @param {event} preference changed event. | 292 * @param {event} preference changed event. |
| 292 * @private | 293 * @private |
| 293 */ | 294 */ |
| 294 handleHomepageIsNewTabPageChange_: function(event) { | 295 handleHomepageIsNewTabPageChange_: function(event) { |
| 295 this.homepage_is_newtabpage_pref_.value = event.value['value']; | 296 this.homepage_is_newtabpage_pref_.value = event.value['value']; |
| 296 this.homepage_is_newtabpage_pref_.managed = event.value['managed']; | 297 this.homepage_is_newtabpage_pref_.controlledBy = |
| 298 event.value['controlledBy']; |
| 297 this.updateHomepageControlStates_(); | 299 this.updateHomepageControlStates_(); |
| 298 }, | 300 }, |
| 299 | 301 |
| 300 /** | 302 /** |
| 301 * Update homepage preference UI controls. Here's a table describing the | 303 * Update homepage preference UI controls. Here's a table describing the |
| 302 * desired characteristics of the homepage choice radio value, its enabled | 304 * desired characteristics of the homepage choice radio value, its enabled |
| 303 * state and the URL field enabled state. They depend on the values of the | 305 * state and the URL field enabled state. They depend on the values of the |
| 304 * managed bits for homepage (m_hp) and homepageIsNewTabPage (m_ntp) | 306 * managed bits for homepage (m_hp) and homepageIsNewTabPage (m_ntp) |
| 305 * preferences, as well as the value of the homepageIsNewTabPage preference | 307 * preferences, as well as the value of the homepageIsNewTabPage preference |
| 306 * (ntp) and whether the homepage preference is equal to the new tab page | 308 * (ntp) and whether the homepage preference is equal to the new tab page |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 }, | 363 }, |
| 362 | 364 |
| 363 /** | 365 /** |
| 364 * Tests whether the Homepage choice "Use New Tab Page" is selected. | 366 * Tests whether the Homepage choice "Use New Tab Page" is selected. |
| 365 * @returns {boolean} True if "Use New Tab Page" is selected. | 367 * @returns {boolean} True if "Use New Tab Page" is selected. |
| 366 * @private | 368 * @private |
| 367 */ | 369 */ |
| 368 isHomepageIsNewTabPageChoiceSelected_: function() { | 370 isHomepageIsNewTabPageChoiceSelected_: function() { |
| 369 return (this.homepage_is_newtabpage_pref_.value || | 371 return (this.homepage_is_newtabpage_pref_.value || |
| 370 (this.isHomepageURLNewTabPageURL_() && | 372 (this.isHomepageURLNewTabPageURL_() && |
| 371 (this.homepage_pref_.managed || | 373 (this.homepage_pref_.controlledBy || |
| 372 !this.homepage_is_newtabpage_pref_.managed))); | 374 !this.homepage_is_newtabpage_pref_.controlledBy))); |
| 373 }, | 375 }, |
| 374 | 376 |
| 375 /** | 377 /** |
| 376 * Tests whether the home page choice controls are enabled. | 378 * Tests whether the home page choice controls are enabled. |
| 377 * @returns {boolean} True if the home page choice controls are enabled. | 379 * @returns {boolean} True if the home page choice controls are enabled. |
| 378 * @private | 380 * @private |
| 379 */ | 381 */ |
| 380 isHomepageChoiceEnabled_: function() { | 382 isHomepageChoiceEnabled_: function() { |
| 381 return (!this.homepage_is_newtabpage_pref_.managed && | 383 return (!this.homepage_is_newtabpage_pref_.controlledBy && |
| 382 !(this.homepage_pref_.managed && | 384 !(this.homepage_pref_.controlledBy && |
| 383 this.isHomepageURLNewTabPageURL_())); | 385 this.isHomepageURLNewTabPageURL_())); |
| 384 }, | 386 }, |
| 385 | 387 |
| 386 /** | 388 /** |
| 387 * Checks whether the home page field should be enabled. | 389 * Checks whether the home page field should be enabled. |
| 388 * @returns {boolean} True if the home page field should be enabled. | 390 * @returns {boolean} True if the home page field should be enabled. |
| 389 * @private | 391 * @private |
| 390 */ | 392 */ |
| 391 isHomepageURLFieldEnabled_: function() { | 393 isHomepageURLFieldEnabled_: function() { |
| 392 return (!this.homepage_is_newtabpage_pref_.value && | 394 return (!this.homepage_is_newtabpage_pref_.value && |
| 393 !this.homepage_pref_.managed && | 395 !this.homepage_pref_.controlledBy && |
| 394 !(this.isHomepageURLNewTabPageURL_() && | 396 !(this.isHomepageURLNewTabPageURL_() && |
| 395 !this.homepage_is_newtabpage_pref_.managed)); | 397 !this.homepage_is_newtabpage_pref_.controlledBy)); |
| 396 }, | 398 }, |
| 397 | 399 |
| 398 /** | 400 /** |
| 399 * Sets the enabled state of the custom startup page list controls | 401 * Sets the enabled state of the custom startup page list controls |
| 400 * based on the current startup radio button selection. | 402 * based on the current startup radio button selection. |
| 401 * @private | 403 * @private |
| 402 */ | 404 */ |
| 403 updateCustomStartupPageControlStates_: function() { | 405 updateCustomStartupPageControlStates_: function() { |
| 404 var disable = !this.shouldEnableCustomStartupPageControls(); | 406 var disable = !this.shouldEnableCustomStartupPageControls(); |
| 405 var startupPagesList = $('startupPagesList'); | 407 var startupPagesList = $('startupPagesList'); |
| 406 startupPagesList.disabled = disable; | 408 startupPagesList.disabled = disable; |
| 407 // Explicitly set disabled state for input text elements. | 409 // Explicitly set disabled state for input text elements. |
| 408 var inputs = startupPagesList.querySelectorAll("input[type='text']"); | 410 var inputs = startupPagesList.querySelectorAll("input[type='text']"); |
| 409 for (var i = 0; i < inputs.length; i++) | 411 for (var i = 0; i < inputs.length; i++) |
| 410 inputs[i].disabled = disable; | 412 inputs[i].disabled = disable; |
| 411 $('startupUseCurrentButton').disabled = disable; | 413 $('startupUseCurrentButton').disabled = disable; |
| 412 }, | 414 }, |
| 413 | 415 |
| 414 /** | 416 /** |
| 415 * Handle change events of the preference | 417 * Handle change events of the preference |
| 416 * 'session.urls_to_restore_on_startup'. | 418 * 'session.urls_to_restore_on_startup'. |
| 417 * @param {event} preference changed event. | 419 * @param {event} preference changed event. |
| 418 * @private | 420 * @private |
| 419 */ | 421 */ |
| 420 handleStartupPageListChange_: function(event) { | 422 handleStartupPageListChange_: function(event) { |
| 421 this.startup_pages_pref_.managed = event.value['managed']; | 423 this.startup_pages_pref_.controlledBy = event.value['controlledBy']; |
| 422 this.updateCustomStartupPageControlStates_(); | 424 this.updateCustomStartupPageControlStates_(); |
| 423 }, | 425 }, |
| 424 | 426 |
| 425 /** | 427 /** |
| 426 * Set the default search engine based on the popup selection. | 428 * Set the default search engine based on the popup selection. |
| 427 */ | 429 */ |
| 428 setDefaultSearchEngine_: function() { | 430 setDefaultSearchEngine_: function() { |
| 429 var engineSelect = $('defaultSearchEngine'); | 431 var engineSelect = $('defaultSearchEngine'); |
| 430 var selectedIndex = engineSelect.selectedIndex; | 432 var selectedIndex = engineSelect.selectedIndex; |
| 431 if (selectedIndex >= 0) { | 433 if (selectedIndex >= 0) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 BrowserOptions.updateAutocompleteSuggestions = function(suggestions) { | 485 BrowserOptions.updateAutocompleteSuggestions = function(suggestions) { |
| 484 BrowserOptions.getInstance().updateAutocompleteSuggestions_(suggestions); | 486 BrowserOptions.getInstance().updateAutocompleteSuggestions_(suggestions); |
| 485 }; | 487 }; |
| 486 | 488 |
| 487 // Export | 489 // Export |
| 488 return { | 490 return { |
| 489 BrowserOptions: BrowserOptions | 491 BrowserOptions: BrowserOptions |
| 490 }; | 492 }; |
| 491 | 493 |
| 492 }); | 494 }); |
| OLD | NEW |