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

Side by Side Diff: chrome/browser/resources/options2/chromeos/accounts_options.js

Issue 10809005: Options: Rename chrome/browser/resources/options2 -> chrome/browser/resources/options. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix. Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('options', function() {
6 var OptionsPage = options.OptionsPage;
7
8 /////////////////////////////////////////////////////////////////////////////
9 // AccountsOptions class:
10
11 /**
12 * Encapsulated handling of ChromeOS accounts options page.
13 * @constructor
14 */
15 function AccountsOptions(model) {
16 OptionsPage.call(this, 'accounts',
17 loadTimeData.getString('accountsPageTabTitle'),
18 'accountsPage');
19 // Whether to show the whitelist.
20 this.showWhitelist_ = false;
21 }
22
23 cr.addSingletonGetter(AccountsOptions);
24
25 AccountsOptions.prototype = {
26 // Inherit AccountsOptions from OptionsPage.
27 __proto__: OptionsPage.prototype,
28
29 /**
30 * Initializes AccountsOptions page.
31 */
32 initializePage: function() {
33 // Call base class implementation to starts preference initialization.
34 OptionsPage.prototype.initializePage.call(this);
35
36 // Set up accounts page.
37 var userList = $('userList');
38 userList.addEventListener('remove', this.handleRemoveUser_);
39
40 var userNameEdit = $('userNameEdit');
41 options.accounts.UserNameEdit.decorate(userNameEdit);
42 userNameEdit.addEventListener('add', this.handleAddUser_);
43
44 // If the current user is not the owner, show some warning,
45 // and do not show the user list.
46 this.showWhitelist_ = UIAccountTweaks.currentUserIsOwner();
47 if (this.showWhitelist_) {
48 options.accounts.UserList.decorate(userList);
49 } else {
50 if (!AccountsOptions.whitelistIsManaged()) {
51 $('ownerOnlyWarning').hidden = false;
52 } else {
53 this.managed = true;
54 }
55 }
56
57 this.addEventListener('visibleChange', this.handleVisibleChange_);
58
59 $('useWhitelistCheck').addEventListener('change',
60 this.handleUseWhitelistCheckChange_.bind(this));
61
62 Preferences.getInstance().addEventListener(
63 $('useWhitelistCheck').pref,
64 this.handleUseWhitelistPrefChange_.bind(this));
65
66 $('accounts-options-overlay-confirm').onclick =
67 OptionsPage.closeOverlay.bind(OptionsPage);
68 },
69
70 /**
71 * Update user list control state.
72 * @private
73 */
74 updateControls_: function() {
75 $('userList').disabled =
76 $('userNameEdit').disabled = !this.showWhitelist_ ||
77 AccountsOptions.whitelistIsManaged() ||
78 !$('useWhitelistCheck').checked;
79 },
80
81 /**
82 * Handler for OptionsPage's visible property change event.
83 * @private
84 * @param {Event} e Property change event.
85 */
86 handleVisibleChange_: function(e) {
87 if (this.visible) {
88 this.updateControls_();
89 if (this.showWhitelist_)
90 $('userList').redraw();
91 }
92 },
93
94 /**
95 * Handler for allow guest check change.
96 * @private
97 */
98 handleUseWhitelistCheckChange_: function(e) {
99 // Whitelist existing users when guest login is being disabled.
100 if ($('useWhitelistCheck').checked) {
101 chrome.send('whitelistExistingUsers');
102 }
103
104 this.updateControls_();
105 },
106
107 /**
108 * handler for allow guest pref change.
109 * @private
110 */
111 handleUseWhitelistPrefChange_: function(e) {
112 this.updateControls_();
113 },
114
115 /**
116 * Handler for "add" event fired from userNameEdit.
117 * @private
118 * @param {Event} e Add event fired from userNameEdit.
119 */
120 handleAddUser_: function(e) {
121 chrome.send('whitelistUser', [e.user.email, e.user.name]);
122 },
123
124 /**
125 * Handler for "remove" event fired from userList.
126 * @private
127 * @param {Event} e Remove event fired from userList.
128 */
129 handleRemoveUser_: function(e) {
130 chrome.send('unwhitelistUser', [e.user.username]);
131 }
132 };
133
134
135 /**
136 * Returns whether the whitelist is managed by policy or not.
137 */
138 AccountsOptions.whitelistIsManaged = function() {
139 return loadTimeData.getBoolean('whitelist_is_managed');
140 };
141
142 /**
143 * Update account picture.
144 * @param {string} username User for which to update the image.
145 */
146 AccountsOptions.updateAccountPicture = function(username) {
147 if (this.showWhitelist_)
148 $('userList').updateAccountPicture(username);
149 };
150
151 // Export
152 return {
153 AccountsOptions: AccountsOptions
154 };
155
156 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698