OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('options.internet', function() { | 5 cr.define('options.internet', function() { |
6 | 6 |
7 /** | 7 /** |
8 * Network settings constants. These enums usually match their C++ | 8 * Network settings constants. These enums usually match their C++ |
9 * counterparts. | 9 * counterparts. |
10 */ | 10 */ |
11 function Constants() {} | 11 function Constants() {} |
12 // Minimum length for wireless network password. | 12 // Minimum length for wireless network password. |
13 Constants.MIN_WIRELESS_PASSWORD_LENGTH = 5; | 13 Constants.MIN_WIRELESS_PASSWORD_LENGTH = 5; |
14 // Minimum length for SSID name. | 14 // Minimum length for SSID name. |
15 Constants.MIN_WIRELESS_SSID_LENGTH = 1; | 15 Constants.MIN_WIRELESS_SSID_LENGTH = 1; |
16 // Cellular activation states: | 16 // Cellular activation states: |
17 Constants.ACTIVATION_STATE_UNKNOWN = 0; | 17 Constants.ACTIVATION_STATE_UNKNOWN = 0; |
18 Constants.ACTIVATION_STATE_ACTIVATED = 1; | 18 Constants.ACTIVATION_STATE_ACTIVATED = 1; |
19 Constants.ACTIVATION_STATE_ACTIVATING = 2; | 19 Constants.ACTIVATION_STATE_ACTIVATING = 2; |
20 Constants.ACTIVATION_STATE_NOT_ACTIVATED = 3; | 20 Constants.ACTIVATION_STATE_NOT_ACTIVATED = 3; |
21 Constants.ACTIVATION_STATE_PARTIALLY_ACTIVATED = 4; | 21 Constants.ACTIVATION_STATE_PARTIALLY_ACTIVATED = 4; |
22 // Network types: | 22 // Network types: |
23 Constants.TYPE_UNKNOWN = 0; | 23 Constants.TYPE_UNKNOWN = 0; |
24 Constants.TYPE_ETHERNET = 1; | 24 Constants.TYPE_ETHERNET = 1; |
25 Constants.TYPE_WIFI = 2; | 25 Constants.TYPE_WIFI = 2; |
26 Constants.TYPE_WIMAX = 3; | 26 Constants.TYPE_WIMAX = 3; |
27 Constants.TYPE_BLUETOOTH = 4; | 27 Constants.TYPE_BLUETOOTH = 4; |
28 Constants.TYPE_CELLULAR = 5; | 28 Constants.TYPE_CELLULAR = 5; |
29 Constants.TYPE_VPN = 6; | 29 Constants.TYPE_VPN = 6; |
| 30 // ONC sources: |
| 31 Constants.ONC_SOURCE_USER_IMPORT = 1; |
| 32 Constants.ONC_SOURCE_DEVICE_POLICY = 2; |
| 33 Constants.ONC_SOURCE_USER_POLICY = 3; |
30 | 34 |
31 /** | 35 /** |
32 * Creates a new network list div. | 36 * Creates a new network list div. |
33 * @param {Object=} opt_propertyBag Optional properties. | 37 * @param {Object=} opt_propertyBag Optional properties. |
34 * @constructor | 38 * @constructor |
35 * @extends {HTMLDivElement} | 39 * @extends {HTMLDivElement} |
36 */ | 40 */ |
37 var NetworkElement = cr.ui.define('div'); | 41 var NetworkElement = cr.ui.define('div'); |
38 | 42 |
39 NetworkElement.prototype = { | 43 NetworkElement.prototype = { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 __proto__: HTMLDivElement.prototype, | 135 __proto__: HTMLDivElement.prototype, |
132 | 136 |
133 /** @inheritDoc */ | 137 /** @inheritDoc */ |
134 decorate: function() { | 138 decorate: function() { |
135 this.className = 'network-item'; | 139 this.className = 'network-item'; |
136 this.connectable = this.data.connectable; | 140 this.connectable = this.data.connectable; |
137 this.connected = this.data.connected; | 141 this.connected = this.data.connected; |
138 this.connecting = this.data.connecting; | 142 this.connecting = this.data.connecting; |
139 this.other = this.data.servicePath == '?'; | 143 this.other = this.data.servicePath == '?'; |
140 this.id = this.data.servicePath; | 144 this.id = this.data.servicePath; |
| 145 |
| 146 // Insert a div holding the policy-managed indicator. |
| 147 var policyIndicator = this.ownerDocument.createElement('div'); |
| 148 policyIndicator.className = 'controlled-setting-indicator'; |
| 149 cr.ui.decorate(policyIndicator, options.ControlledSettingIndicator); |
| 150 |
| 151 if (this.data.policyManaged) { |
| 152 policyIndicator.controlledBy = 'policy'; |
| 153 policyIndicator.setAttribute('textPolicy', |
| 154 localStrings.getString('managedNetwork')); |
| 155 } |
| 156 this.appendChild(policyIndicator); |
| 157 |
141 // textDiv holds icon, name and status text. | 158 // textDiv holds icon, name and status text. |
142 var textDiv = this.ownerDocument.createElement('div'); | 159 var textDiv = this.ownerDocument.createElement('div'); |
143 textDiv.className = 'network-item-text'; | 160 textDiv.className = 'network-item-text'; |
144 if (this.data.iconURL) { | 161 if (this.data.iconURL) { |
145 textDiv.style.backgroundImage = url(this.data.iconURL); | 162 textDiv.style.backgroundImage = url(this.data.iconURL); |
146 } | 163 } |
147 | 164 |
148 var nameEl = this.ownerDocument.createElement('div'); | 165 var nameEl = this.ownerDocument.createElement('div'); |
149 nameEl.className = 'network-name-label'; | 166 nameEl.className = 'network-name-label'; |
150 nameEl.textContent = this.data.networkName; | 167 nameEl.textContent = this.data.networkName; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 256 } |
240 } else { | 257 } else { |
241 // Put "Forget this network" button. | 258 // Put "Forget this network" button. |
242 var button = this.createButton_('forget_button', 'forget', | 259 var button = this.createButton_('forget_button', 'forget', |
243 function(e) { | 260 function(e) { |
244 chrome.send('buttonClickCallback', | 261 chrome.send('buttonClickCallback', |
245 [String(self.data.networkType), | 262 [String(self.data.networkType), |
246 self.data.servicePath, | 263 self.data.servicePath, |
247 'forget']); | 264 'forget']); |
248 }); | 265 }); |
249 | 266 button.disabled = this.data.policyManaged; |
250 buttonsDiv.appendChild(button); | 267 buttonsDiv.appendChild(button); |
251 } | 268 } |
252 this.appendChild(buttonsDiv); | 269 this.appendChild(buttonsDiv); |
253 }, | 270 }, |
254 | 271 |
255 /** | 272 /** |
256 * Creates a button for interacting with a network. | 273 * Creates a button for interacting with a network. |
257 * @param {Object} name The name of the localStrings to use for the text. | 274 * @param {Object} name The name of the localStrings to use for the text. |
258 * @param {Object} type The type of button. | 275 * @param {Object} type The type of button. |
259 */ | 276 */ |
(...skipping 30 matching lines...) Expand all Loading... |
290 * Whether the underlying network is connectable. | 307 * Whether the underlying network is connectable. |
291 * @type {boolean} | 308 * @type {boolean} |
292 */ | 309 */ |
293 cr.defineProperty(NetworkItem, 'connectable', cr.PropertyKind.BOOL_ATTR); | 310 cr.defineProperty(NetworkItem, 'connectable', cr.PropertyKind.BOOL_ATTR); |
294 | 311 |
295 return { | 312 return { |
296 Constants: Constants, | 313 Constants: Constants, |
297 NetworkElement: NetworkElement | 314 NetworkElement: NetworkElement |
298 }; | 315 }; |
299 }); | 316 }); |
OLD | NEW |