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

Side by Side Diff: chrome/browser/resources/settings/internet_page/network_property_list.js

Issue 1369403006: Add cr-policy-network-indicator and add to internet settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Separate policy indicator strings 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Polymer element for displaying a list of network properties 6 * @fileoverview Polymer element for displaying a list of network properties
7 * in a list in the format: 7 * in a list in the format:
8 * Key1.........Value1 8 * Key1.........Value1
9 * KeyTwo.......ValueTwo 9 * KeyTwo.......ValueTwo
10 * This also supports editing fields inline for fields listed in editFieldTypes: 10 * This also supports editing fields inline for fields listed in editFieldTypes:
11 * KeyThree....._________ 11 * KeyThree....._________
12 * TODO(stevenjb): Translate the keys and (where appropriate) values. 12 * TODO(stevenjb): Translate the keys and (where appropriate) values.
13 */ 13 */
14 Polymer({ 14 Polymer({
15 is: 'network-property-list', 15 is: 'network-property-list',
16 16
17 behaviors: [CrPolicyNetworkBehavior],
18
17 properties: { 19 properties: {
18 /** 20 /**
19 * The dictionary containing the properties to display. 21 * The dictionary containing the properties to display.
22 * @type {!Object|undefined}
20 */ 23 */
21 propertyDict: { 24 propertyDict: {
22 type: Object 25 type: Object
23 }, 26 },
24 27
25 /** 28 /**
26 * Fields to display. 29 * Fields to display.
27 * @type {!Array<string>} 30 * @type {!Array<string>}
28 */ 31 */
29 fields: { 32 fields: {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 * @param {string} key The property key. 76 * @param {string} key The property key.
74 * @return {string} The text to display for the property label. 77 * @return {string} The text to display for the property label.
75 * @private 78 * @private
76 */ 79 */
77 getPropertyLabel_: function(key) { 80 getPropertyLabel_: function(key) {
78 // TODO(stevenjb): Localize. 81 // TODO(stevenjb): Localize.
79 return key; 82 return key;
80 }, 83 },
81 84
82 /** 85 /**
83 * @param {!Object|undefined} propertyDict 86 * @param {!Object} propertyDict
84 * @param {string} key The property key. 87 * @param {string} key The property key.
85 * @return {boolean} Whether or not the property exists in |propertyDict|. 88 * @return {boolean} Whether or not the property exists in |propertyDict|.
86 * @private 89 * @private
87 */ 90 */
88 hasPropertyValue_: function(propertyDict, key) { 91 hasPropertyValue_: function(propertyDict, key) {
89 var value = (propertyDict && this.get(key, propertyDict)) || undefined; 92 var value = this.get(key, propertyDict);
90 return (value !== undefined && value !== ''); 93 return (value !== undefined && value !== '');
91 }, 94 },
92 95
93 /** 96 /**
94 * @param {!Object|undefined} propertyDict 97 * @param {!Object} propertyDict
95 * @param {!Object} editFieldTypes The editFieldTypes object. 98 * @param {!Object} editFieldTypes The editFieldTypes object.
96 * @param {string} key The property key. 99 * @param {string} key The property key.
97 * @return {boolean} Whether or not to show the property. Editable properties 100 * @return {boolean} Whether or not to show the property. Editable properties
98 * are always shown. 101 * are always shown.
99 * @private 102 * @private
100 */ 103 */
101 showProperty_: function(propertyDict, editFieldTypes, key) { 104 showProperty_: function(propertyDict, editFieldTypes, key) {
102 if (editFieldTypes.hasOwnProperty(key)) 105 if (editFieldTypes.hasOwnProperty(key))
103 return true; 106 return true;
104 return this.hasPropertyValue_(propertyDict, key); 107 return this.hasPropertyValue_(propertyDict, key);
105 }, 108 },
106 109
107 /** 110 /**
108 * @param {!Object|undefined} propertyDict 111 * @param {!Object} propertyDict
109 * @param {!Object} editFieldTypes The editFieldTypes object. 112 * @param {!Object} editFieldTypes The editFieldTypes object.
110 * @param {string} key The property key. 113 * @param {string} key The property key.
111 * @return {boolean} True if |key| exists in |propertiesDict| and is not 114 * @return {boolean} True if |key| exists in |propertiesDict| and is not
112 * editable. 115 * editable.
113 * @private 116 * @private
114 */ 117 */
115 showNoEdit_: function(propertyDict, editFieldTypes, key) { 118 showNoEdit_: function(propertyDict, editFieldTypes, key) {
116 if (!this.hasPropertyValue_(propertyDict, key)) 119 if (!this.hasPropertyValue_(propertyDict, key))
117 return false; 120 return false;
118 var editType = editFieldTypes[key]; 121 var property = /** @type {!CrOnc.NetworkProperty|undefined} */(
119 return !editType; 122 this.get(key, propertyDict));
123 if (this.isNetworkPolicyEnforced(property))
124 return true;
125 return !editFieldTypes[key];
120 }, 126 },
121 127
122 /** 128 /**
123 * @param {!Object|undefined} propertyDict 129 * @param {!Object} propertyDict
124 * @param {!Object} editFieldTypes The editFieldTypes object. 130 * @param {!Object} editFieldTypes The editFieldTypes object.
125 * @param {string} key The property key. 131 * @param {string} key The property key.
126 * @param {string} type The field type. 132 * @param {string} type The field type.
127 * @return {boolean} True if |key| exists in |propertyDict| and is of editable 133 * @return {boolean} True if |key| exists in |propertyDict| and is of editable
128 * type |type|. 134 * type |type|.
129 * @private 135 * @private
130 */ 136 */
131 showEdit_: function(propertyDict, editFieldTypes, key, type) { 137 showEdit_: function(propertyDict, editFieldTypes, key, type) {
138 if (!this.hasPropertyValue_(propertyDict, key))
139 return false;
140 var property = /** @type {!CrOnc.NetworkProperty|undefined} */(
141 this.get(key, propertyDict));
142 if (this.isNetworkPolicyEnforced(property))
143 return false;
132 return editFieldTypes[key] == type; 144 return editFieldTypes[key] == type;
133 }, 145 },
134 146
135 /** 147 /**
136 * @param {!Object|undefined} propertyDict 148 * @param {!Object} propertyDict
137 * @param {string} key The property key. 149 * @param {string} key The property key.
138 * @return {string} The text to display for the property value. 150 * @return {string} The text to display for the property value.
139 * @private 151 * @private
140 */ 152 */
141 getPropertyValue_: function(propertyDict, key) { 153 getPropertyValue_: function(propertyDict, key) {
142 if (!propertyDict)
143 return '';
144 var value = this.get(key, propertyDict); 154 var value = this.get(key, propertyDict);
145 if (value === undefined) 155 if (value === undefined)
146 return ''; 156 return '';
147 if (typeof value == 'object') { 157 if (typeof value == 'object') {
148 // Extract the property from an ONC managed dictionary 158 // Extract the property from an ONC managed dictionary
149 value = 159 value =
150 CrOnc.getActiveValue(/** @type {!CrOnc.ManagedProperty} */(value)); 160 CrOnc.getActiveValue(/** @type {!CrOnc.ManagedProperty} */(value));
151 } 161 }
152 // TODO(stevenjb): Localize. 162 // TODO(stevenjb): Localize.
153 if (typeof value == 'number' || typeof value == 'boolean') 163 if (typeof value == 'number' || typeof value == 'boolean')
154 return value.toString(); 164 return value.toString();
155 return /** @type {string} */(value); 165 return /** @type {string} */(value);
156 }, 166 },
157 }); 167 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698