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

Unified Diff: ash/common/system/chromeos/network/vpn_delegate.h

Issue 2510083006: chromeos: Move ownership of ash VPN provider list from chrome into ash (Closed)
Patch Set: rebase Created 4 years, 1 month 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: ash/common/system/chromeos/network/vpn_delegate.h
diff --git a/ash/common/system/chromeos/network/vpn_delegate.h b/ash/common/system/chromeos/network/vpn_delegate.h
index 88b58cacf8010e486dbb927e0eba0efaca560449..94ca69c7eb54f4e9b388d4db21566c8ccbd7afc5 100644
--- a/ash/common/system/chromeos/network/vpn_delegate.h
+++ b/ash/common/system/chromeos/network/vpn_delegate.h
@@ -42,6 +42,8 @@ struct ASH_EXPORT VPNProvider {
VPNProvider(const Key& key, const std::string& name);
+ bool operator==(const VPNProvider& other) const;
+
// Key that uniquely identifies this VPN provider.
Key key;
@@ -49,10 +51,12 @@ struct ASH_EXPORT VPNProvider {
std::string name;
};
-// This delegate provides UI code in ash, e.g. |VPNList|, with access to the
+// This delegate provides UI code in ash, e.g. |VPNListView|, with access to the
// list of VPN providers enabled in the primary user's profile. The delegate
// furthermore allows the UI code to request that a VPN provider show its "add
// network" dialog.
+// TODO(jamescook): Rename this to VpnList as part of mojo conversion because it
+// won't be a delegate anymore.
class ASH_EXPORT VPNDelegate {
public:
// An observer that is notified whenever the list of VPN providers enabled in
@@ -71,12 +75,11 @@ class ASH_EXPORT VPNDelegate {
VPNDelegate();
virtual ~VPNDelegate();
+ const std::vector<VPNProvider>& vpn_providers() { return vpn_providers_; }
+
// Returns |true| if at least one third-party VPN provider is enabled in the
// primary user's profile, in addition to the built-in OpenVPN/L2TP provider.
- virtual bool HaveThirdPartyVPNProviders() const = 0;
-
- // Returns the list of VPN providers enabled in the primary user's profile.
- virtual const std::vector<VPNProvider>& GetVPNProviders() const = 0;
+ bool HaveThirdPartyVPNProviders() const;
// Requests that the VPN provider identified by |key| show its "add network"
// dialog.
@@ -85,12 +88,23 @@ class ASH_EXPORT VPNDelegate {
void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer);
- protected:
+ // Sets the list of extension-backed VPN providers. The list may be empty.
+ // Notifies observers. Public for testing.
+ // TODO(jamescook): Convert to mojo interface.
+ void SetThirdPartyVpnProviders(const std::vector<VPNProvider>& providers);
+
+ private:
// Notify observers that the list of VPN providers enabled in the primary
// user's profile has changed.
void NotifyObservers();
- private:
+ // Adds the built-in OpenVPN/L2TP provider to |vpn_providers_|.
+ void AddBuiltInProvider();
+
+ // Cache of VPN providers, including the built-in OpenVPN/L2TP provider and
+ // other providers added by extensions in the primary user's profile.
+ std::vector<VPNProvider> vpn_providers_;
+
base::ObserverList<Observer> observer_list_;
DISALLOW_COPY_AND_ASSIGN(VPNDelegate);

Powered by Google App Engine
This is Rietveld 408576698