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

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: Fixed closure errors. Addressed comments. 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 911c68487fbf67238d92644ad4eb93e2329bdd87..06da41b5339940a846dcf01029334353b6eca1f3 100644
--- a/chrome/browser/resources/options/chromeos/vpn_providers.js
+++ b/chrome/browser/resources/options/chromeos/vpn_providers.js
@@ -26,6 +26,34 @@ cr.define('options', function() {
providers_: [],
/**
+ * Observers who will be called when the list of VPN providers changes.
+ * @type {!Array<!function()>}
+ */
+ observers_: [],
+
+ /**
+ * The VPN providers enabled in the primary user's profile.
+ * @type {!Array<{name: string, extensionID: ?string}>}
+ */
+ get providers() {
+ return this.providers_;
+ },
+ set providers(providers) {
+ this.providers_ = providers;
+ for (var i = 0; i < this.observers_.length; ++i)
+ this.observers_[i]();
+ },
+
+ /**
+ * Adds an observer to be called when the list of VPN providers changes.
+ * @param {!function()} observer The observer to add.
+ * @private
+ */
+ addObserver_: function(observer) {
+ this.observers_.push(observer);
+ },
+
+ /**
* 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.
@@ -50,12 +78,23 @@ cr.define('options', function() {
};
/**
+ * Adds an observer to be called when the list of VPN providers changes. Note
+ * that an observer may in turn call setProviders() but should be careful not
+ * to get stuck in an infinite loop as every change to the list of VPN
+ * providers will cause the observers to be called again.
+ * @param {!function()} 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 {!Array<{name: string, extensionID: ?string}>} The list of VPN
* providers enabled in the primary user's profile.
*/
VPNProviders.getProviders = function() {
- return VPNProviders.getInstance().providers_;
+ return VPNProviders.getInstance().providers;
};
/**
@@ -64,7 +103,7 @@ cr.define('options', function() {
* of VPN providers enabled in the primary user's profile.
*/
VPNProviders.setProviders = function(providers) {
- VPNProviders.getInstance().providers_ = providers;
+ VPNProviders.getInstance().providers = providers;
};
/**

Powered by Google App Engine
This is Rietveld 408576698