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 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
7 var Page = cr.ui.pageManager.Page; | 7 var Page = cr.ui.pageManager.Page; |
8 var PageManager = cr.ui.pageManager.PageManager; | 8 var PageManager = cr.ui.pageManager.PageManager; |
9 var ArrayDataModel = cr.ui.ArrayDataModel; | 9 var ArrayDataModel = cr.ui.ArrayDataModel; |
10 var RepeatingButton = cr.ui.RepeatingButton; | 10 var RepeatingButton = cr.ui.RepeatingButton; |
11 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; | 11 var HotwordSearchSettingIndicator = options.HotwordSearchSettingIndicator; |
12 var NetworkPredictionOptions = { | 12 var NetworkPredictionOptions = { |
13 ALWAYS: 0, | 13 ALWAYS: 0, |
14 WIFI_ONLY: 1, | 14 WIFI_ONLY: 1, |
15 NEVER: 2, | 15 NEVER: 2, |
16 UNSET: 3, | 16 UNSET: 3, |
17 DEFAULT: 1 | 17 DEFAULT: 1 |
18 }; | 18 }; |
19 | 19 |
20 /** | 20 // |
21 * Encapsulated handling of browser options page. | 21 // BrowserOptions class |
22 * @constructor | 22 // Encapsulated handling of browser options page. |
23 * @extends {cr.ui.pageManager.Page} | 23 // |
24 */ | |
25 function BrowserOptions() { | 24 function BrowserOptions() { |
26 Page.call(this, 'settings', loadTimeData.getString('settingsTitle'), | 25 Page.call(this, 'settings', loadTimeData.getString('settingsTitle'), |
27 'settings'); | 26 'settings'); |
28 } | 27 } |
29 | 28 |
30 cr.addSingletonGetter(BrowserOptions); | 29 cr.addSingletonGetter(BrowserOptions); |
31 | 30 |
32 /** | 31 /** |
33 * @param {HTMLElement} section The section to show or hide. | 32 * @param {HTMLElement} section The section to show or hide. |
34 * @return {boolean} Whether the section should be shown. | 33 * @return {boolean} Whether the section should be shown. |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 if (section.classList.contains('sliding')) | 729 if (section.classList.contains('sliding')) |
731 cr.dispatchSimpleEvent(section, 'webkitTransitionEnd'); | 730 cr.dispatchSimpleEvent(section, 'webkitTransitionEnd'); |
732 | 731 |
733 this.addTransitionEndListener_(section); | 732 this.addTransitionEndListener_(section); |
734 | 733 |
735 section.hidden = false; | 734 section.hidden = false; |
736 section.style.height = (showing ? 0 : container.offsetHeight) + 'px'; | 735 section.style.height = (showing ? 0 : container.offsetHeight) + 'px'; |
737 section.classList.add('sliding'); | 736 section.classList.add('sliding'); |
738 | 737 |
739 // Force a style recalc before starting the animation. | 738 // Force a style recalc before starting the animation. |
740 /** @suppress {suspiciousCode} */ | 739 /** @suppress {uselessCode} */ |
741 section.offsetHeight; | 740 section.offsetHeight; |
742 | 741 |
743 section.style.height = (showing ? container.offsetHeight : 0) + 'px'; | 742 section.style.height = (showing ? container.offsetHeight : 0) + 'px'; |
744 }, | 743 }, |
745 | 744 |
746 /** | 745 /** |
747 * Shows the given section. | 746 * Shows the given section. |
748 * @param {HTMLElement} section The section to be shown. | 747 * @param {HTMLElement} section The section to be shown. |
749 * @param {HTMLElement} container The container for the section. Must be | 748 * @param {HTMLElement} container The container for the section. Must be |
750 * inside of |section|. | 749 * inside of |section|. |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 | 1409 |
1411 /** | 1410 /** |
1412 * Propmpts user to confirm deletion of the profile for this browser | 1411 * Propmpts user to confirm deletion of the profile for this browser |
1413 * window. | 1412 * window. |
1414 * @private | 1413 * @private |
1415 */ | 1414 */ |
1416 deleteCurrentProfile_: function() { | 1415 deleteCurrentProfile_: function() { |
1417 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_()); | 1416 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_()); |
1418 }, | 1417 }, |
1419 | 1418 |
1420 /** | |
1421 * @param {boolean} enabled | |
1422 */ | |
1423 setNativeThemeButtonEnabled_: function(enabled) { | 1419 setNativeThemeButtonEnabled_: function(enabled) { |
1424 var button = $('themes-native-button'); | 1420 var button = $('themes-native-button'); |
1425 if (button) | 1421 if (button) |
1426 button.disabled = !enabled; | 1422 button.disabled = !enabled; |
1427 }, | 1423 }, |
1428 | 1424 |
1429 /** | |
1430 * @param {boolean} enabled | |
1431 */ | |
1432 setThemesResetButtonEnabled_: function(enabled) { | 1425 setThemesResetButtonEnabled_: function(enabled) { |
1433 $('themes-reset').disabled = !enabled; | 1426 $('themes-reset').disabled = !enabled; |
1434 }, | 1427 }, |
1435 | 1428 |
1436 /** | |
1437 * @param {boolean} managed | |
1438 */ | |
1439 setAccountPictureManaged_: function(managed) { | 1429 setAccountPictureManaged_: function(managed) { |
1440 var picture = $('account-picture'); | 1430 var picture = $('account-picture'); |
1441 if (managed || UIAccountTweaks.loggedInAsGuest()) { | 1431 if (managed || UIAccountTweaks.loggedInAsGuest()) { |
1442 picture.disabled = true; | 1432 picture.disabled = true; |
1443 ChangePictureOptions.closeOverlay(); | 1433 ChangePictureOptions.closeOverlay(); |
1444 } else { | 1434 } else { |
1445 picture.disabled = false; | 1435 picture.disabled = false; |
1446 } | 1436 } |
1447 | 1437 |
1448 // Create a synthetic pref change event decorated as | 1438 // Create a synthetic pref change event decorated as |
(...skipping 11 matching lines...) Expand all Loading... |
1460 * @private | 1450 * @private |
1461 */ | 1451 */ |
1462 updateAccountPicture_: function() { | 1452 updateAccountPicture_: function() { |
1463 var picture = $('account-picture'); | 1453 var picture = $('account-picture'); |
1464 if (picture) { | 1454 if (picture) { |
1465 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + | 1455 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + |
1466 Date.now(); | 1456 Date.now(); |
1467 } | 1457 } |
1468 }, | 1458 }, |
1469 | 1459 |
1470 /** | |
1471 * @param {boolean} managed | |
1472 */ | |
1473 setWallpaperManaged_: function(managed) { | 1460 setWallpaperManaged_: function(managed) { |
1474 var button = $('set-wallpaper'); | 1461 var button = $('set-wallpaper'); |
1475 button.disabled = !!managed; | 1462 button.disabled = !!managed; |
1476 | 1463 |
1477 // Create a synthetic pref change event decorated as | 1464 // Create a synthetic pref change event decorated as |
1478 // CoreOptionsHandler::CreateValueForPref() does. | 1465 // CoreOptionsHandler::CreateValueForPref() does. |
1479 var event = new Event('wallpaper'); | 1466 var event = new Event('wallpaper'); |
1480 if (managed) | 1467 if (managed) |
1481 event.value = { controlledBy: 'policy' }; | 1468 event.value = { controlledBy: 'policy' }; |
1482 else | 1469 else |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1914 /** | 1901 /** |
1915 * Handle the 'set date and time' button click. | 1902 * Handle the 'set date and time' button click. |
1916 * @private | 1903 * @private |
1917 */ | 1904 */ |
1918 handleSetTime_: function() { | 1905 handleSetTime_: function() { |
1919 chrome.send('showSetTime'); | 1906 chrome.send('showSetTime'); |
1920 }, | 1907 }, |
1921 }; | 1908 }; |
1922 | 1909 |
1923 //Forward public APIs to private implementations. | 1910 //Forward public APIs to private implementations. |
1924 cr.makePublic(BrowserOptions, [ | 1911 [ |
1925 'addBluetoothDevice', | 1912 'addBluetoothDevice', |
1926 'deleteCurrentProfile', | 1913 'deleteCurrentProfile', |
1927 'enableCertificateButton', | 1914 'enableCertificateButton', |
1928 'enableFactoryResetSection', | 1915 'enableFactoryResetSection', |
1929 'getCurrentProfile', | 1916 'getCurrentProfile', |
1930 'getStartStopSyncButton', | 1917 'getStartStopSyncButton', |
1931 'hideBluetoothSettings', | 1918 'hideBluetoothSettings', |
1932 'notifyInitializationComplete', | 1919 'notifyInitializationComplete', |
1933 'removeBluetoothDevice', | 1920 'removeBluetoothDevice', |
1934 'scrollToSection', | 1921 'scrollToSection', |
(...skipping 24 matching lines...) Expand all Loading... |
1959 'showSupervisedUserImportError', | 1946 'showSupervisedUserImportError', |
1960 'showSupervisedUserImportSuccess', | 1947 'showSupervisedUserImportSuccess', |
1961 'showTouchpadControls', | 1948 'showTouchpadControls', |
1962 'toggleExtensionIndicators', | 1949 'toggleExtensionIndicators', |
1963 'updateAccountPicture', | 1950 'updateAccountPicture', |
1964 'updateAutoLaunchState', | 1951 'updateAutoLaunchState', |
1965 'updateDefaultBrowserState', | 1952 'updateDefaultBrowserState', |
1966 'updateEasyUnlock', | 1953 'updateEasyUnlock', |
1967 'updateManagesSupervisedUsers', | 1954 'updateManagesSupervisedUsers', |
1968 'updateSearchEngines', | 1955 'updateSearchEngines', |
| 1956 'updateStartupPages', |
1969 'updateSyncState', | 1957 'updateSyncState', |
1970 ]); | 1958 ].forEach(function(name) { |
| 1959 BrowserOptions[name] = function() { |
| 1960 var instance = BrowserOptions.getInstance(); |
| 1961 return instance[name + '_'].apply(instance, arguments); |
| 1962 }; |
| 1963 }); |
1971 | 1964 |
1972 if (cr.isChromeOS) { | 1965 if (cr.isChromeOS) { |
1973 /** | 1966 /** |
1974 * Returns username (canonical email) of the user logged in (ChromeOS only). | 1967 * Returns username (canonical email) of the user logged in (ChromeOS only). |
1975 * @return {string} user email. | 1968 * @return {string} user email. |
1976 */ | 1969 */ |
1977 // TODO(jhawkins): Investigate the use case for this method. | 1970 // TODO(jhawkins): Investigate the use case for this method. |
1978 BrowserOptions.getLoggedInUsername = function() { | 1971 BrowserOptions.getLoggedInUsername = function() { |
1979 return BrowserOptions.getInstance().username_; | 1972 return BrowserOptions.getInstance().username_; |
1980 }; | 1973 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 } | 2008 } |
2016 button.textContent = loadTimeData.getString(strId); | 2009 button.textContent = loadTimeData.getString(strId); |
2017 }; | 2010 }; |
2018 } | 2011 } |
2019 | 2012 |
2020 // Export | 2013 // Export |
2021 return { | 2014 return { |
2022 BrowserOptions: BrowserOptions | 2015 BrowserOptions: BrowserOptions |
2023 }; | 2016 }; |
2024 }); | 2017 }); |
OLD | NEW |