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

Unified Diff: chrome/browser/resources/options/chromeos/vpn_providers.js

Issue 1017443002: Allow users to add third-party VPNs from the settings page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_3_460428_update_details_dialog
Patch Set: 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
index 9198259de5d51ec90fe4079e979c1880ac82e883..5dc58d3b6b09f3134f62fc03882e17ad4d8292d7 100644
--- a/chrome/browser/resources/options/chromeos/vpn_providers.js
+++ b/chrome/browser/resources/options/chromeos/vpn_providers.js
@@ -27,12 +27,39 @@ cr.define('options', function() {
* mapping from provider ID to provider name. For third-party VPN providers,
* the provider ID is an extension ID. For the built-in OpenVPN/L2TP
* provider, the ID is 'built-in'.
- * @type {Object<string, string>}
+ * @type {!Object<string, string>}
* @private
*/
providers_: {},
/**
+ * Observers who will be notified when the list of VPN providers changes.
+ * @type {!Array<!options.VPNProviders.Observer>}
+ */
+ observers_: [],
+
+ /**
+ * The VPN providers enabled in the primary user's profile.
+ * @type {!Object<string, string>}
+ */
+ get providers() {
michaelpg 2015/03/17 19:28:16 Why do we need these get/setters?
bartfab (slow) 2015/03/18 21:27:15 I had to convert |providers_| from a simple member
+ return this.providers_;
+ },
+ set providers(providers) {
+ this.providers_ = providers;
+ for (var i = 0; i < this.observers_.length; ++i)
+ this.observers_[i].onVPNProvidersChanged();
+ },
+
+ /**
+ * Adds an observer to be notified when the list of VPN providers changes.
+ * @param {!options.VPNProviders.Observer} observer The observer to add.
+ */
+ addObserver: function(observer) {
+ this.observers_.push(observer);
+ },
+
+ /**
* Determines whether |provider_id| belongs to a third-party VPN provider.
* @param {string} provider_id The VPN provider ID.
* @return {boolean} True if the ID belongs to a third-party VPN provider.
@@ -63,11 +90,19 @@ cr.define('options', function() {
};
/**
+ * Adds an observer to be notified when the list of VPN providers changes.
+ * @param {!options.VPNProviders.Observer} observer The observer to add.
+ */
+ VPNProviders.addObserver = function(observer) {
+ VPNProviders.getInstance().addObserver(observer);
+ };
+
+ /**
* Returns the list of VPN providers enabled in the primary user's profile.
* @return {Object<string, string>} A mapping from VPN provider ID to name.
*/
VPNProviders.getProviders = function() {
- return VPNProviders.getInstance().providers_;
+ return VPNProviders.getInstance().providers;
};
/**
@@ -76,7 +111,7 @@ cr.define('options', function() {
* to name.
*/
VPNProviders.setProviders = function(providers) {
- VPNProviders.getInstance().providers_ = providers;
+ VPNProviders.getInstance().providers = providers;
};
/**
@@ -100,6 +135,19 @@ cr.define('options', function() {
network_name);
};
+ /**
+ * An observer of VPNProviders.
+ * @interface
+ */
+ VPNProviders.Observer = function() {};
+
+ VPNProviders.Observer.prototype = {
+ /**
+ * Called when the list of VPN providers changes.
+ */
+ onVPNProvidersChanged: function() {},
+ };
+
// Export
return {
VPNProviders: VPNProviders

Powered by Google App Engine
This is Rietveld 408576698