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

Side by Side Diff: chrome/browser/resources/md_policy/md_policy.js

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

Powered by Google App Engine
This is Rietveld 408576698