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

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

Issue 9464053: Hide/Disable several (meaningless) options in Settings uber-page for Guest. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Another merge Created 8 years, 9 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 7
8 ///////////////////////////////////////////////////////////////////////////// 8 /////////////////////////////////////////////////////////////////////////////
9 // AccountsOptions class: 9 // AccountsOptions class:
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 * Returns whether the current user is owner or not. 134 * Returns whether the current user is owner or not.
135 */ 135 */
136 AccountsOptions.currentUserIsOwner = function() { 136 AccountsOptions.currentUserIsOwner = function() {
137 return localStrings.getString('current_user_is_owner') == 'true'; 137 return localStrings.getString('current_user_is_owner') == 'true';
138 }; 138 };
139 139
140 /** 140 /**
141 * Returns whether we're currently in guest mode. 141 * Returns whether we're currently in guest mode.
142 */ 142 */
143 AccountsOptions.loggedInAsGuest = function() { 143 AccountsOptions.loggedInAsGuest = function() {
144 return localStrings.getString('logged_in_as_guest') == 'true'; 144 return localStrings.getString('loggedInAsGuest') == 'true';
145 }; 145 };
146 146
147 /** 147 /**
148 * Returns whether the whitelist is managed by policy or not. 148 * Returns whether the whitelist is managed by policy or not.
149 */ 149 */
150 AccountsOptions.whitelistIsManaged = function() { 150 AccountsOptions.whitelistIsManaged = function() {
151 return localStrings.getString('whitelist_is_managed') == 'true'; 151 return localStrings.getString('whitelist_is_managed') == 'true';
152 }; 152 };
153 153
154 /** 154 /**
155 * Update account picture. 155 * Update account picture.
156 * @param {string} username User for which to update the image. 156 * @param {string} username User for which to update the image.
157 */ 157 */
158 AccountsOptions.updateAccountPicture = function(username) { 158 AccountsOptions.updateAccountPicture = function(username) {
159 if (this.showWhitelist_) 159 if (this.showWhitelist_)
160 $('userList').updateAccountPicture(username); 160 $('userList').updateAccountPicture(username);
161 }; 161 };
162 162
163 /**
164 * Disable or hide some elements in Guest mode in ChromeOS.
165 * All elements within given document with guest-visibility
166 * attribute are either hidden (for guest-visibility="hidden")
167 * or disabled (for guest-visibility="disabled").
168 *
169 * @param {Document} document Document that should processed.
170 */
171 AccountsOptions.applyGuestModeVisibility = function(document) {
172 if (!cr.isChromeOS || !AccountsOptions.loggedInAsGuest())
173 return;
174 var elements = document.querySelectorAll('[guest-visibility]');
175 for (var i = 0; i < elements.length; i++) {
176 var element = elements[i];
177 var visibility = element.getAttribute('guest-visibility');
178 if (visibility == 'hidden') {
179 element.hidden = true;
180 } else if (visibility == 'disabled') {
181 AccountsOptions.disableElementsForGuest(element);
182 }
183 }
184 }
185
186 /**
187 * Disables and marks page elements for Guest mode.
188 * Adds guest-disabled css class to all elements within given subtree,
189 * disables interactive elements (input/select/button), and removes href
190 * attribute from <a> elements.
191 *
192 * @param {Element} element Root element of DOM subtree that should be
193 * disabled.
194 */
195 AccountsOptions.disableElementsForGuest = function(element) {
196 AccountsOptions.disableElementForGuest_(element);
197
198 // Walk the tree, searching each ELEMENT node.
199 var walker = document.createTreeWalker(element,
200 NodeFilter.SHOW_ELEMENT,
201 null,
202 false);
203
204 var node = walker.nextNode();
205 while (node) {
206 AccountsOptions.disableElementForGuest_(node);
207 node = walker.nextNode();
208 }
209 };
210
211 /**
212 * Disables single element for Guest mode.
213 * Adds guest-disabled css class, adds disabled attribute for appropriate
214 * elements (input/select/button), and removes href attribute from
215 * <a> element.
216 *
217 * @private
218 * @param {Element} element Element that should be disabled.
219 */
220 AccountsOptions.disableElementForGuest_ = function(element) {
221 element.classList.add('guest-disabled');
222 if (element.nodeName == 'INPUT' ||
223 element.nodeName == 'SELECT' ||
224 element.nodeName == 'BUTTON')
225 element.disabled = true;
226 if (element.nodeName == 'A')
227 element.removeAttribute('href');
228 };
229
163 // Export 230 // Export
164 return { 231 return {
165 AccountsOptions: AccountsOptions 232 AccountsOptions: AccountsOptions
166 }; 233 };
167 234
168 }); 235 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698