| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_ |
| 6 #define ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_ |
| 7 |
| 8 #include <string> |
| 9 #include <vector> |
| 10 |
| 11 #include "ash/ash_export.h" |
| 12 #include "base/macros.h" |
| 13 #include "base/observer_list.h" |
| 14 |
| 15 namespace ash { |
| 16 |
| 17 // Describes a VPN provider. |
| 18 struct ASH_EXPORT VPNProvider { |
| 19 // Constructs the built-in VPN provider. |
| 20 VPNProvider(); |
| 21 |
| 22 // Constructs a third-party VPN provider. |
| 23 VPNProvider(const std::string& extension_id, |
| 24 const std::string& third_party_provider_name); |
| 25 |
| 26 bool operator==(const VPNProvider& other) const; |
| 27 |
| 28 // Whether this key represents a built-in or third-party VPN provider. |
| 29 bool third_party; |
| 30 |
| 31 // ID of the extension that implements this provider. Used for third-party |
| 32 // VPN providers only. |
| 33 std::string extension_id; |
| 34 |
| 35 // Human-readable name if |third_party| is true, otherwise empty. |
| 36 std::string third_party_provider_name; |
| 37 }; |
| 38 |
| 39 // This delegate provides UI code in ash, e.g. |VPNListView|, with access to the |
| 40 // list of VPN providers enabled in the primary user's profile. The delegate |
| 41 // furthermore allows the UI code to request that a VPN provider show its "add |
| 42 // network" dialog. |
| 43 // TODO(jamescook): Rename this to VpnList as part of mojo conversion because it |
| 44 // won't be a delegate anymore. |
| 45 class ASH_EXPORT VPNDelegate { |
| 46 public: |
| 47 // An observer that is notified whenever the list of VPN providers enabled in |
| 48 // the primary user's profile changes. |
| 49 class Observer { |
| 50 public: |
| 51 virtual void OnVPNProvidersChanged() = 0; |
| 52 |
| 53 protected: |
| 54 virtual ~Observer(); |
| 55 |
| 56 private: |
| 57 DISALLOW_ASSIGN(Observer); |
| 58 }; |
| 59 |
| 60 VPNDelegate(); |
| 61 virtual ~VPNDelegate(); |
| 62 |
| 63 const std::vector<VPNProvider>& vpn_providers() { return vpn_providers_; } |
| 64 |
| 65 // Returns |true| if at least one third-party VPN provider is enabled in the |
| 66 // primary user's profile, in addition to the built-in OpenVPN/L2TP provider. |
| 67 bool HaveThirdPartyVPNProviders() const; |
| 68 |
| 69 // Requests that the third-party VPN provider identified by |extension_id| |
| 70 // show its "add network" dialog. If |extension_id| is empty then the built-in |
| 71 // VPN provider's dialog is shown. |
| 72 virtual void ShowAddPage(const std::string& extension_id) = 0; |
| 73 |
| 74 void AddObserver(Observer* observer); |
| 75 void RemoveObserver(Observer* observer); |
| 76 |
| 77 // Sets the list of extension-backed VPN providers. The list may be empty. |
| 78 // Notifies observers. Public for testing. |
| 79 // TODO(jamescook): Convert to mojo interface. |
| 80 void SetThirdPartyVpnProviders( |
| 81 const std::vector<VPNProvider>& third_party_providers); |
| 82 |
| 83 private: |
| 84 // Notify observers that the list of VPN providers enabled in the primary |
| 85 // user's profile has changed. |
| 86 void NotifyObservers(); |
| 87 |
| 88 // Adds the built-in OpenVPN/L2TP provider to |vpn_providers_|. |
| 89 void AddBuiltInProvider(); |
| 90 |
| 91 // Cache of VPN providers, including the built-in OpenVPN/L2TP provider and |
| 92 // other providers added by extensions in the primary user's profile. |
| 93 std::vector<VPNProvider> vpn_providers_; |
| 94 |
| 95 base::ObserverList<Observer> observer_list_; |
| 96 |
| 97 DISALLOW_COPY_AND_ASSIGN(VPNDelegate); |
| 98 }; |
| 99 |
| 100 } // namespace ash |
| 101 |
| 102 #endif // ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_VPN_DELEGATE_H_ |
| OLD | NEW |