OLD | NEW |
---|---|
(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 * Define a global entry point that will be set when the page is initialized. | |
7 * @return {?PolicyUi} | |
8 */ | |
9 cr.define('policy', function() { | |
10 return { Page: null }; | |
11 }); | |
12 | |
13 /** | |
14 * @fileoverview | |
15 * 'policy-ui' is the main MD element, combining the UI and models. | |
16 * | |
17 * Example: | |
18 * | |
19 * <policy-ui></policy-ui> | |
20 * | |
21 * @group Chrome Policy Elements | |
22 * @element policy-ui | |
23 */ | |
24 PolicyUi = Polymer({ | |
25 is: 'policy-ui', | |
26 | |
27 properties: { | |
28 /** Object containing title and text of the introduction card. */ | |
stevenjb
2015/10/09 16:10:14
You can (and should) type Object properties:
/**
fhorschig
2015/10/09 16:30:39
Nice to know, done for both classes.
| |
29 introduction: { | |
30 type: Object, | |
31 reflectToAttribute: false, | |
32 readOnly: true, | |
33 notify: false | |
34 } | |
35 }, | |
36 | |
37 /** @override */ | |
38 ready: function() { | |
39 // TODO(fhorschig): i18n! Replace sample text with reviewed message. | |
40 this._setIntroduction({ | |
41 title: 'Managed account policies', | |
42 text: | |
43 'Your device and your user account are managed which means that ' + | |
44 'some of your settings are fixed by your administrator.\n' + | |
45 'The cards below explain how the administrator\'s choices may ' + | |
46 'impact your privacy or security.' | |
47 }); | |
48 | |
49 // Set this element as receiver of calls to the Page. | |
50 policy.Page = this; | |
51 | |
52 // Notify the browser that the page has loaded, causing it to send the | |
53 // list of all known policies, the current policy values and the cloud | |
54 // policy status. | |
55 chrome.send('initialized'); | |
56 }, | |
57 | |
58 /** | |
59 * Looks for the existing PolicyGroup matching the |tag| and triggers adding | |
60 * the policy to it. | |
61 * @private | |
62 * @param {string} name Name of the policy. | |
63 * @param {string} tag Name of the policy's tag. | |
64 */ | |
65 addNameToTagGroup_: function(name, tag) { | |
66 for (var pos = 0; pos < this.$.groups.children.length; ++pos) | |
67 if (this.$.groups.children[pos].riskTag == tag) | |
68 this.$.groups.children[pos].addPolicy(name); | |
69 }, | |
70 | |
71 /** | |
72 * Removes DOM Elements and empties list of known tags. | |
73 * @private | |
74 */ | |
75 clearGroups_: function() { | |
76 while (this.$.groups.firstChild) | |
77 this.$.groups.removeChild(this.$.groups.firstChild); | |
78 }, | |
79 | |
80 /** | |
81 * Creates PolicyGroup and inserts it to list of known tags. | |
82 * @param {string} tag Name of the tag (included in i18n strings). | |
83 * @private | |
84 */ | |
85 createTagGroup_: function(tag) { | |
86 this.$.groups.appendChild(new PolicyGroup(tag)); | |
87 }, | |
88 | |
89 /** | |
90 * Receives a list of known tags and creates an empty policy list for each. | |
91 * @param {!Array<string>} tags List of tags. | |
92 */ | |
93 setPolicyGroups: function(tags) { | |
94 this.clearGroups_(); | |
95 tags.forEach(this.createTagGroup_.bind(this)); | |
96 }, | |
97 | |
98 /** | |
99 * Creates UI elements for tagged policies within the passed |names| object. | |
100 * @param {!{chromePolicyNames: !Object<!Array<string>>}} namesWithTags | |
101 */ | |
102 setPolicyNames: function(namesWithTags) { | |
103 for (var name in namesWithTags.chromePolicyNames) { | |
104 namesWithTags.chromePolicyNames[name].forEach( | |
105 this.addNameToTagGroup_.bind(this, name)); | |
106 } | |
107 }, | |
108 | |
109 /** | |
110 * Receives a list of current values that it hands down to children. | |
111 * @param {!{chromePolicies: !Object<string>}} values Current policies. | |
112 */ | |
113 setPolicyValues: function(values) { | |
114 // TODO(fhorschig): Update or notify tag groups. | |
115 }, | |
116 | |
117 /** | |
118 * Receives an object with meta data about the currently set policies. | |
119 * @param {!Object} status Dictionary containing meta data about set policies. | |
120 */ | |
121 setStatus: function(status) { | |
122 // TODO(fhorschig): Update |this.$.introduction| with status information. | |
123 // text according to policy status. | |
124 } | |
125 }); | |
OLD | NEW |