| 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 Page = cr.ui.pageManager.Page; | 6 var Page = cr.ui.pageManager.Page; |
| 7 var PageManager = cr.ui.pageManager.PageManager; | 7 var PageManager = cr.ui.pageManager.PageManager; |
| 8 | 8 |
| 9 ///////////////////////////////////////////////////////////////////////////// | 9 ///////////////////////////////////////////////////////////////////////////// |
| 10 // AccountsOptions class: | 10 // AccountsOptions class: |
| 11 | 11 |
| 12 /** | 12 /** |
| 13 * Encapsulated handling of ChromeOS accounts options page. | 13 * Encapsulated handling of ChromeOS accounts options page. |
| 14 * @constructor | 14 * @constructor |
| 15 * @extends {cr.ui.pageManager.Page} | 15 * @extends {cr.ui.pageManager.Page} |
| 16 */ | 16 */ |
| 17 function AccountsOptions(model) { | 17 function AccountsOptions(model) { |
| 18 Page.call(this, 'accounts', loadTimeData.getString('accountsPageTabTitle'), | 18 Page.call( |
| 19 'accountsPage'); | 19 this, 'accounts', loadTimeData.getString('accountsPageTabTitle'), |
| 20 'accountsPage'); |
| 20 // Whether to show the whitelist. | 21 // Whether to show the whitelist. |
| 21 this.showWhitelist_ = false; | 22 this.showWhitelist_ = false; |
| 22 } | 23 } |
| 23 | 24 |
| 24 cr.addSingletonGetter(AccountsOptions); | 25 cr.addSingletonGetter(AccountsOptions); |
| 25 | 26 |
| 26 AccountsOptions.prototype = { | 27 AccountsOptions.prototype = { |
| 27 // Inherit AccountsOptions from Page. | 28 // Inherit AccountsOptions from Page. |
| 28 __proto__: Page.prototype, | 29 __proto__: Page.prototype, |
| 29 | 30 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 45 this.showWhitelist_ = UIAccountTweaks.currentUserIsOwner(); | 46 this.showWhitelist_ = UIAccountTweaks.currentUserIsOwner(); |
| 46 if (this.showWhitelist_) { | 47 if (this.showWhitelist_) { |
| 47 options.accounts.UserList.decorate(userList); | 48 options.accounts.UserList.decorate(userList); |
| 48 } else { | 49 } else { |
| 49 $('ownerOnlyWarning').hidden = false; | 50 $('ownerOnlyWarning').hidden = false; |
| 50 this.managed = AccountsOptions.whitelistIsManaged(); | 51 this.managed = AccountsOptions.whitelistIsManaged(); |
| 51 } | 52 } |
| 52 | 53 |
| 53 this.addEventListener('visibleChange', this.handleVisibleChange_); | 54 this.addEventListener('visibleChange', this.handleVisibleChange_); |
| 54 | 55 |
| 55 $('useWhitelistCheck').addEventListener('change', | 56 $('useWhitelistCheck') |
| 56 this.handleUseWhitelistCheckChange_.bind(this)); | 57 .addEventListener( |
| 58 'change', this.handleUseWhitelistCheckChange_.bind(this)); |
| 57 | 59 |
| 58 Preferences.getInstance().addEventListener( | 60 Preferences.getInstance().addEventListener( |
| 59 $('useWhitelistCheck').pref, | 61 $('useWhitelistCheck').pref, |
| 60 this.handleUseWhitelistPrefChange_.bind(this)); | 62 this.handleUseWhitelistPrefChange_.bind(this)); |
| 61 | 63 |
| 62 $('accounts-options-overlay-confirm').onclick = | 64 $('accounts-options-overlay-confirm').onclick = |
| 63 PageManager.closeOverlay.bind(PageManager); | 65 PageManager.closeOverlay.bind(PageManager); |
| 64 }, | 66 }, |
| 65 | 67 |
| 66 /** | 68 /** |
| 67 * Update user list control state. | 69 * Update user list control state. |
| 68 * @private | 70 * @private |
| 69 */ | 71 */ |
| 70 updateControls_: function() { | 72 updateControls_: function() { |
| 71 $('userList').disabled = | 73 $('userList').disabled = $('userNameEdit').disabled = |
| 72 $('userNameEdit').disabled = !this.showWhitelist_ || | 74 !this.showWhitelist_ || AccountsOptions.whitelistIsManaged() || |
| 73 AccountsOptions.whitelistIsManaged() || | 75 !$('useWhitelistCheck').checked; |
| 74 !$('useWhitelistCheck').checked; | |
| 75 }, | 76 }, |
| 76 | 77 |
| 77 /** | 78 /** |
| 78 * Handler for Page's visible property change event. | 79 * Handler for Page's visible property change event. |
| 79 * @private | 80 * @private |
| 80 * @param {Event} e Property change event. | 81 * @param {Event} e Property change event. |
| 81 */ | 82 */ |
| 82 handleVisibleChange_: function(e) { | 83 handleVisibleChange_: function(e) { |
| 83 if (this.visible) { | 84 if (this.visible) { |
| 84 chrome.send('updateWhitelist'); | 85 chrome.send('updateWhitelist'); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 109 this.updateControls_(); | 110 this.updateControls_(); |
| 110 }, | 111 }, |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * Handler for "add" event fired from userNameEdit. | 114 * Handler for "add" event fired from userNameEdit. |
| 114 * @private | 115 * @private |
| 115 * @param {Event} e Add event fired from userNameEdit. | 116 * @param {Event} e Add event fired from userNameEdit. |
| 116 */ | 117 */ |
| 117 handleAddUser_: function(e) { | 118 handleAddUser_: function(e) { |
| 118 chrome.send('whitelistUser', [e.user.email, e.user.name]); | 119 chrome.send('whitelistUser', [e.user.email, e.user.name]); |
| 119 chrome.send('coreOptionsUserMetricsAction', | 120 chrome.send( |
| 120 ['Options_WhitelistedUser_Add']); | 121 'coreOptionsUserMetricsAction', ['Options_WhitelistedUser_Add']); |
| 121 }, | 122 }, |
| 122 | 123 |
| 123 /** | 124 /** |
| 124 * Handler for "remove" event fired from userList. | 125 * Handler for "remove" event fired from userList. |
| 125 * @private | 126 * @private |
| 126 * @param {Event} e Remove event fired from userList. | 127 * @param {Event} e Remove event fired from userList. |
| 127 */ | 128 */ |
| 128 handleRemoveUser_: function(e) { | 129 handleRemoveUser_: function(e) { |
| 129 chrome.send('unwhitelistUser', [e.user.username]); | 130 chrome.send('unwhitelistUser', [e.user.username]); |
| 130 chrome.send('coreOptionsUserMetricsAction', | 131 chrome.send( |
| 131 ['Options_WhitelistedUser_Remove']); | 132 'coreOptionsUserMetricsAction', ['Options_WhitelistedUser_Remove']); |
| 132 }, | 133 }, |
| 133 | 134 |
| 134 /** | 135 /** |
| 135 * Update account picture. | 136 * Update account picture. |
| 136 * @param {string} username User for which to update the image. | 137 * @param {string} username User for which to update the image. |
| 137 */ | 138 */ |
| 138 updateAccountPicture: function(username) { | 139 updateAccountPicture: function(username) { |
| 139 if (this.showWhitelist_) | 140 if (this.showWhitelist_) |
| 140 $('userList').updateAccountPicture(username); | 141 $('userList').updateAccountPicture(username); |
| 141 } | 142 } |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 | 145 |
| 145 /** | 146 /** |
| 146 * Returns whether the whitelist is managed by policy or not. | 147 * Returns whether the whitelist is managed by policy or not. |
| 147 */ | 148 */ |
| 148 AccountsOptions.whitelistIsManaged = function() { | 149 AccountsOptions.whitelistIsManaged = function() { |
| 149 return loadTimeData.getBoolean('whitelist_is_managed'); | 150 return loadTimeData.getBoolean('whitelist_is_managed'); |
| 150 }; | 151 }; |
| 151 | 152 |
| 152 | 153 |
| 153 // Export | 154 // Export |
| 154 return { | 155 return {AccountsOptions: AccountsOptions}; |
| 155 AccountsOptions: AccountsOptions | |
| 156 }; | |
| 157 | 156 |
| 158 }); | 157 }); |
| OLD | NEW |