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

Side by Side Diff: ui/webui/resources/cr_elements/v1_0/policy/cr_policy_pref_indicator.js

Issue 1391433003: Extract policy indicator behavior (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_521791_network_indicators_a
Patch Set: Created 5 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
OLDNEW
(Empty)
1 // Copyright 2015 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 /**
6 * @fileoverview Polymer element for indicating policies that apply to an
7 * element controlling a settings preference.
8 *
9 * @element cr-policy-pref-indicator
10 */
11 Polymer({
12 is: 'cr-policy-pref-indicator',
13
14 behaviors: [CrPolicyIndicatorBehavior, CrPolicyPrefBehavior],
15
16 properties: {
17 /**
18 * Optional preference object associated with the indicator. Initialized to
19 * null so that computed functions will get called if this is never set.
20 * @type {?chrome.settingsPrivate.PrefObject}
21 */
22 pref: {type: Object, value: null},
23
24 /**
25 * Optional email of the user controlling the setting when the setting does
26 * not correspond to a pref (Chrome OS only). Only used when pref is null.
27 * Initialized to '' so that computed functions will get called if this is
28 * never set.
29 */
30 controllingUser: {type: String, value: ''},
michaelpg 2015/10/07 18:18:35 TODO (for me or you): extract this to a separate i
stevenjb 2015/10/07 18:33:38 Done.
31
32 /**
33 * Which indicator type to show (or NONE).
34 * @type {CrPolicyIndicatorType}
35 */
36 indicatorType: {type: String, value: CrPolicyIndicatorType.NONE},
37 },
38
39 observers: ['prefPolicyChanged_(pref.policySource, pref.policyEnforcement)'],
40
41 /**
42 * Polymer observer for pref.
43 * @param {chrome.settingsPrivate.PolicySource} source
44 * @param {chrome.settingsPrivate.PolicyEnforcement} enforcement
45 * @private
46 */
47 prefPolicyChanged_: function(source, enforcement) {
48 this.indicatorType = this.getIndicatorType(source, enforcement);
49 },
50
51 /**
52 * @param {CrPolicyIndicatorType} type
53 * @param {?chrome.settingsPrivate.PrefObject} pref
54 * @return {string} The tooltip text for |type|.
55 * @private
56 */
57 getTooltip_: function(type, pref, controllingUser) {
58 if (type == CrPolicyIndicatorType.RECOMMENDED) {
59 if (pref && pref.value == pref.recommendedValue)
60 return this.i18n('controlledSettingRecommendedMatches');
61 return this.i18n('controlledSettingRecommendedDiffers');
62 }
63 var name = pref ? pref.policySourceName : controllingUser;
64 return this.getTooltipText(type, name);
65 }
66 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698