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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_ 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_
6 #define ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_ 6 #define ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 24 matching lines...) Expand all
35 // Whether this key represents a built-in or third-party VPN provider. 35 // Whether this key represents a built-in or third-party VPN provider.
36 bool third_party; 36 bool third_party;
37 37
38 // ID of the extension that implements this provider. Used for third-party 38 // ID of the extension that implements this provider. Used for third-party
39 // VPN providers only. 39 // VPN providers only.
40 std::string extension_id; 40 std::string extension_id;
41 }; 41 };
42 42
43 VPNProvider(const Key& key, const std::string& name); 43 VPNProvider(const Key& key, const std::string& name);
44 44
45 bool operator==(const VPNProvider& other) const;
46
45 // Key that uniquely identifies this VPN provider. 47 // Key that uniquely identifies this VPN provider.
46 Key key; 48 Key key;
47 49
48 // Human-readable name. 50 // Human-readable name.
stevenjb 2016/11/21 20:23:18 // Human-readable name if key.third_party is true,
James Cook 2016/11/21 23:58:38 Done.
49 std::string name; 51 std::string name;
50 }; 52 };
51 53
52 // This delegate provides UI code in ash, e.g. |VPNList|, with access to the 54 // This delegate provides UI code in ash, e.g. |VPNListView|, with access to the
53 // list of VPN providers enabled in the primary user's profile. The delegate 55 // 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 // furthermore allows the UI code to request that a VPN provider show its "add
55 // network" dialog. 57 // network" dialog.
58 // TODO(jamescook): Rename this to VpnList as part of mojo conversion because it
59 // won't be a delegate anymore.
56 class ASH_EXPORT VPNDelegate { 60 class ASH_EXPORT VPNDelegate {
57 public: 61 public:
58 // An observer that is notified whenever the list of VPN providers enabled in 62 // An observer that is notified whenever the list of VPN providers enabled in
59 // the primary user's profile changes. 63 // the primary user's profile changes.
60 class Observer { 64 class Observer {
61 public: 65 public:
62 virtual void OnVPNProvidersChanged() = 0; 66 virtual void OnVPNProvidersChanged() = 0;
63 67
64 protected: 68 protected:
65 virtual ~Observer(); 69 virtual ~Observer();
66 70
67 private: 71 private:
68 DISALLOW_ASSIGN(Observer); 72 DISALLOW_ASSIGN(Observer);
69 }; 73 };
70 74
71 VPNDelegate(); 75 VPNDelegate();
72 virtual ~VPNDelegate(); 76 virtual ~VPNDelegate();
73 77
78 const std::vector<VPNProvider>& vpn_providers() { return vpn_providers_; }
79
74 // Returns |true| if at least one third-party VPN provider is enabled in the 80 // 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. 81 // primary user's profile, in addition to the built-in OpenVPN/L2TP provider.
76 virtual bool HaveThirdPartyVPNProviders() const = 0; 82 bool HaveThirdPartyVPNProviders() const;
77
78 // Returns the list of VPN providers enabled in the primary user's profile.
79 virtual const std::vector<VPNProvider>& GetVPNProviders() const = 0;
80 83
81 // Requests that the VPN provider identified by |key| show its "add network" 84 // Requests that the VPN provider identified by |key| show its "add network"
82 // dialog. 85 // dialog.
83 virtual void ShowAddPage(const VPNProvider::Key& key) = 0; 86 virtual void ShowAddPage(const VPNProvider::Key& key) = 0;
James Cook 2016/11/21 19:23:30 I'm going to move ShowAddPage() to the mojo System
stevenjb 2016/11/21 20:23:18 Acknowledged.
84 87
85 void AddObserver(Observer* observer); 88 void AddObserver(Observer* observer);
86 void RemoveObserver(Observer* observer); 89 void RemoveObserver(Observer* observer);
87 90
88 protected: 91 // Sets the list of extension-backed VPN providers. The list may be empty.
92 // Notifies observers. Public for testing.
93 // TODO(jamescook): Convert to mojo interface.
94 void SetThirdPartyVpnProviders(const std::vector<VPNProvider>& providers);
95
96 private:
89 // Notify observers that the list of VPN providers enabled in the primary 97 // Notify observers that the list of VPN providers enabled in the primary
90 // user's profile has changed. 98 // user's profile has changed.
91 void NotifyObservers(); 99 void NotifyObservers();
92 100
93 private: 101 // Adds the built-in OpenVPN/L2TP provider to |vpn_providers_|.
102 void AddBuiltInProvider();
103
104 // Cache of VPN providers, including the built-in OpenVPN/L2TP provider and
105 // other providers added by extensions in the primary user's profile.
106 std::vector<VPNProvider> vpn_providers_;
107
94 base::ObserverList<Observer> observer_list_; 108 base::ObserverList<Observer> observer_list_;
95 109
96 DISALLOW_COPY_AND_ASSIGN(VPNDelegate); 110 DISALLOW_COPY_AND_ASSIGN(VPNDelegate);
97 }; 111 };
98 112
99 } // namespace ash 113 } // namespace ash
100 114
101 #endif // ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_ 115 #endif // ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698