Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / system / chromeos / network / vpn_delegate.h
blobaaf76a3b145ab3341c310d10413a4bb166eca334
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
8 #include <string>
9 #include <vector>
11 #include "ash/ash_export.h"
12 #include "base/macros.h"
13 #include "base/observer_list.h"
15 namespace chromeos {
16 class NetworkState;
19 namespace ash {
21 // Describes a VPN provider.
22 struct ASH_EXPORT VPNProvider {
23 struct Key {
24 // Constructs a key for the built-in VPN provider.
25 Key();
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.
36 bool third_party;
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.
46 Key key;
48 // Human-readable name.
49 std::string 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
55 // network" dialog.
56 class ASH_EXPORT VPNDelegate {
57 public:
58 // An observer that is notified whenever the list of VPN providers enabled in
59 // the primary user's profile changes.
60 class Observer {
61 public:
62 virtual void OnVPNProvidersChanged() = 0;
64 protected:
65 virtual ~Observer();
67 private:
68 DISALLOW_ASSIGN(Observer);
71 VPNDelegate();
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"
82 // dialog.
83 virtual void ShowAddPage(const VPNProvider::Key& key) = 0;
85 void AddObserver(Observer* observer);
86 void RemoveObserver(Observer* observer);
88 protected:
89 // Notify observers that the list of VPN providers enabled in the primary
90 // user's profile has changed.
91 void NotifyObservers();
93 private:
94 base::ObserverList<Observer, true> observer_list_;
96 DISALLOW_COPY_AND_ASSIGN(VPNDelegate);
99 } // namespace ash
101 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H