Chromium Code Reviews| 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 }; | |
|
Dan Beam
2015/10/10 01:04:18
{Page: null}
fhorschig
2015/10/13 16:29:11
Done.
| |
| 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> | |
|
Dan Beam
2015/10/10 01:04:18
1 less space
fhorschig
2015/10/13 16:29:11
Done.
| |
| 20 * | |
| 21 * @group Chrome Policy Elements | |
| 22 * @element policy-ui | |
| 23 */ | |
| 24 PolicyUi = Polymer({ | |
| 25 is: 'policy-ui', | |
| 26 | |
| 27 properties: { | |
| 28 /** | |
| 29 * Object containing title and text of the introduction card. | |
| 30 * @type {!{ title: string, text: string }|undefined} | |
|
Dan Beam
2015/10/10 01:04:18
{title: string, text: string}
fhorschig
2015/10/13 16:29:11
Done.
| |
| 31 */ | |
| 32 introduction: { | |
| 33 type: Object, | |
| 34 reflectToAttribute: false, | |
| 35 readOnly: true, | |
| 36 notify: false | |
| 37 } | |
| 38 }, | |
| 39 | |
| 40 /** @override */ | |
| 41 ready: function() { | |
| 42 // TODO(fhorschig): i18n! Replace sample text with reviewed message. | |
| 43 this._setIntroduction({ | |
|
Dan Beam
2015/10/10 01:04:18
don't call _ methods outside of your class
stevenjb
2015/10/12 16:55:37
You can just use:
this.introduction = { title: ..
fhorschig
2015/10/13 16:29:11
Isn't this "inside" my class? Isn't this setter ex
fhorschig
2015/10/13 16:29:11
Apparently, setting the object like this doesn't t
Dan Beam
2015/10/13 16:56:09
this.set('introduction', {...});
stevenjb
2015/10/13 17:30:15
Polymer is a little funny regarding object notific
stevenjb
2015/10/13 18:36:50
I messed the 'readOnly' comment earlier. If you wa
fhorschig
2015/10/14 18:23:41
This works good for the introduction. The other pr
| |
| 44 title: 'Managed account policies', | |
| 45 text: | |
| 46 'Your device and your user account are managed which means that ' + | |
| 47 'some of your settings are fixed by your administrator.\n' + | |
| 48 'The cards below explain how the administrator\'s choices may ' + | |
| 49 'impact your privacy or security.' | |
| 50 }); | |
| 51 | |
| 52 // Set this element as receiver of calls to the Page. | |
| 53 policy.Page = this; | |
| 54 | |
| 55 // Notify the browser that the page has loaded, causing it to send the | |
| 56 // list of all known policies, the current policy values and the cloud | |
| 57 // policy status. | |
| 58 chrome.send('initialized'); | |
| 59 }, | |
| 60 | |
| 61 /** | |
| 62 * Looks for the existing PolicyGroup matching the |tag| and triggers adding | |
| 63 * the policy to it. | |
| 64 * @private | |
| 65 * @param {string} name Name of the policy. | |
| 66 * @param {string} tag Name of the policy's tag. | |
| 67 */ | |
| 68 addNameToTagGroup_: function(name, tag) { | |
| 69 for (var pos = 0; pos < this.$.groups.children.length; ++pos) | |
|
Dan Beam
2015/10/10 01:04:18
curlies around for () { }
fhorschig
2015/10/13 16:29:11
Done.
| |
| 70 if (this.$.groups.children[pos].riskTag == tag) | |
| 71 this.$.groups.children[pos].addPolicy(name); | |
| 72 }, | |
| 73 | |
| 74 /** | |
| 75 * Removes DOM Elements and empties list of known tags. | |
| 76 * @private | |
| 77 */ | |
| 78 clearGroups_: function() { | |
|
Dan Beam
2015/10/10 01:04:18
this.$.groups.innerHTML = '';?
fhorschig
2015/10/13 16:29:11
Nice!
| |
| 79 while (this.$.groups.firstChild) | |
| 80 this.$.groups.removeChild(this.$.groups.firstChild); | |
| 81 }, | |
| 82 | |
| 83 /** | |
| 84 * Creates PolicyGroup and inserts it to list of known tags. | |
| 85 * @param {string} tag Name of the tag (included in i18n strings). | |
| 86 * @private | |
| 87 */ | |
| 88 createTagGroup_: function(tag) { | |
| 89 this.$.groups.appendChild(new PolicyGroup(tag)); | |
| 90 }, | |
| 91 | |
| 92 /** | |
| 93 * Receives a list of known tags and creates an empty policy list for each. | |
| 94 * @param {!Array<string>} tags List of tags. | |
| 95 */ | |
| 96 setPolicyGroups: function(tags) { | |
|
Dan Beam
2015/10/10 01:04:18
can we use a dom-repeat or iron-list?
fhorschig
2015/10/13 16:29:11
dom-repeat is awesome! Thanks for showing.
(iron-l
| |
| 97 this.clearGroups_(); | |
| 98 tags.forEach(this.createTagGroup_.bind(this)); | |
| 99 }, | |
| 100 | |
| 101 /** | |
| 102 * Creates UI elements for tagged policies within the passed |names| object. | |
| 103 * @param {!{chromePolicyNames: !Object<!Array<string>>}} namesWithTags | |
| 104 */ | |
| 105 setPolicyNames: function(namesWithTags) { | |
| 106 for (var name in namesWithTags.chromePolicyNames) { | |
| 107 namesWithTags.chromePolicyNames[name].forEach( | |
| 108 this.addNameToTagGroup_.bind(this, name)); | |
| 109 } | |
| 110 }, | |
| 111 | |
| 112 /** | |
| 113 * Receives a list of current values that it hands down to children. | |
| 114 * @param {!{chromePolicies: !Object<string>}} values Current policies. | |
| 115 */ | |
| 116 setPolicyValues: function(values) { | |
| 117 // TODO(fhorschig): Update or notify tag groups. | |
| 118 }, | |
| 119 | |
| 120 /** | |
| 121 * Receives an object with meta data about the currently set policies. | |
| 122 * @param {!Object} status Dictionary containing meta data about set policies. | |
| 123 */ | |
| 124 setStatus: function(status) { | |
| 125 // TODO(fhorschig): Update |this.$.introduction| with status information. | |
| 126 // text according to policy status. | |
| 127 } | |
| 128 }); | |
| OLD | NEW |