Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(278)

Side by Side Diff: chrome/browser/resources/options/browser_options.js

Issue 557633002: Add public API generation with cr.makePublic() and handle it in compiler pass (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@H_options_errors_3
Patch Set: fix bug with oobe Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 if (section.classList.contains('sliding')) 736 if (section.classList.contains('sliding'))
736 cr.dispatchSimpleEvent(section, 'webkitTransitionEnd'); 737 cr.dispatchSimpleEvent(section, 'webkitTransitionEnd');
737 738
738 this.addTransitionEndListener_(section); 739 this.addTransitionEndListener_(section);
739 740
740 section.hidden = false; 741 section.hidden = false;
741 section.style.height = (showing ? 0 : container.offsetHeight) + 'px'; 742 section.style.height = (showing ? 0 : container.offsetHeight) + 'px';
742 section.classList.add('sliding'); 743 section.classList.add('sliding');
743 744
744 // Force a style recalc before starting the animation. 745 // Force a style recalc before starting the animation.
745 /** @suppress {uselessCode} */ 746 /** @suppress {suspiciousCode} */
746 section.offsetHeight; 747 section.offsetHeight;
747 748
748 section.style.height = (showing ? container.offsetHeight : 0) + 'px'; 749 section.style.height = (showing ? container.offsetHeight : 0) + 'px';
749 }, 750 },
750 751
751 /** 752 /**
752 * Shows the given section. 753 * Shows the given section.
753 * @param {HTMLElement} section The section to be shown. 754 * @param {HTMLElement} section The section to be shown.
754 * @param {HTMLElement} container The container for the section. Must be 755 * @param {HTMLElement} container The container for the section. Must be
755 * inside of |section|. 756 * inside of |section|.
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 1423
1423 /** 1424 /**
1424 * Propmpts user to confirm deletion of the profile for this browser 1425 * Propmpts user to confirm deletion of the profile for this browser
1425 * window. 1426 * window.
1426 * @private 1427 * @private
1427 */ 1428 */
1428 deleteCurrentProfile_: function() { 1429 deleteCurrentProfile_: function() {
1429 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_()); 1430 ManageProfileOverlay.showDeleteDialog(this.getCurrentProfile_());
1430 }, 1431 },
1431 1432
1433 /**
1434 * @param {boolean} enabled
1435 */
1432 setNativeThemeButtonEnabled_: function(enabled) { 1436 setNativeThemeButtonEnabled_: function(enabled) {
1433 var button = $('themes-native-button'); 1437 var button = $('themes-native-button');
1434 if (button) 1438 if (button)
1435 button.disabled = !enabled; 1439 button.disabled = !enabled;
1436 }, 1440 },
1437 1441
1442 /**
1443 * @param {boolean} enabled
1444 */
1438 setThemesResetButtonEnabled_: function(enabled) { 1445 setThemesResetButtonEnabled_: function(enabled) {
1439 $('themes-reset').disabled = !enabled; 1446 $('themes-reset').disabled = !enabled;
1440 }, 1447 },
1441 1448
1449 /**
1450 * @param {boolean} managed
1451 */
1442 setAccountPictureManaged_: function(managed) { 1452 setAccountPictureManaged_: function(managed) {
1443 var picture = $('account-picture'); 1453 var picture = $('account-picture');
1444 if (managed || UIAccountTweaks.loggedInAsGuest()) { 1454 if (managed || UIAccountTweaks.loggedInAsGuest()) {
1445 picture.disabled = true; 1455 picture.disabled = true;
1446 ChangePictureOptions.closeOverlay(); 1456 ChangePictureOptions.closeOverlay();
1447 } else { 1457 } else {
1448 picture.disabled = false; 1458 picture.disabled = false;
1449 } 1459 }
1450 1460
1451 // Create a synthetic pref change event decorated as 1461 // Create a synthetic pref change event decorated as
(...skipping 11 matching lines...) Expand all
1463 * @private 1473 * @private
1464 */ 1474 */
1465 updateAccountPicture_: function() { 1475 updateAccountPicture_: function() {
1466 var picture = $('account-picture'); 1476 var picture = $('account-picture');
1467 if (picture) { 1477 if (picture) {
1468 picture.src = 'chrome://userimage/' + this.username_ + '?id=' + 1478 picture.src = 'chrome://userimage/' + this.username_ + '?id=' +
1469 Date.now(); 1479 Date.now();
1470 } 1480 }
1471 }, 1481 },
1472 1482
1483 /**
1484 * @param {boolean} managed
1485 */
1473 setWallpaperManaged_: function(managed) { 1486 setWallpaperManaged_: function(managed) {
1474 var button = $('set-wallpaper'); 1487 var button = $('set-wallpaper');
1475 button.disabled = !!managed; 1488 button.disabled = !!managed;
1476 1489
1477 // Create a synthetic pref change event decorated as 1490 // Create a synthetic pref change event decorated as
1478 // CoreOptionsHandler::CreateValueForPref() does. 1491 // CoreOptionsHandler::CreateValueForPref() does.
1479 var event = new Event('wallpaper'); 1492 var event = new Event('wallpaper');
1480 if (managed) 1493 if (managed)
1481 event.value = { controlledBy: 'policy' }; 1494 event.value = { controlledBy: 'policy' };
1482 else 1495 else
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 /** 1927 /**
1915 * Handle the 'set date and time' button click. 1928 * Handle the 'set date and time' button click.
1916 * @private 1929 * @private
1917 */ 1930 */
1918 handleSetTime_: function() { 1931 handleSetTime_: function() {
1919 chrome.send('showSetTime'); 1932 chrome.send('showSetTime');
1920 }, 1933 },
1921 }; 1934 };
1922 1935
1923 //Forward public APIs to private implementations. 1936 //Forward public APIs to private implementations.
1924 [ 1937 cr.makePublic(BrowserOptions, [
1925 'addBluetoothDevice', 1938 'addBluetoothDevice',
1926 'deleteCurrentProfile', 1939 'deleteCurrentProfile',
1927 'enableCertificateButton', 1940 'enableCertificateButton',
1928 'enableFactoryResetSection', 1941 'enableFactoryResetSection',
1929 'getCurrentProfile', 1942 'getCurrentProfile',
1930 'getStartStopSyncButton', 1943 'getStartStopSyncButton',
1931 'hideBluetoothSettings', 1944 'hideBluetoothSettings',
1932 'notifyInitializationComplete', 1945 'notifyInitializationComplete',
1933 'removeBluetoothDevice', 1946 'removeBluetoothDevice',
1934 'scrollToSection', 1947 'scrollToSection',
(...skipping 24 matching lines...) Expand all
1959 'showSupervisedUserImportError', 1972 'showSupervisedUserImportError',
1960 'showSupervisedUserImportSuccess', 1973 'showSupervisedUserImportSuccess',
1961 'showTouchpadControls', 1974 'showTouchpadControls',
1962 'toggleExtensionIndicators', 1975 'toggleExtensionIndicators',
1963 'updateAccountPicture', 1976 'updateAccountPicture',
1964 'updateAutoLaunchState', 1977 'updateAutoLaunchState',
1965 'updateDefaultBrowserState', 1978 'updateDefaultBrowserState',
1966 'updateEasyUnlock', 1979 'updateEasyUnlock',
1967 'updateManagesSupervisedUsers', 1980 'updateManagesSupervisedUsers',
1968 'updateSearchEngines', 1981 'updateSearchEngines',
1969 'updateStartupPages',
1970 'updateSyncState', 1982 'updateSyncState',
1971 ].forEach(function(name) { 1983 ]);
1972 BrowserOptions[name] = function() {
1973 var instance = BrowserOptions.getInstance();
1974 return instance[name + '_'].apply(instance, arguments);
1975 };
1976 });
1977 1984
1978 if (cr.isChromeOS) { 1985 if (cr.isChromeOS) {
1979 /** 1986 /**
1980 * Returns username (canonical email) of the user logged in (ChromeOS only). 1987 * Returns username (canonical email) of the user logged in (ChromeOS only).
1981 * @return {string} user email. 1988 * @return {string} user email.
1982 */ 1989 */
1983 // TODO(jhawkins): Investigate the use case for this method. 1990 // TODO(jhawkins): Investigate the use case for this method.
1984 BrowserOptions.getLoggedInUsername = function() { 1991 BrowserOptions.getLoggedInUsername = function() {
1985 return BrowserOptions.getInstance().username_; 1992 return BrowserOptions.getInstance().username_;
1986 }; 1993 };
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 } 2028 }
2022 button.textContent = loadTimeData.getString(strId); 2029 button.textContent = loadTimeData.getString(strId);
2023 }; 2030 };
2024 } 2031 }
2025 2032
2026 // Export 2033 // Export
2027 return { 2034 return {
2028 BrowserOptions: BrowserOptions 2035 BrowserOptions: BrowserOptions
2029 }; 2036 };
2030 }); 2037 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698