Chromium Code Reviews| 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 /** | 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 Loading... | |
| 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) { | |
|
stevenjb
2014/09/25 15:45:33
Again, this function name seems too generic for th
michaelpg
2014/09/29 18:50:56
enableElementIfAllowed? enableElementIfEditable? t
| |
| 65 if (cr.isChromeOS) { | |
|
stevenjb
2014/09/25 15:45:33
Shouldn't this always be true since this is in js/
michaelpg
2014/09/29 18:50:56
Yes. I've done a sanity check anyway, and nothing
| |
| 66 var sessionType; | |
| 67 if (UIAccountTweaks.loggedInAsGuest()) | |
| 68 sessionType = SESSION_TYPE_GUEST; | |
| 69 else if (UIAccountTweaks.loggedInAsPublicAccount()) | |
| 70 sessionType = SESSION_TYPE_PUBLIC; | |
| 71 | |
| 72 if (sessionType && | |
| 73 element.getAttribute(sessionType +'-visibility') == 'disabled') { | |
| 74 return; | |
| 75 } | |
| 76 } | |
| 77 | |
| 78 element.disabled = false; | |
| 79 } | |
| 80 | |
| 81 /** | |
| 60 * Disables or hides some elements in specified type of session in ChromeOS. | 82 * Disables or hides some elements in specified type of session in ChromeOS. |
| 61 * All elements within given document with *sessionType*-visibility | 83 * All elements within given document with *sessionType*-visibility |
| 62 * attribute are either hidden (for *sessionType*-visibility="hidden") | 84 * attribute are either hidden (for *sessionType*-visibility="hidden") |
| 63 * or disabled (for *sessionType*-visibility="disabled"). | 85 * or disabled (for *sessionType*-visibility="disabled"). |
| 64 * | 86 * |
| 65 * @param {Document} document Document that should processed. | 87 * @param {Document} document Document that should processed. |
| 66 * @param {string} sessionType name of the session type processed. | 88 * @param {string} sessionType name of the session type processed. |
| 67 * @private | 89 * @private |
| 68 */ | 90 */ |
| 69 UIAccountTweaks.applySessionTypeVisibility_ = function(document, | 91 UIAccountTweaks.applySessionTypeVisibility_ = function(document, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 }; | 176 }; |
| 155 } | 177 } |
| 156 }; | 178 }; |
| 157 | 179 |
| 158 // Export | 180 // Export |
| 159 return { | 181 return { |
| 160 UIAccountTweaks: UIAccountTweaks | 182 UIAccountTweaks: UIAccountTweaks |
| 161 }; | 183 }; |
| 162 | 184 |
| 163 }); | 185 }); |
| OLD | NEW |