| 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 1387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 | 1422 |
| 1422 /** | 1423 /** |
| 1423 * Propmpts user to confirm deletion of the profile for this browser | 1424 * Propmpts user to confirm deletion of the profile for this browser |
| 1424 * window. | 1425 * window. |
| 1425 * @private | 1426 * @private |
| 1426 */ | 1427 */ |
| 1427 deleteCurrentProfile_: function() { | 1428 deleteCurrentProfile_: function() { |
| 1428 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_()); | 1429 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_()); |
| 1429 }, | 1430 }, |
| 1430 | 1431 |
| 1432 /** |
| 1433 * @param {boolean} enabled |
| 1434 */ |
| 1431 setNativeThemeButtonEnabled_: function(enabled) { | 1435 setNativeThemeButtonEnabled_: function(enabled) { |
| 1432 var button = $('themes-native-button'); | 1436 var button = $('themes-native-button'); |
| 1433 if (button) | 1437 if (button) |
| 1434 button.disabled = !enabled; | 1438 button.disabled = !enabled; |
| 1435 }, | 1439 }, |
| 1436 | 1440 |
| 1441 /** |
| 1442 * @param {boolean} enabled |
| 1443 */ |
| 1437 setThemesResetButtonEnabled_: function(enabled) { | 1444 setThemesResetButtonEnabled_: function(enabled) { |
| 1438 $('themes-reset').disabled = !enabled; | 1445 $('themes-reset').disabled = !enabled; |
| 1439 }, | 1446 }, |
| 1440 | 1447 |
| 1448 /** |
| 1449 * @param {boolean} managed |
| 1450 */ |
| 1441 setAccountPictureManaged_: function(managed) { | 1451 setAccountPictureManaged_: function(managed) { |
| 1442 var picture = $('account-picture'); | 1452 var picture = $('account-picture'); |
| 1443 if (managed || UIAccountTweaks.loggedInAsGuest()) { | 1453 if (managed || UIAccountTweaks.loggedInAsGuest()) { |
| 1444 picture.disabled = true; | 1454 picture.disabled = true; |
| 1445 ChangePictureOptions.closeOverlay(); | 1455 ChangePictureOptions.closeOverlay(); |
| 1446 } else { | 1456 } else { |
| 1447 picture.disabled = false; | 1457 picture.disabled = false; |
| 1448 } | 1458 } |
| 1449 | 1459 |
| 1450 // Create a synthetic pref change event decorated as | 1460 // Create a synthetic pref change event decorated as |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1462 * @private | 1472 * @private |
| 1463 */ | 1473 */ |
| 1464 updateAccountPicture_: function() { | 1474 updateAccountPicture_: function() { |
| 1465 var picture = $('account-picture'); | 1475 var picture = $('account-picture'); |
| 1466 if (picture) { | 1476 if (picture) { |
| 1467 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + | 1477 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + |
| 1468 Date.now(); | 1478 Date.now(); |
| 1469 } | 1479 } |
| 1470 }, | 1480 }, |
| 1471 | 1481 |
| 1482 /** |
| 1483 * @param {boolean} managed |
| 1484 */ |
| 1472 setWallpaperManaged_: function(managed) { | 1485 setWallpaperManaged_: function(managed) { |
| 1473 var button = $('set-wallpaper'); | 1486 var button = $('set-wallpaper'); |
| 1474 button.disabled = !!managed; | 1487 button.disabled = !!managed; |
| 1475 | 1488 |
| 1476 // Create a synthetic pref change event decorated as | 1489 // Create a synthetic pref change event decorated as |
| 1477 // CoreOptionsHandler::CreateValueForPref() does. | 1490 // CoreOptionsHandler::CreateValueForPref() does. |
| 1478 var event = new Event('wallpaper'); | 1491 var event = new Event('wallpaper'); |
| 1479 if (managed) | 1492 if (managed) |
| 1480 event.value = { controlledBy: 'policy' }; | 1493 event.value = { controlledBy: 'policy' }; |
| 1481 else | 1494 else |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1906 /** | 1919 /** |
| 1907 * Handle the 'set date and time' button click. | 1920 * Handle the 'set date and time' button click. |
| 1908 * @private | 1921 * @private |
| 1909 */ | 1922 */ |
| 1910 handleSetTime_: function() { | 1923 handleSetTime_: function() { |
| 1911 chrome.send('showSetTime'); | 1924 chrome.send('showSetTime'); |
| 1912 }, | 1925 }, |
| 1913 }; | 1926 }; |
| 1914 | 1927 |
| 1915 //Forward public APIs to private implementations. | 1928 //Forward public APIs to private implementations. |
| 1916 [ | 1929 cr.makePublic(BrowserOptions, [ |
| 1917 'addBluetoothDevice', | 1930 'addBluetoothDevice', |
| 1918 'deleteCurrentProfile', | 1931 'deleteCurrentProfile', |
| 1919 'enableCertificateButton', | 1932 'enableCertificateButton', |
| 1920 'enableFactoryResetSection', | 1933 'enableFactoryResetSection', |
| 1921 'getCurrentProfile', | 1934 'getCurrentProfile', |
| 1922 'getStartStopSyncButton', | 1935 'getStartStopSyncButton', |
| 1923 'hideBluetoothSettings', | 1936 'hideBluetoothSettings', |
| 1924 'notifyInitializationComplete', | 1937 'notifyInitializationComplete', |
| 1925 'removeBluetoothDevice', | 1938 'removeBluetoothDevice', |
| 1926 'scrollToSection', | 1939 'scrollToSection', |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1953 'showTouchpadControls', | 1966 'showTouchpadControls', |
| 1954 'toggleExtensionIndicators', | 1967 'toggleExtensionIndicators', |
| 1955 'updateAccountPicture', | 1968 'updateAccountPicture', |
| 1956 'updateAutoLaunchState', | 1969 'updateAutoLaunchState', |
| 1957 'updateDefaultBrowserState', | 1970 'updateDefaultBrowserState', |
| 1958 'updateEasyUnlock', | 1971 'updateEasyUnlock', |
| 1959 'updateManagesSupervisedUsers', | 1972 'updateManagesSupervisedUsers', |
| 1960 'updateSearchEngines', | 1973 'updateSearchEngines', |
| 1961 'updateStartupPages', | 1974 'updateStartupPages', |
| 1962 'updateSyncState', | 1975 'updateSyncState', |
| 1963 ].forEach(function(name) { | 1976 ]); |
| 1964 BrowserOptions[name] = function() { | |
| 1965 var instance = BrowserOptions.getInstance(); | |
| 1966 return instance[name + '_'].apply(instance, arguments); | |
| 1967 }; | |
| 1968 }); | |
| 1969 | 1977 |
| 1970 if (cr.isChromeOS) { | 1978 if (cr.isChromeOS) { |
| 1971 /** | 1979 /** |
| 1972 * Returns username (canonical email) of the user logged in (ChromeOS only). | 1980 * Returns username (canonical email) of the user logged in (ChromeOS only). |
| 1973 * @return {string} user email. | 1981 * @return {string} user email. |
| 1974 */ | 1982 */ |
| 1975 // TODO(jhawkins): Investigate the use case for this method. | 1983 // TODO(jhawkins): Investigate the use case for this method. |
| 1976 BrowserOptions.getLoggedInUsername = function() { | 1984 BrowserOptions.getLoggedInUsername = function() { |
| 1977 return BrowserOptions.getInstance().username_; | 1985 return BrowserOptions.getInstance().username_; |
| 1978 }; | 1986 }; |
| 1979 } | 1987 } |
| 1980 | 1988 |
| 1981 // Export | 1989 // Export |
| 1982 return { | 1990 return { |
| 1983 BrowserOptions: BrowserOptions | 1991 BrowserOptions: BrowserOptions |
| 1984 }; | 1992 }; |
| 1985 }); | 1993 }); |
| OLD | NEW |