Index: chrome/browser/resources/options/personal_options.js |
diff --git a/chrome/browser/resources/options/personal_options.js b/chrome/browser/resources/options/personal_options.js |
deleted file mode 100644 |
index a3c705990b8528943cbbadf4d06a618f45ca2bd0..0000000000000000000000000000000000000000 |
--- a/chrome/browser/resources/options/personal_options.js |
+++ /dev/null |
@@ -1,375 +0,0 @@ |
-// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
-// Use of this source code is governed by a BSD-style license that can be |
-// found in the LICENSE file. |
- |
-cr.define('options', function() { |
- |
- var OptionsPage = options.OptionsPage; |
- var ArrayDataModel = cr.ui.ArrayDataModel; |
- |
- /** |
- * Encapsulated handling of personal options page. |
- * @constructor |
- */ |
- function PersonalOptions() { |
- OptionsPage.call(this, 'personal', |
- templateData.personalPageTabTitle, |
- 'personal-page'); |
- if (cr.isChromeOS) { |
- // Username (canonical email) of the currently logged in user or |
- // |kGuestUser| if a guest session is active. |
- this.username_ = localStrings.getString('username'); |
- } |
- } |
- |
- cr.addSingletonGetter(PersonalOptions); |
- |
- PersonalOptions.prototype = { |
- // Inherit PersonalOptions from OptionsPage. |
- __proto__: options.OptionsPage.prototype, |
- |
- // State variables. |
- syncEnabled: false, |
- syncSetupCompleted: false, |
- |
- // Initialize PersonalOptions page. |
- initializePage: function() { |
- // Call base class implementation to start preference initialization. |
- OptionsPage.prototype.initializePage.call(this); |
- |
- var self = this; |
- |
- // Sync. |
- $('sync-action-link').onclick = function(event) { |
- SyncSetupOverlay.showErrorUI(); |
- }; |
- $('start-stop-sync').onclick = function(event) { |
- if (self.syncSetupCompleted) |
- SyncSetupOverlay.showStopSyncingUI(); |
- else |
- SyncSetupOverlay.showSetupUI(); |
- }; |
- $('customize-sync').onclick = function(event) { |
- SyncSetupOverlay.showSetupUI(); |
- }; |
- |
- // Profiles. |
- var profilesList = $('profiles-list'); |
- options.personal_options.ProfileList.decorate(profilesList); |
- profilesList.autoExpands = true; |
- |
- profilesList.onchange = self.setProfileViewButtonsStatus_; |
- $('profiles-create').onclick = function(event) { |
- chrome.send('createProfile'); |
- }; |
- $('profiles-manage').onclick = function(event) { |
- var selectedProfile = self.getSelectedProfileItem_(); |
- if (selectedProfile) |
- ManageProfileOverlay.showManageDialog(selectedProfile); |
- }; |
- $('profiles-delete').onclick = function(event) { |
- var selectedProfile = self.getSelectedProfileItem_(); |
- if (selectedProfile) |
- ManageProfileOverlay.showDeleteDialog(selectedProfile); |
- }; |
- |
- // Passwords. |
- $('manage-passwords').onclick = function(event) { |
- OptionsPage.navigateToPage('passwords'); |
- OptionsPage.showTab($('passwords-nav-tab')); |
- chrome.send('coreOptionsUserMetricsAction', |
- ['Options_ShowPasswordManager']); |
- }; |
- |
- // Autofill. |
- $('autofill-settings').onclick = function(event) { |
- OptionsPage.navigateToPage('autofill'); |
- chrome.send('coreOptionsUserMetricsAction', |
- ['Options_ShowAutofillSettings']); |
- }; |
- if (cr.isChromeOS && cr.commandLine && cr.commandLine.options['--bwsi']) { |
- // Hide Autofill options for the guest user. |
- $('autofill-section').hidden = true; |
- } |
- |
- // Appearance. |
- $('themes-reset').onclick = function(event) { |
- chrome.send('themesReset'); |
- }; |
- |
- if (!cr.isChromeOS) { |
- $('import-data').onclick = function(event) { |
- // Make sure that any previous import success message is hidden, and |
- // we're showing the UI to import further data. |
- $('import-data-configure').hidden = false; |
- $('import-data-success').hidden = true; |
- OptionsPage.navigateToPage('importData'); |
- chrome.send('coreOptionsUserMetricsAction', ['Import_ShowDlg']); |
- }; |
- |
- if ($('themes-GTK-button')) { |
- $('themes-GTK-button').onclick = function(event) { |
- chrome.send('themesSetGTK'); |
- }; |
- } |
- } else { |
- $('change-picture-button').onclick = function(event) { |
- OptionsPage.navigateToPage('changePicture'); |
- }; |
- this.updateAccountPicture_(); |
- |
- if (cr.commandLine && cr.commandLine.options['--bwsi']) { |
- // Disable the screen lock checkbox and change-picture-button in |
- // guest mode. |
- $('enable-screen-lock').disabled = true; |
- $('change-picture-button').disabled = true; |
- } |
- } |
- |
- if (PersonalOptions.disablePasswordManagement()) { |
- // Disable the Password Manager in guest mode. |
- $('passwords-offersave').disabled = true; |
- $('passwords-neversave').disabled = true; |
- $('passwords-offersave').value = false; |
- $('passwords-neversave').value = true; |
- $('manage-passwords').disabled = true; |
- } |
- |
- if (cr.isMac) { |
- $('mac-passwords-warning').hidden = |
- !(localStrings.getString('macPasswordsWarning')); |
- } |
- |
- if (PersonalOptions.disableAutofillManagement()) { |
- $('autofill-settings').disabled = true; |
- |
- // Disable and turn off autofill. |
- var autofillEnabled = $('autofill-enabled'); |
- autofillEnabled.disabled = true; |
- autofillEnabled.checked = false; |
- cr.dispatchSimpleEvent(autofillEnabled, 'change'); |
- } |
- }, |
- |
- setSyncEnabled_: function(enabled) { |
- this.syncEnabled = enabled; |
- }, |
- |
- setAutoLoginVisible_ : function(visible) { |
- $('enable-auto-login-checkbox').hidden = !visible; |
- }, |
- |
- setSyncSetupCompleted_: function(completed) { |
- this.syncSetupCompleted = completed; |
- $('customize-sync').hidden = !completed; |
- }, |
- |
- setSyncStatus_: function(status) { |
- var statusSet = status != ''; |
- $('sync-overview').hidden = statusSet; |
- $('sync-status').hidden = !statusSet; |
- $('sync-status-text').innerHTML = status; |
- }, |
- |
- setSyncStatusErrorVisible_: function(visible) { |
- visible ? $('sync-status').classList.add('sync-error') : |
- $('sync-status').classList.remove('sync-error'); |
- }, |
- |
- setCustomizeSyncButtonEnabled_: function(enabled) { |
- $('customize-sync').disabled = !enabled; |
- }, |
- |
- setSyncActionLinkEnabled_: function(enabled) { |
- $('sync-action-link').disabled = !enabled; |
- }, |
- |
- setSyncActionLinkLabel_: function(status) { |
- $('sync-action-link').textContent = status; |
- |
- // link-button does is not zero-area when the contents of the button are |
- // empty, so explicitly hide the element. |
- $('sync-action-link').hidden = !status.length; |
- }, |
- |
- /** |
- * Display or hide the profiles section of the page. This is used for |
- * multi-profile settings. |
- * @param {boolean} visible True to show the section. |
- * @private |
- */ |
- setProfilesSectionVisible_: function(visible) { |
- $('profiles-section').hidden = !visible; |
- }, |
- |
- /** |
- * Get the selected profile item from the profile list. This also works |
- * correctly if the list is not displayed. |
- * @return {Object} the profile item object, or null if nothing is selected. |
- * @private |
- */ |
- getSelectedProfileItem_: function() { |
- var profilesList = $('profiles-list'); |
- if (profilesList.hidden) { |
- if (profilesList.dataModel.length > 0) |
- return profilesList.dataModel.item(0); |
- } else { |
- return profilesList.selectedItem; |
- } |
- return null; |
- }, |
- |
- /** |
- * Helper function to set the status of profile view buttons to disabled or |
- * enabled, depending on the number of profiles and selection status of the |
- * profiles list. |
- */ |
- setProfileViewButtonsStatus_: function() { |
- var profilesList = $('profiles-list'); |
- var selectedProfile = profilesList.selectedItem; |
- var hasSelection = selectedProfile != null; |
- var hasSingleProfile = profilesList.dataModel.length == 1; |
- $('profiles-manage').disabled = !hasSelection || |
- !selectedProfile.isCurrentProfile; |
- $('profiles-delete').disabled = !hasSelection && !hasSingleProfile; |
- }, |
- |
- /** |
- * Display the correct dialog layout, depending on how many profiles are |
- * available. |
- * @param {number} numProfiles The number of profiles to display. |
- */ |
- setProfileViewSingle_: function(numProfiles) { |
- var hasSingleProfile = numProfiles == 1; |
- $('profiles-list').hidden = hasSingleProfile; |
- $('profiles-single-message').hidden = !hasSingleProfile; |
- $('profiles-manage').hidden = hasSingleProfile; |
- $('profiles-delete').textContent = hasSingleProfile ? |
- templateData.profilesDeleteSingle : |
- templateData.profilesDelete; |
- }, |
- |
- /** |
- * Adds all |profiles| to the list. |
- * @param {Array.<Object>} An array of profile info objects. |
- * each object is of the form: |
- * profileInfo = { |
- * name: "Profile Name", |
- * iconURL: "chrome://path/to/icon/image", |
- * filePath: "/path/to/profile/data/on/disk", |
- * isCurrentProfile: false |
- * }; |
- */ |
- setProfilesInfo_: function(profiles) { |
- this.setProfileViewSingle_(profiles.length); |
- // add it to the list, even if the list is hidden so we can access it |
- // later. |
- $('profiles-list').dataModel = new ArrayDataModel(profiles); |
- this.setProfileViewButtonsStatus_(); |
- }, |
- |
- setStartStopButtonVisible_: function(visible) { |
- $('start-stop-sync').hidden = !visible; |
- }, |
- |
- setStartStopButtonEnabled_: function(enabled) { |
- $('start-stop-sync').disabled = !enabled; |
- }, |
- |
- setStartStopButtonLabel_: function(label) { |
- $('start-stop-sync').textContent = label; |
- }, |
- |
- setGtkThemeButtonEnabled_: function(enabled) { |
- if (!cr.isChromeOS && navigator.platform.match(/linux|BSD/i)) { |
- $('themes-GTK-button').disabled = !enabled; |
- } |
- }, |
- |
- setThemesResetButtonEnabled_: function(enabled) { |
- $('themes-reset').disabled = !enabled; |
- }, |
- |
- hideSyncSection_: function() { |
- $('sync-section').hidden = true; |
- }, |
- |
- /** |
- * Get the start/stop sync button DOM element. |
- * @return {DOMElement} The start/stop sync button. |
- * @private |
- */ |
- getStartStopSyncButton_: function() { |
- return $('start-stop-sync'); |
- }, |
- |
- /** |
- * (Re)loads IMG element with current user account picture. |
- */ |
- updateAccountPicture_: function() { |
- $('account-picture').src = |
- 'chrome://userimage/' + this.username_ + |
- '?id=' + (new Date()).getTime(); |
- }, |
- }; |
- |
- /** |
- * Returns whether the user should be able to manage (view and edit) their |
- * stored passwords. Password management is disabled in guest mode. |
- * @return {boolean} True if password management should be disabled. |
- */ |
- PersonalOptions.disablePasswordManagement = function() { |
- return cr.commandLine && cr.commandLine.options['--bwsi']; |
- }; |
- |
- /** |
- * Returns whether the user should be able to manage autofill settings. |
- * @return {boolean} True if password management should be disabled. |
- */ |
- PersonalOptions.disableAutofillManagement = function() { |
- return cr.commandLine && cr.commandLine.options['--bwsi']; |
- }; |
- |
- if (cr.isChromeOS) { |
- /** |
- * Returns username (canonical email) of the user logged in (ChromeOS only). |
- * @return {string} user email. |
- */ |
- PersonalOptions.getLoggedInUsername = function() { |
- return PersonalOptions.getInstance().username_; |
- }; |
- } |
- |
- // Forward public APIs to private implementations. |
- [ |
- 'getStartStopSyncButton', |
- 'hideSyncSection', |
- 'setAutoLoginVisible', |
- 'setCustomizeSyncButtonEnabled', |
- 'setGtkThemeButtonEnabled', |
- 'setProfilesInfo', |
- 'setProfilesSectionVisible', |
- 'setStartStopButtonEnabled', |
- 'setStartStopButtonLabel', |
- 'setStartStopButtonVisible', |
- 'setSyncActionLinkEnabled', |
- 'setSyncActionLinkLabel', |
- 'setSyncEnabled', |
- 'setSyncSetupCompleted', |
- 'setSyncStatus', |
- 'setSyncStatusErrorVisible', |
- 'setThemesResetButtonEnabled', |
- 'updateAccountPicture', |
- ].forEach(function(name) { |
- PersonalOptions[name] = function() { |
- var instance = PersonalOptions.getInstance(); |
- return instance[name + '_'].apply(instance, arguments); |
- }; |
- }); |
- |
- // Export |
- return { |
- PersonalOptions: PersonalOptions |
- }; |
- |
-}); |