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

Side by Side Diff: chrome/browser/resources/options/chromeos/vpn_providers.js

Issue 1006553002: Add third-party VPN support to network details dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_2_460428_add_ash_ui
Patch Set: Updated to read the extension ID from the new ONC property. Created 5 years, 9 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 A singleton that keeps track of the VPN providers enabled in
7 * the primary user's profile.
8 */
9
10 cr.define('options', function() {
11 /**
12 * @constructor
13 */
14 function VPNProviders() {
15 }
16
17 cr.addSingletonGetter(VPNProviders);
18
19 VPNProviders.prototype = {
20 /**
21 * The VPN providers enabled in the primary user's profile. Each provider
22 * has a name. Third-party VPN providers additionally have an extension ID.
23 * @type {!Array<{name: string, extensionID: ?string>}}
pneubeck (no reviews) 2015/03/18 20:41:30 was there a specific reason why you changed from o
bartfab (slow) 2015/03/18 21:10:48 Yes. In CL 1017443002, I will be showing a list of
24 * @private
25 */
26 providers_: [],
27
28 /**
29 * Formats a network name for display purposes. If the network belongs to
30 * a third-party VPN provider, the provider name is added to the network
31 * name.
32 * @param {cr.onc.OncData} onc ONC data describing this network.
33 * @return {string} The resulting display name.
34 * @private
35 */
36 formatNetworkName_(onc) {
37 var networkName = onc.getTranslatedValue('Name');
38 if (onc.getActiveValue('VPN.Type') != 'ThirdPartyVPN')
39 return networkName;
40 var extensionID = onc.getActiveValue('VPN.ThirdPartyVPN.ExtensionID');
41 for (var i = 0; i < this.providers_.length; ++i) {
42 if (extensionID == this.providers_[i].extensionID) {
43 return loadTimeData.getStringF('vpnNameTemplate',
44 this.providers_[i].name,
45 networkName);
46 }
47 }
48 return networkName;
49 },
50 };
51
52 /**
53 * Returns the list of VPN providers enabled in the primary user's profile.
54 * @return {!Array<{name: string, extensionID: ?string>}} The list of VPN
55 * providers enabled in the primary user's profile.
56 */
57 VPNProviders.getProviders = function() {
58 return VPNProviders.getInstance().providers_;
59 };
60
61 /**
62 * Replaces the list of VPN providers enabled in the primary user's profile.
63 * @param {!Array<{name: string, extensionID: ?string>}} providers The list
64 * ofVPN providers enabled in the primary user's profile.
pneubeck (no reviews) 2015/03/18 20:41:30 typo: ofVPN -> of VPN
bartfab (slow) 2015/03/18 21:10:48 Done.
65 */
66 VPNProviders.setProviders = function(providers) {
67 VPNProviders.getInstance().providers_ = providers;
68 };
69
70 /**
71 * Formats a network name for display purposes. If the network belongs to a
72 * third-party VPN provider, the provider name is added to the network name.
73 * @param {cr.onc.OncData} onc ONC data describing this network.
74 * @return {string} The resulting display name.
75 * @private
pneubeck (no reviews) 2015/03/18 20:41:30 why is this private? it's called from external
bartfab (slow) 2015/03/18 21:10:48 Copypasta.
76 */
77 VPNProviders.formatNetworkName = function(onc) {
78 return VPNProviders.getInstance().formatNetworkName_(onc);
79 };
80
81 // Export
82 return {
83 VPNProviders: VPNProviders
84 };
85 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698