Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / system / chromeos / network / vpn_delegate.cc
blob62264a6511f4188aa86c12c7bfb938a05a6d826d
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 #include "ash/system/chromeos/network/vpn_delegate.h"
7 #include "chromeos/network/network_state.h"
8 #include "third_party/cros_system_api/dbus/service_constants.h"
10 namespace ash {
12 VPNProvider::Key::Key() : third_party(false) {
15 VPNProvider::Key::Key(const std::string& extension_id)
16 : third_party(true), extension_id(extension_id) {
19 bool VPNProvider::Key::operator==(const Key& other) const {
20 return other.third_party == third_party && other.extension_id == extension_id;
23 bool VPNProvider::Key::MatchesNetwork(
24 const chromeos::NetworkState& network) const {
25 if (network.type() != shill::kTypeVPN)
26 return false;
27 const bool network_uses_third_party_provider =
28 network.vpn_provider_type() == shill::kProviderThirdPartyVpn;
29 if (!third_party)
30 return !network_uses_third_party_provider;
31 return network_uses_third_party_provider &&
32 network.third_party_vpn_provider_extension_id() == extension_id;
35 VPNProvider::VPNProvider(const Key& key, const std::string& name)
36 : key(key), name(name) {
39 VPNDelegate::Observer::~Observer() {
42 VPNDelegate::VPNDelegate() {
45 VPNDelegate::~VPNDelegate() {
48 void VPNDelegate::AddObserver(Observer* observer) {
49 observer_list_.AddObserver(observer);
52 void VPNDelegate::RemoveObserver(Observer* observer) {
53 observer_list_.RemoveObserver(observer);
56 void VPNDelegate::NotifyObservers() {
57 FOR_EACH_OBSERVER(Observer, observer_list_, OnVPNProvidersChanged());
60 } // namespace ash