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 * <policy-ui></policy-ui> | |
19 * | |
20 * @group Chrome Policy Elements | |
21 * @element policy-ui | |
22 */ | |
23 PolicyUi = Polymer({ | |
24 is: 'policy-ui', | |
25 | |
26 properties: { | |
27 /** | |
28 * Object containing title and text of the introduction card. | |
29 * @type {!{title: string, text: string}} | |
30 */ | |
31 introduction: { | |
32 type: Object, | |
33 // TODO(fhorschig): i18n! Replace sample text with reviewed message. | |
34 value: { | |
35 title: 'Managed account policies', | |
36 text: 'Your device and your user account are managed which means ' + | |
37 'that some of your settings are fixed by your administrator.\n' + | |
38 'The cards below explain how the administrator\'s choices may ' + | |
39 'impact your privacy or security.' | |
40 }, | |
41 readOnly: true, | |
42 }, | |
43 | |
44 /** | |
45 * Array containing all known tags. | |
46 * @type {!Array<Object<string>>} | |
47 * @private | |
48 */ | |
49 tags_: { | |
50 type: Array, | |
51 value: function() { return []; } | |
Dan Beam
2015/10/14 21:44:00
does this need an initial value?
fhorschig
2015/10/15 17:38:29
No. Deleted.
| |
52 } | |
53 }, | |
54 | |
55 /** @override */ | |
56 ready: function() { | |
57 // Set this element as receiver of calls to the Page. | |
58 policy.Page = this; | |
59 | |
60 // Notify the browser that the page has loaded, causing it to send the | |
61 // list of all known policies, the current policy values and the cloud | |
62 // policy status. | |
63 chrome.send('initialized'); | |
64 }, | |
65 | |
66 /** | |
67 * Receives a list of known tags and creates an empty policy list for each. | |
68 * @param {!Array<string>} tags List of tags. | |
69 */ | |
70 setPolicyGroups: function(tags) { | |
71 this.set('tags_', tags.map(function(tag) { | |
Dan Beam
2015/10/14 21:44:00
can we get away without this .map()?
fhorschig
2015/10/15 17:38:29
Yes, we can. Done.
| |
72 return {name: tag}; | |
73 })); | |
74 }, | |
75 | |
76 /** | |
77 * Creates UI elements for tagged policies within the passed |names| object. | |
78 * @param {!{chromePolicyNames: !Object<!Array<string>>}} namesWithTags | |
79 */ | |
80 setPolicyNames: function(namesWithTags) { | |
81 for (var name in namesWithTags.chromePolicyNames) { | |
82 namesWithTags.chromePolicyNames[name].forEach((function(tag) { | |
83 this.$.groups.querySelector('[risk-tag="' + tag + '"]').addPolicy(name); | |
84 }).bind(this)); | |
85 } | |
86 }, | |
87 | |
88 /** | |
89 * Receives a list of current values that it hands down to children. | |
90 * @param {!{chromePolicies: !Object<string>}} values Current policies. | |
91 */ | |
92 setPolicyValues: function(values) { | |
93 // TODO(fhorschig): Update or notify tag groups. | |
94 }, | |
95 | |
96 /** | |
97 * Receives an object with meta data about the currently set policies. | |
98 * @param {!Object} status Dictionary containing meta data about set policies. | |
99 */ | |
100 setStatus: function(status) { | |
101 // TODO(fhorschig): Update |this.$.introduction| with status information. | |
102 // text according to policy status. | |
103 } | |
104 }); | |
OLD | NEW |