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

Side by Side Diff: ui/webui/resources/js/chromeos/ui_account_tweaks.js

Issue 599723002: Disable wallpaper button in Guest mode settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/resources/options/browser_options.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * @fileoverview This file contains methods that allow to tweak 6 * @fileoverview This file contains methods that allow to tweak
7 * internal page UI based on the status of current user (owner/user/guest). 7 * internal page UI based on the status of current user (owner/user/guest).
8 * It is assumed that required data is passed via i18n strings 8 * It is assumed that required data is passed via i18n strings
9 * (using loadTimeData dictionary) that are filled with call to 9 * (using loadTimeData dictionary) that are filled with call to
10 * AddAccountUITweaksLocalizedValues in ui_account_tweaks.cc. 10 * AddAccountUITweaksLocalizedValues in ui_account_tweaks.cc.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 }; 50 };
51 51
52 /** 52 /**
53 * @return {boolean} Whether we're currently in supervised user mode. 53 * @return {boolean} Whether we're currently in supervised user mode.
54 */ 54 */
55 UIAccountTweaks.loggedInAsSupervisedUser = function() { 55 UIAccountTweaks.loggedInAsSupervisedUser = function() {
56 return loadTimeData.getBoolean('loggedInAsSupervisedUser'); 56 return loadTimeData.getBoolean('loggedInAsSupervisedUser');
57 }; 57 };
58 58
59 /** 59 /**
60 * Enables an element unless it should be disabled for the session type.
61 *
62 * @param {!Element} element Element that should be enabled.
63 */
64 UIAccountTweaks.enableElementIfPossible = function(element) {
65 var sessionType;
66 if (UIAccountTweaks.loggedInAsGuest())
67 sessionType = SESSION_TYPE_GUEST;
68 else if (UIAccountTweaks.loggedInAsPublicAccount())
69 sessionType = SESSION_TYPE_PUBLIC;
70
71 if (sessionType &&
72 element.getAttribute(sessionType + '-visibility') == 'disabled') {
73 return;
74 }
75
76 element.disabled = false;
77 }
78
79 /**
60 * Disables or hides some elements in specified type of session in ChromeOS. 80 * Disables or hides some elements in specified type of session in ChromeOS.
61 * All elements within given document with *sessionType*-visibility 81 * All elements within given document with *sessionType*-visibility
62 * attribute are either hidden (for *sessionType*-visibility="hidden") 82 * attribute are either hidden (for *sessionType*-visibility="hidden")
63 * or disabled (for *sessionType*-visibility="disabled"). 83 * or disabled (for *sessionType*-visibility="disabled").
64 * 84 *
65 * @param {Document} document Document that should processed. 85 * @param {Document} document Document that should processed.
66 * @param {string} sessionType name of the session type processed. 86 * @param {string} sessionType name of the session type processed.
67 * @private 87 * @private
68 */ 88 */
69 UIAccountTweaks.applySessionTypeVisibility_ = function(document, 89 UIAccountTweaks.applySessionTypeVisibility_ = function(document,
70 sessionType) { 90 sessionType) {
71 var elements = document.querySelectorAll('['+ sessionType +'-visibility]'); 91 var elements = document.querySelectorAll('['+ sessionType + '-visibility]');
72 for (var i = 0; i < elements.length; i++) { 92 for (var i = 0; i < elements.length; i++) {
73 var element = elements[i]; 93 var element = elements[i];
74 var visibility = element.getAttribute(sessionType +'-visibility'); 94 var visibility = element.getAttribute(sessionType + '-visibility');
75 if (visibility == 'hidden') 95 if (visibility == 'hidden')
76 element.hidden = true; 96 element.hidden = true;
77 else if (visibility == 'disabled') 97 else if (visibility == 'disabled')
78 UIAccountTweaks.disableElementsForSessionType(element, sessionType); 98 UIAccountTweaks.disableElementsForSessionType(element, sessionType);
79 } 99 }
80 } 100 }
81 101
82 /** 102 /**
83 * Updates specific visibility of elements for Guest session in ChromeOS. 103 * Updates specific visibility of elements for Guest session in ChromeOS.
84 * Calls applySessionTypeVisibility_ method. 104 * Calls applySessionTypeVisibility_ method.
85 * 105 *
86 * @param {Document} document Document that should processed. 106 * @param {Document} document Document that should processed.
87 */ 107 */
88 UIAccountTweaks.applyGuestSessionVisibility = function(document) { 108 UIAccountTweaks.applyGuestSessionVisibility = function(document) {
89 if (!cr.isChromeOS || !UIAccountTweaks.loggedInAsGuest()) 109 if (!UIAccountTweaks.loggedInAsGuest())
90 return; 110 return;
91 UIAccountTweaks.applySessionTypeVisibility_(document, SESSION_TYPE_GUEST); 111 UIAccountTweaks.applySessionTypeVisibility_(document, SESSION_TYPE_GUEST);
92 } 112 }
93 113
94 /** 114 /**
95 * Updates specific visibility of elements for Public account session in 115 * Updates specific visibility of elements for Public account session in
96 * ChromeOS. Calls applySessionTypeVisibility_ method. 116 * ChromeOS. Calls applySessionTypeVisibility_ method.
97 * 117 *
98 * @param {Document} document Document that should processed. 118 * @param {Document} document Document that should processed.
99 */ 119 */
100 UIAccountTweaks.applyPublicSessionVisibility = function(document) { 120 UIAccountTweaks.applyPublicSessionVisibility = function(document) {
101 if (!cr.isChromeOS || !UIAccountTweaks.loggedInAsPublicAccount()) 121 if (!UIAccountTweaks.loggedInAsPublicAccount())
102 return; 122 return;
103 UIAccountTweaks.applySessionTypeVisibility_(document, SESSION_TYPE_PUBLIC); 123 UIAccountTweaks.applySessionTypeVisibility_(document, SESSION_TYPE_PUBLIC);
104 } 124 }
105 125
106 /** 126 /**
107 * Disables and marks page elements for specified session type. 127 * Disables and marks page elements for specified session type.
108 * Adds #-disabled css class to all elements within given subtree, 128 * Adds #-disabled css class to all elements within given subtree,
109 * disables interactive elements (input/select/button), and removes href 129 * disables interactive elements (input/select/button), and removes href
110 * attribute from <a> elements. 130 * attribute from <a> elements.
111 * 131 *
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 }; 174 };
155 } 175 }
156 }; 176 };
157 177
158 // Export 178 // Export
159 return { 179 return {
160 UIAccountTweaks: UIAccountTweaks 180 UIAccountTweaks: UIAccountTweaks
161 }; 181 };
162 182
163 }); 183 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/browser_options.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698