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.exportPath('options'); | 5 cr.exportPath('options'); |
6 | 6 |
7 /** | 7 /** |
8 * @typedef {{actionLinkText: (string|undefined), | 8 * @typedef {{actionLinkText: (string|undefined), |
9 * childUser: (boolean|undefined), | 9 * childUser: (boolean|undefined), |
10 * hasError: (boolean|undefined), | 10 * hasError: (boolean|undefined), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 /** | 103 /** |
104 * Track if page initialization is complete. All C++ UI handlers have the | 104 * Track if page initialization is complete. All C++ UI handlers have the |
105 * chance to manipulate page content within their InitializePage methods. | 105 * chance to manipulate page content within their InitializePage methods. |
106 * This flag is set to true after all initializers have been called. | 106 * This flag is set to true after all initializers have been called. |
107 * @type {boolean} | 107 * @type {boolean} |
108 * @private | 108 * @private |
109 */ | 109 */ |
110 initializationComplete_: false, | 110 initializationComplete_: false, |
111 | 111 |
| 112 /** |
| 113 * Current status of "Resolve Timezone by Geolocation" checkbox. |
| 114 * @private {boolean} |
| 115 */ |
| 116 resolveTimezoneByGeolocation_: false, |
| 117 |
| 118 /** |
| 119 * True if system timezone is managed by policy. |
| 120 * @private {boolean} |
| 121 */ |
| 122 systemTimezoneIsManaged_: false, |
| 123 |
112 /** @override */ | 124 /** @override */ |
113 initializePage: function() { | 125 initializePage: function() { |
114 Page.prototype.initializePage.call(this); | 126 Page.prototype.initializePage.call(this); |
115 var self = this; | 127 var self = this; |
116 | 128 |
117 if (window.top != window) { | 129 if (window.top != window) { |
118 // The options page is not in its own window. | 130 // The options page is not in its own window. |
119 document.body.classList.add('uber-frame'); | 131 document.body.classList.add('uber-frame'); |
120 PageManager.horizontalOffset = 155; | 132 PageManager.horizontalOffset = 155; |
121 } | 133 } |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 412 } |
401 | 413 |
402 // Date and time section (CrOS only). | 414 // Date and time section (CrOS only). |
403 if (cr.isChromeOS) { | 415 if (cr.isChromeOS) { |
404 if ($('set-time-button')) | 416 if ($('set-time-button')) |
405 $('set-time-button').onclick = this.handleSetTime_.bind(this); | 417 $('set-time-button').onclick = this.handleSetTime_.bind(this); |
406 | 418 |
407 // Timezone | 419 // Timezone |
408 if (loadTimeData.getBoolean('enableTimeZoneTrackingOption')) { | 420 if (loadTimeData.getBoolean('enableTimeZoneTrackingOption')) { |
409 $('resolve-timezone-by-geolocation-selection').hidden = false; | 421 $('resolve-timezone-by-geolocation-selection').hidden = false; |
410 this.setSystemTimezoneManaged_(false); | 422 this.resolveTimezoneByGeolocation_ = loadTimeData.getBoolean( |
411 $('timezone-value-select').disabled = loadTimeData.getBoolean( | |
412 'resolveTimezoneByGeolocationInitialValue'); | 423 'resolveTimezoneByGeolocationInitialValue'); |
| 424 this.updateTimezoneSectionState_(); |
| 425 Preferences.getInstance().addEventListener( |
| 426 'settings.resolve_timezone_by_geolocation', |
| 427 this.onResolveTimezoneByGeolocationChanged_.bind(this)); |
413 } | 428 } |
414 } | 429 } |
415 | 430 |
416 // Default browser section. | 431 // Default browser section. |
417 if (!cr.isChromeOS) { | 432 if (!cr.isChromeOS) { |
418 if (!loadTimeData.getBoolean('showSetDefault')) { | 433 if (!loadTimeData.getBoolean('showSetDefault')) { |
419 $('set-default-browser-section').hidden = true; | 434 $('set-default-browser-section').hidden = true; |
420 } | 435 } |
421 $('set-as-default-browser').onclick = function(event) { | 436 $('set-as-default-browser').onclick = function(event) { |
422 chrome.send('becomeDefaultBrowser'); | 437 chrome.send('becomeDefaultBrowser'); |
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 this.enableElementIfPossible_(getRequiredElement('set-wallpaper')); | 1660 this.enableElementIfPossible_(getRequiredElement('set-wallpaper')); |
1646 | 1661 |
1647 // Create a synthetic pref change event decorated as | 1662 // Create a synthetic pref change event decorated as |
1648 // CoreOptionsHandler::CreateValueForPref() does. | 1663 // CoreOptionsHandler::CreateValueForPref() does. |
1649 var event = new Event('wallpaper'); | 1664 var event = new Event('wallpaper'); |
1650 event.value = managed ? { controlledBy: 'policy' } : {}; | 1665 event.value = managed ? { controlledBy: 'policy' } : {}; |
1651 $('wallpaper-indicator').handlePrefChange(event); | 1666 $('wallpaper-indicator').handlePrefChange(event); |
1652 }, | 1667 }, |
1653 | 1668 |
1654 /** | 1669 /** |
| 1670 * This enables or disables dependent settings in timezone section. |
| 1671 * @private |
| 1672 */ |
| 1673 updateTimezoneSectionState_: function() { |
| 1674 if (this.systemTimezoneIsManaged_) { |
| 1675 $('resolve-timezone-by-geolocation-selection').disabled = true; |
| 1676 $('resolve-timezone-by-geolocation').onclick = function(event) {}; |
| 1677 } else { |
| 1678 this.enableElementIfPossible_( |
| 1679 getRequiredElement('resolve-timezone-by-geolocation-selection')); |
| 1680 $('resolve-timezone-by-geolocation').onclick = function(event) { |
| 1681 $('timezone-value-select').disabled = event.currentTarget.checked; |
| 1682 }; |
| 1683 $('timezone-value-select').disabled = |
| 1684 this.resolveTimezoneByGeolocation_; |
| 1685 } |
| 1686 }, |
| 1687 |
| 1688 /** |
1655 * This is called from chromium code when system timezone "managed" state | 1689 * This is called from chromium code when system timezone "managed" state |
1656 * is changed. Enables or disables dependent settings. | 1690 * is changed. Enables or disables dependent settings. |
1657 * @param {boolean} managed Is true when system Timezone is managed by | 1691 * @param {boolean} managed Is true when system Timezone is managed by |
1658 * enterprise policy. False otherwize. | 1692 * enterprise policy. False otherwize. |
1659 */ | 1693 */ |
1660 setSystemTimezoneManaged_: function(managed) { | 1694 setSystemTimezoneManaged_: function(managed) { |
1661 if (loadTimeData.getBoolean('enableTimeZoneTrackingOption')) { | 1695 this.systemTimezoneIsManaged_ = managed; |
1662 if (managed) { | 1696 this.updateTimezoneSectionState_(); |
1663 $('resolve-timezone-by-geolocation-selection').disabled = true; | |
1664 $('resolve-timezone-by-geolocation').onclick = function(event) {}; | |
1665 } else { | |
1666 this.enableElementIfPossible_( | |
1667 getRequiredElement('resolve-timezone-by-geolocation-selection')); | |
1668 $('resolve-timezone-by-geolocation').onclick = function(event) { | |
1669 $('timezone-value-select').disabled = event.currentTarget.checked; | |
1670 }; | |
1671 $('timezone-value-select').disabled = | |
1672 $('resolve-timezone-by-geolocation').checked; | |
1673 } | |
1674 } | |
1675 }, | 1697 }, |
1676 | 1698 |
1677 /** | 1699 /** |
| 1700 * This is Preferences event listener, which is called when |
| 1701 * kResolveTimezoneByGeolocation preference is changed. |
| 1702 * Enables or disables dependent settings. |
| 1703 * @param {Event} value New preference state. |
| 1704 */ |
| 1705 onResolveTimezoneByGeolocationChanged_: function(value) { |
| 1706 this.resolveTimezoneByGeolocation_ = value.value.value; |
| 1707 this.updateTimezoneSectionState_(); |
| 1708 }, |
| 1709 |
| 1710 /** |
1678 * Handle the 'add device' button click. | 1711 * Handle the 'add device' button click. |
1679 * @private | 1712 * @private |
1680 */ | 1713 */ |
1681 handleAddBluetoothDevice_: function() { | 1714 handleAddBluetoothDevice_: function() { |
1682 chrome.send('coreOptionsUserMetricsAction', | 1715 chrome.send('coreOptionsUserMetricsAction', |
1683 ['Options_BluetoothShowAddDevice']); | 1716 ['Options_BluetoothShowAddDevice']); |
1684 chrome.send('findBluetoothDevices'); | 1717 chrome.send('findBluetoothDevices'); |
1685 PageManager.showPageByName('bluetooth', false); | 1718 PageManager.showPageByName('bluetooth', false); |
1686 }, | 1719 }, |
1687 | 1720 |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2237 } | 2270 } |
2238 button.textContent = loadTimeData.getString(strId); | 2271 button.textContent = loadTimeData.getString(strId); |
2239 }; | 2272 }; |
2240 } | 2273 } |
2241 | 2274 |
2242 // Export | 2275 // Export |
2243 return { | 2276 return { |
2244 BrowserOptions: BrowserOptions | 2277 BrowserOptions: BrowserOptions |
2245 }; | 2278 }; |
2246 }); | 2279 }); |
OLD | NEW |