| 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 #include "ash/system/chromeos/network/vpn_delegate.h" | |
| 6 | |
| 7 #include "chromeos/network/network_state.h" | |
| 8 #include "third_party/cros_system_api/dbus/service_constants.h" | |
| 9 | |
| 10 namespace ash { | |
| 11 | |
| 12 VPNProvider::Key::Key() : third_party(false) {} | |
| 13 | |
| 14 VPNProvider::Key::Key(const std::string& extension_id) | |
| 15 : third_party(true), extension_id(extension_id) {} | |
| 16 | |
| 17 bool VPNProvider::Key::operator==(const Key& other) const { | |
| 18 return other.third_party == third_party && other.extension_id == extension_id; | |
| 19 } | |
| 20 | |
| 21 bool VPNProvider::Key::MatchesNetwork( | |
| 22 const chromeos::NetworkState& network) const { | |
| 23 if (network.type() != shill::kTypeVPN) | |
| 24 return false; | |
| 25 const bool network_uses_third_party_provider = | |
| 26 network.vpn_provider_type() == shill::kProviderThirdPartyVpn; | |
| 27 if (!third_party) | |
| 28 return !network_uses_third_party_provider; | |
| 29 return network_uses_third_party_provider && | |
| 30 network.third_party_vpn_provider_extension_id() == extension_id; | |
| 31 } | |
| 32 | |
| 33 VPNProvider::VPNProvider(const Key& key, const std::string& name) | |
| 34 : key(key), name(name) {} | |
| 35 | |
| 36 VPNDelegate::Observer::~Observer() {} | |
| 37 | |
| 38 VPNDelegate::VPNDelegate() {} | |
| 39 | |
| 40 VPNDelegate::~VPNDelegate() {} | |
| 41 | |
| 42 void VPNDelegate::AddObserver(Observer* observer) { | |
| 43 observer_list_.AddObserver(observer); | |
| 44 } | |
| 45 | |
| 46 void VPNDelegate::RemoveObserver(Observer* observer) { | |
| 47 observer_list_.RemoveObserver(observer); | |
| 48 } | |
| 49 | |
| 50 void VPNDelegate::NotifyObservers() { | |
| 51 FOR_EACH_OBSERVER(Observer, observer_list_, OnVPNProvidersChanged()); | |
| 52 } | |
| 53 | |
| 54 } // namespace ash | |
| OLD | NEW |