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 // BrowserOptions class | 21 * Encapsulated handling of browser options page. |
22 // Encapsulated handling of browser options page. | 22 * @constructor |
23 // | 23 * @extends {cr.ui.pageManager.Page} |
24 */ | |
24 function BrowserOptions() { | 25 function BrowserOptions() { |
25 Page.call(this, 'settings', loadTimeData.getString('settingsTitle'), | 26 Page.call(this, 'settings', loadTimeData.getString('settingsTitle'), |
26 'settings'); | 27 'settings'); |
27 } | 28 } |
28 | 29 |
29 cr.addSingletonGetter(BrowserOptions); | 30 cr.addSingletonGetter(BrowserOptions); |
30 | 31 |
31 /** | 32 /** |
32 * @param {HTMLElement} section The section to show or hide. | 33 * @param {HTMLElement} section The section to show or hide. |
33 * @return {boolean} Whether the section should be shown. | 34 * @return {boolean} Whether the section should be shown. |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
724 if (section.classList.contains('sliding')) | 725 if (section.classList.contains('sliding')) |
725 cr.dispatchSimpleEvent(section, 'webkitTransitionEnd'); | 726 cr.dispatchSimpleEvent(section, 'webkitTransitionEnd'); |
726 | 727 |
727 this.addTransitionEndListener_(section); | 728 this.addTransitionEndListener_(section); |
728 | 729 |
729 section.hidden = false; | 730 section.hidden = false; |
730 section.style.height = (showing ? 0 : container.offsetHeight) + 'px'; | 731 section.style.height = (showing ? 0 : container.offsetHeight) + 'px'; |
731 section.classList.add('sliding'); | 732 section.classList.add('sliding'); |
732 | 733 |
733 // Force a style recalc before starting the animation. | 734 // Force a style recalc before starting the animation. |
734 /** @suppress {uselessCode} */ | 735 /** @suppress {uselessCode} */ |
Dan Beam
2014/09/12 23:43:54
i was wrong, can you change this to suspiciousCode
Vitaly Pavlenko
2014/09/13 01:22:39
Done.
| |
735 section.offsetHeight; | 736 section.offsetHeight; |
736 | 737 |
737 section.style.height = (showing ? container.offsetHeight : 0) + 'px'; | 738 section.style.height = (showing ? container.offsetHeight : 0) + 'px'; |
738 }, | 739 }, |
739 | 740 |
740 /** | 741 /** |
741 * Shows the given section. | 742 * Shows the given section. |
742 * @param {HTMLElement} section The section to be shown. | 743 * @param {HTMLElement} section The section to be shown. |
743 * @param {HTMLElement} container The container for the section. Must be | 744 * @param {HTMLElement} container The container for the section. Must be |
744 * inside of |section|. | 745 * inside of |section|. |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1404 | 1405 |
1405 /** | 1406 /** |
1406 * Propmpts user to confirm deletion of the profile for this browser | 1407 * Propmpts user to confirm deletion of the profile for this browser |
1407 * window. | 1408 * window. |
1408 * @private | 1409 * @private |
1409 */ | 1410 */ |
1410 deleteCurrentProfile_: function() { | 1411 deleteCurrentProfile_: function() { |
1411 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_()); | 1412 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_()); |
1412 }, | 1413 }, |
1413 | 1414 |
1415 /** | |
1416 * @param {boolean} enabled | |
1417 */ | |
1414 setNativeThemeButtonEnabled_: function(enabled) { | 1418 setNativeThemeButtonEnabled_: function(enabled) { |
1415 var button = $('themes-native-button'); | 1419 var button = $('themes-native-button'); |
1416 if (button) | 1420 if (button) |
1417 button.disabled = !enabled; | 1421 button.disabled = !enabled; |
1418 }, | 1422 }, |
1419 | 1423 |
1424 /** | |
1425 * @param {boolean} enabled | |
1426 */ | |
1420 setThemesResetButtonEnabled_: function(enabled) { | 1427 setThemesResetButtonEnabled_: function(enabled) { |
1421 $('themes-reset').disabled = !enabled; | 1428 $('themes-reset').disabled = !enabled; |
1422 }, | 1429 }, |
1423 | 1430 |
1431 /** | |
1432 * @param {boolean} managed | |
1433 */ | |
1424 setAccountPictureManaged_: function(managed) { | 1434 setAccountPictureManaged_: function(managed) { |
1425 var picture = $('account-picture'); | 1435 var picture = $('account-picture'); |
1426 if (managed || UIAccountTweaks.loggedInAsGuest()) { | 1436 if (managed || UIAccountTweaks.loggedInAsGuest()) { |
1427 picture.disabled = true; | 1437 picture.disabled = true; |
1428 ChangePictureOptions.closeOverlay(); | 1438 ChangePictureOptions.closeOverlay(); |
1429 } else { | 1439 } else { |
1430 picture.disabled = false; | 1440 picture.disabled = false; |
1431 } | 1441 } |
1432 | 1442 |
1433 // Create a synthetic pref change event decorated as | 1443 // Create a synthetic pref change event decorated as |
(...skipping 11 matching lines...) Expand all Loading... | |
1445 * @private | 1455 * @private |
1446 */ | 1456 */ |
1447 updateAccountPicture_: function() { | 1457 updateAccountPicture_: function() { |
1448 var picture = $('account-picture'); | 1458 var picture = $('account-picture'); |
1449 if (picture) { | 1459 if (picture) { |
1450 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + | 1460 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + |
1451 Date.now(); | 1461 Date.now(); |
1452 } | 1462 } |
1453 }, | 1463 }, |
1454 | 1464 |
1465 /** | |
1466 * @param {boolean} managed | |
1467 */ | |
1455 setWallpaperManaged_: function(managed) { | 1468 setWallpaperManaged_: function(managed) { |
1456 var button = $('set-wallpaper'); | 1469 var button = $('set-wallpaper'); |
1457 button.disabled = !!managed; | 1470 button.disabled = !!managed; |
1458 | 1471 |
1459 // Create a synthetic pref change event decorated as | 1472 // Create a synthetic pref change event decorated as |
1460 // CoreOptionsHandler::CreateValueForPref() does. | 1473 // CoreOptionsHandler::CreateValueForPref() does. |
1461 var event = new Event('wallpaper'); | 1474 var event = new Event('wallpaper'); |
1462 if (managed) | 1475 if (managed) |
1463 event.value = { controlledBy: 'policy' }; | 1476 event.value = { controlledBy: 'policy' }; |
1464 else | 1477 else |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1889 /** | 1902 /** |
1890 * Handle the 'set date and time' button click. | 1903 * Handle the 'set date and time' button click. |
1891 * @private | 1904 * @private |
1892 */ | 1905 */ |
1893 handleSetTime_: function() { | 1906 handleSetTime_: function() { |
1894 chrome.send('showSetTime'); | 1907 chrome.send('showSetTime'); |
1895 }, | 1908 }, |
1896 }; | 1909 }; |
1897 | 1910 |
1898 //Forward public APIs to private implementations. | 1911 //Forward public APIs to private implementations. |
1899 [ | 1912 cr.makePublic(BrowserOptions, [ |
1900 'addBluetoothDevice', | 1913 'addBluetoothDevice', |
1901 'deleteCurrentProfile', | 1914 'deleteCurrentProfile', |
1902 'enableCertificateButton', | 1915 'enableCertificateButton', |
1903 'enableFactoryResetSection', | 1916 'enableFactoryResetSection', |
1904 'getCurrentProfile', | 1917 'getCurrentProfile', |
1905 'getStartStopSyncButton', | 1918 'getStartStopSyncButton', |
1906 'hideBluetoothSettings', | 1919 'hideBluetoothSettings', |
1907 'notifyInitializationComplete', | 1920 'notifyInitializationComplete', |
1908 'removeBluetoothDevice', | 1921 'removeBluetoothDevice', |
1909 'scrollToSection', | 1922 'scrollToSection', |
(...skipping 24 matching lines...) Expand all Loading... | |
1934 'showSupervisedUserImportError', | 1947 'showSupervisedUserImportError', |
1935 'showSupervisedUserImportSuccess', | 1948 'showSupervisedUserImportSuccess', |
1936 'showTouchpadControls', | 1949 'showTouchpadControls', |
1937 'toggleExtensionIndicators', | 1950 'toggleExtensionIndicators', |
1938 'updateAccountPicture', | 1951 'updateAccountPicture', |
1939 'updateAutoLaunchState', | 1952 'updateAutoLaunchState', |
1940 'updateDefaultBrowserState', | 1953 'updateDefaultBrowserState', |
1941 'updateEasyUnlock', | 1954 'updateEasyUnlock', |
1942 'updateManagesSupervisedUsers', | 1955 'updateManagesSupervisedUsers', |
1943 'updateSearchEngines', | 1956 'updateSearchEngines', |
1944 'updateStartupPages', | |
1945 'updateSyncState', | 1957 'updateSyncState', |
1946 ].forEach(function(name) { | 1958 ]); |
1947 BrowserOptions[name] = function() { | |
1948 var instance = BrowserOptions.getInstance(); | |
1949 return instance[name + '_'].apply(instance, arguments); | |
1950 }; | |
1951 }); | |
1952 | 1959 |
1953 if (cr.isChromeOS) { | 1960 if (cr.isChromeOS) { |
1954 /** | 1961 /** |
1955 * Returns username (canonical email) of the user logged in (ChromeOS only). | 1962 * Returns username (canonical email) of the user logged in (ChromeOS only). |
1956 * @return {string} user email. | 1963 * @return {string} user email. |
1957 */ | 1964 */ |
1958 // TODO(jhawkins): Investigate the use case for this method. | 1965 // TODO(jhawkins): Investigate the use case for this method. |
1959 BrowserOptions.getLoggedInUsername = function() { | 1966 BrowserOptions.getLoggedInUsername = function() { |
1960 return BrowserOptions.getInstance().username_; | 1967 return BrowserOptions.getInstance().username_; |
1961 }; | 1968 }; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1996 } | 2003 } |
1997 button.textContent = loadTimeData.getString(strId); | 2004 button.textContent = loadTimeData.getString(strId); |
1998 }; | 2005 }; |
1999 } | 2006 } |
2000 | 2007 |
2001 // Export | 2008 // Export |
2002 return { | 2009 return { |
2003 BrowserOptions: BrowserOptions | 2010 BrowserOptions: BrowserOptions |
2004 }; | 2011 }; |
2005 }); | 2012 }); |
OLD | NEW |