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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/options/chromeos/vpn_providers.js
diff --git a/chrome/browser/resources/options/chromeos/vpn_providers.js b/chrome/browser/resources/options/chromeos/vpn_providers.js
new file mode 100644
index 0000000000000000000000000000000000000000..e12a25a4cd34cbebcd4a710b21874943653286a7
--- /dev/null
+++ b/chrome/browser/resources/options/chromeos/vpn_providers.js
@@ -0,0 +1,85 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview A singleton that keeps track of the VPN providers enabled in
+ * the primary user's profile.
+ */
+
+cr.define('options', function() {
+ /**
+ * @constructor
+ */
+ function VPNProviders() {
+ }
+
+ cr.addSingletonGetter(VPNProviders);
+
+ VPNProviders.prototype = {
+ /**
+ * The VPN providers enabled in the primary user's profile. Each provider
+ * has a name. Third-party VPN providers additionally have an extension ID.
+ * @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
+ * @private
+ */
+ providers_: [],
+
+ /**
+ * Formats a network name for display purposes. If the network belongs to
+ * a third-party VPN provider, the provider name is added to the network
+ * name.
+ * @param {cr.onc.OncData} onc ONC data describing this network.
+ * @return {string} The resulting display name.
+ * @private
+ */
+ formatNetworkName_(onc) {
+ var networkName = onc.getTranslatedValue('Name');
+ if (onc.getActiveValue('VPN.Type') != 'ThirdPartyVPN')
+ return networkName;
+ var extensionID = onc.getActiveValue('VPN.ThirdPartyVPN.ExtensionID');
+ for (var i = 0; i < this.providers_.length; ++i) {
+ if (extensionID == this.providers_[i].extensionID) {
+ return loadTimeData.getStringF('vpnNameTemplate',
+ this.providers_[i].name,
+ networkName);
+ }
+ }
+ return networkName;
+ },
+ };
+
+ /**
+ * Returns the list of VPN providers enabled in the primary user's profile.
+ * @return {!Array<{name: string, extensionID: ?string>}} The list of VPN
+ * providers enabled in the primary user's profile.
+ */
+ VPNProviders.getProviders = function() {
+ return VPNProviders.getInstance().providers_;
+ };
+
+ /**
+ * Replaces the list of VPN providers enabled in the primary user's profile.
+ * @param {!Array<{name: string, extensionID: ?string>}} providers The list
+ * 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.
+ */
+ VPNProviders.setProviders = function(providers) {
+ VPNProviders.getInstance().providers_ = providers;
+ };
+
+ /**
+ * Formats a network name for display purposes. If the network belongs to a
+ * third-party VPN provider, the provider name is added to the network name.
+ * @param {cr.onc.OncData} onc ONC data describing this network.
+ * @return {string} The resulting display name.
+ * @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.
+ */
+ VPNProviders.formatNetworkName = function(onc) {
+ return VPNProviders.getInstance().formatNetworkName_(onc);
+ };
+
+ // Export
+ return {
+ VPNProviders: VPNProviders
+ };
+});

Powered by Google App Engine
This is Rietveld 408576698