1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H
11 #include "ash/ash_export.h"
12 #include "base/macros.h"
13 #include "base/observer_list.h"
21 // Describes a VPN provider.
22 struct ASH_EXPORT VPNProvider
{
24 // Constructs a key for the built-in VPN provider.
27 // Constructs a key for a third-party VPN provider.
28 explicit Key(const std::string
& extension_id
);
30 bool operator==(const Key
& other
) const;
32 // Indicates whether |network| belongs to this VPN provider.
33 bool MatchesNetwork(const chromeos::NetworkState
& network
) const;
35 // Whether this key represents a built-in or third-party VPN provider.
38 // ID of the extension that implements this provider. Used for third-party
39 // VPN providers only.
40 std::string extension_id
;
43 VPNProvider(const Key
& key
, const std::string
& name
);
45 // Key that uniquely identifies this VPN provider.
48 // Human-readable name.
52 // This delegate provides UI code in ash, e.g. |VPNList|, with access to the
53 // list of VPN providers enabled in the primary user's profile. The delegate
54 // furthermore allows the UI code to request that a VPN provider show its "add
56 class ASH_EXPORT VPNDelegate
{
58 // An observer that is notified whenever the list of VPN providers enabled in
59 // the primary user's profile changes.
62 virtual void OnVPNProvidersChanged() = 0;
68 DISALLOW_ASSIGN(Observer
);
72 virtual ~VPNDelegate();
74 // Returns |true| if at least one third-party VPN provider is enabled in the
75 // primary user's profile, in addition to the built-in OpenVPN/L2TP provider.
76 virtual bool HaveThirdPartyVPNProviders() const = 0;
78 // Returns the list of VPN providers enabled in the primary user's profile.
79 virtual const std::vector
<VPNProvider
>& GetVPNProviders() const = 0;
81 // Requests that the VPN provider identified by |key| show its "add network"
83 virtual void ShowAddPage(const VPNProvider::Key
& key
) = 0;
85 void AddObserver(Observer
* observer
);
86 void RemoveObserver(Observer
* observer
);
89 // Notify observers that the list of VPN providers enabled in the primary
90 // user's profile has changed.
91 void NotifyObservers();
94 base::ObserverList
<Observer
, true> observer_list_
;
96 DISALLOW_COPY_AND_ASSIGN(VPNDelegate
);
101 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H