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

Side by Side Diff: ui/webui/resources/cr_elements/network/cr_onc_types.js

Issue 2627023006: WebUI: Remove i18n from cr_elements/network (Closed)
Patch Set: Allow <if> in settings_ui.html Created 3 years, 11 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
« no previous file with comments | « ui/webui/resources/cr_elements/network/cr_network_select.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 This file has two parts: 6 * @fileoverview This file has three parts:
7 * 7 *
8 * 1. Typedefs for network properties. Note: These 'types' define a subset of 8 * 1. A dictionary of strings for network element translations.
9 *
10 * 2. Typedefs for network properties. Note: These 'types' define a subset of
9 * ONC properties in the ONC data dictionary. The first letter is capitalized to 11 * ONC properties in the ONC data dictionary. The first letter is capitalized to
10 * match the ONC spec and avoid an extra layer of translation. 12 * match the ONC spec and avoid an extra layer of translation.
11 * See components/onc/docs/onc_spec.html for the complete spec. 13 * See components/onc/docs/onc_spec.html for the complete spec.
12 * TODO(stevenjb): Replace with chrome.networkingPrivate.NetworkStateProperties 14 * TODO(stevenjb): Replace with chrome.networkingPrivate.NetworkStateProperties
13 * once that is fully defined. 15 * once that is fully defined.
14 * 16 *
15 * 2. Helper functions to facilitate extracting and setting ONC properties. 17 * 3. Helper functions to facilitate extracting and setting ONC properties.
16 */ 18 */
17 19
20 /**
21 * Strings required for networking elements. These must be set at runtime.
22 * @type {{
23 * OncTypeCellular: string,
24 * OncTypeEthernet: string,
25 * OncTypeVPN: string,
26 * OncTypeWiFi: string,
27 * OncTypeWiMAX: string,
28 * networkDisabled: string,
29 * networkListItemConnected: string,
30 * networkListItemConnecting: string,
31 * networkListItemNotConnected: string,
32 * vpnNameTemplate: string,
33 * }}
34 */
35 var CrOncStrings;
36
18 var CrOnc = {}; 37 var CrOnc = {};
19 38
20 /** @typedef {chrome.networkingPrivate.NetworkStateProperties} */ 39 /** @typedef {chrome.networkingPrivate.NetworkStateProperties} */
21 CrOnc.NetworkStateProperties; 40 CrOnc.NetworkStateProperties;
22 41
23 /** @typedef {chrome.networkingPrivate.ManagedProperties} */ 42 /** @typedef {chrome.networkingPrivate.ManagedProperties} */
24 CrOnc.NetworkProperties; 43 CrOnc.NetworkProperties;
25 44
26 /** @typedef {string|number|boolean|Object|Array<Object>} */ 45 /** @typedef {string|number|boolean|Object|Array<Object>} */
27 CrOnc.NetworkPropertyType; 46 CrOnc.NetworkPropertyType;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 * RoutingPrefix: (string|undefined), 92 * RoutingPrefix: (string|undefined),
74 * Type: (string|undefined), 93 * Type: (string|undefined),
75 * WebProxyAutoDiscoveryUrl: (string|undefined) 94 * WebProxyAutoDiscoveryUrl: (string|undefined)
76 * }} 95 * }}
77 */ 96 */
78 CrOnc.IPConfigUIProperties; 97 CrOnc.IPConfigUIProperties;
79 98
80 /** @typedef {chrome.networkingPrivate.PaymentPortal} */ 99 /** @typedef {chrome.networkingPrivate.PaymentPortal} */
81 CrOnc.PaymentPortal; 100 CrOnc.PaymentPortal;
82 101
102 /** @enum {string} */
83 CrOnc.ActivationState = chrome.networkingPrivate.ActivationStateType; 103 CrOnc.ActivationState = chrome.networkingPrivate.ActivationStateType;
104
105 /** @enum {string} */
84 CrOnc.ConnectionState = chrome.networkingPrivate.ConnectionStateType; 106 CrOnc.ConnectionState = chrome.networkingPrivate.ConnectionStateType;
107
108 /** @enum {string} */
85 CrOnc.IPConfigType = chrome.networkingPrivate.IPConfigType; 109 CrOnc.IPConfigType = chrome.networkingPrivate.IPConfigType;
110
111 /** @enum {string} */
86 CrOnc.ProxySettingsType = chrome.networkingPrivate.ProxySettingsType; 112 CrOnc.ProxySettingsType = chrome.networkingPrivate.ProxySettingsType;
113
114 /** @enum {string} */
87 CrOnc.Type = chrome.networkingPrivate.NetworkType; 115 CrOnc.Type = chrome.networkingPrivate.NetworkType;
88 116
89 /** @enum {string} */ 117 /** @enum {string} */
90 CrOnc.IPType = { 118 CrOnc.IPType = {
91 IPV4: 'IPv4', 119 IPV4: 'IPv4',
92 IPV6: 'IPv6', 120 IPV6: 'IPv6',
93 }; 121 };
94 122
95 /** @enum {string} */ 123 /** @enum {string} */
96 CrOnc.LockType = { 124 CrOnc.LockType = {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 * @return {boolean} The AutoConnect value if it exists or false. 342 * @return {boolean} The AutoConnect value if it exists or false.
315 */ 343 */
316 CrOnc.getAutoConnect = function(properties) { 344 CrOnc.getAutoConnect = function(properties) {
317 var autoconnect = CrOnc.getManagedAutoConnect(properties); 345 var autoconnect = CrOnc.getManagedAutoConnect(properties);
318 return !!CrOnc.getActiveValue(autoconnect); 346 return !!CrOnc.getActiveValue(autoconnect);
319 }; 347 };
320 348
321 /** 349 /**
322 * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} 350 * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined}
323 * properties The ONC network properties or state properties. 351 * properties The ONC network properties or state properties.
324 * @param {!I18nBehavior.Proto} i18nBehavior An I18nBehavior instance.
325 * @return {string} The name to display for |network|. 352 * @return {string} The name to display for |network|.
326 */ 353 */
327 CrOnc.getNetworkName = function(properties, i18nBehavior) { 354 CrOnc.getNetworkName = function(properties) {
328 if (!properties) 355 if (!properties)
329 return ''; 356 return '';
330 let name = CrOnc.getStateOrActiveString(properties.Name); 357 let name = CrOnc.getStateOrActiveString(properties.Name);
331 let type = CrOnc.getStateOrActiveString(properties.Type); 358 let type = CrOnc.getStateOrActiveString(properties.Type);
332 if (!name) 359 if (!name)
333 return i18nBehavior.i18n('OncType' + type); 360 return CrOncStrings['OncType' + type];
334 if (type == 'VPN' && properties.VPN) { 361 if (type == 'VPN' && properties.VPN) {
335 let vpnType = CrOnc.getStateOrActiveString(properties.VPN.Type); 362 let vpnType = CrOnc.getStateOrActiveString(properties.VPN.Type);
336 if (vpnType == 'ThirdPartyVPN' && properties.VPN.ThirdPartyVPN) { 363 if (vpnType == 'ThirdPartyVPN' && properties.VPN.ThirdPartyVPN) {
337 let providerName = properties.VPN.ThirdPartyVPN.ProviderName; 364 let providerName = properties.VPN.ThirdPartyVPN.ProviderName;
338 if (providerName) 365 if (providerName) {
339 return i18nBehavior.i18n('vpnNameTemplate', providerName, name); 366 return CrOncStrings.vpnNameTemplate.replace('$1', providerName)
367 .replace('$2', name);
368 }
340 } 369 }
341 } 370 }
342 return name; 371 return name;
343 }; 372 };
344 373
345 /** 374 /**
346 * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined} 375 * @param {!CrOnc.NetworkProperties|!CrOnc.NetworkStateProperties|undefined}
347 * properties The ONC network properties or state properties. 376 * properties The ONC network properties or state properties.
348 * @return {boolean} True if |properties| is a Cellular network with a 377 * @return {boolean} True if |properties| is a Cellular network with a
349 * locked SIM. 378 * locked SIM.
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 prefixLength += 1; 536 prefixLength += 1;
508 } else if (token == '0') { 537 } else if (token == '0') {
509 prefixLength += 0; 538 prefixLength += 0;
510 } else { 539 } else {
511 // mask is not a valid number. 540 // mask is not a valid number.
512 return -1; 541 return -1;
513 } 542 }
514 } 543 }
515 return prefixLength; 544 return prefixLength;
516 }; 545 };
OLDNEW
« no previous file with comments | « ui/webui/resources/cr_elements/network/cr_network_select.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698