Chromium Code Reviews| 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..661a62c126196ecc063b6fafb2de4682c8e451b0 100644 |
| --- a/chrome/browser/resources/options/chromeos/vpn_providers.js |
| +++ b/chrome/browser/resources/options/chromeos/vpn_providers.js |
| @@ -26,6 +26,33 @@ cr.define('options', function() { |
| providers_: [], |
| /** |
| + * Observers who will be notified 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](); |
|
michaelpg
2015/03/19 19:48:28
What would happen if an observer tried to set prov
bartfab (slow)
2015/03/20 00:10:25
As discussed, I added a comment warning about this
|
| + }, |
| + |
| + /** |
| + * Adds an observer to be notified when the list of VPN providers changes. |
| + * @param {!function()} observer The observer to add. |
| + */ |
| + 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 +77,20 @@ cr.define('options', function() { |
| }; |
| /** |
| + * Adds an observer to be notified when the list of VPN providers changes. |
|
michaelpg
2015/03/19 19:48:28
nit: s/notified/called
bartfab (slow)
2015/03/20 00:10:25
Done.
|
| + * @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 +99,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; |
| }; |
| /** |