Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include "ash/system/chromeos/network/vpn_delegate.h" | 5 #include "ash/system/chromeos/network/vpn_delegate.h" |
| 6 | 6 |
| 7 #include "chromeos/network/network_state.h" | 7 #include "chromeos/network/network_state.h" |
| 8 #include "third_party/cros_system_api/dbus/service_constants.h" | 8 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 9 | 9 |
| 10 namespace ash { | 10 namespace ash { |
| 11 | 11 |
| 12 VPNProvider::Key::Key() : third_party(false) { | 12 VPNProvider::Key::Key() : third_party(false) { |
| 13 } | 13 } |
| 14 | 14 |
| 15 VPNProvider::Key::Key(const std::string& extension_id) | 15 VPNProvider::Key::Key(const std::string& extension_id) |
| 16 : third_party(true), extension_id(extension_id) { | 16 : third_party(true), extension_id(extension_id) { |
|
pneubeck (no reviews)
2015/03/18 18:48:26
extension_id(extension_id)
jesus christ... does th
bartfab (slow)
2015/03/18 19:00:46
Sure. We have lots of code like that. The outer on
| |
| 17 } | 17 } |
| 18 | 18 |
| 19 bool VPNProvider::Key::operator==(const Key& other) const { | 19 bool VPNProvider::Key::operator==(const Key& other) const { |
| 20 return other.third_party == third_party && other.extension_id == extension_id; | 20 return other.third_party == third_party && other.extension_id == extension_id; |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool VPNProvider::Key::MatchesNetwork( | 23 bool VPNProvider::Key::MatchesNetwork( |
| 24 const chromeos::NetworkState& network) const { | 24 const chromeos::NetworkState& network) const { |
| 25 if (network.type() != shill::kTypeVPN) | 25 if (network.type() != shill::kTypeVPN) |
| 26 return false; | 26 return false; |
| 27 if (third_party) | 27 const bool network_uses_third_party_provider = |
| 28 return network.vpn_provider_extension_id() == extension_id; | 28 network.vpn_provider_type() == shill::kProviderThirdPartyVpn; |
| 29 // Currently, all networks with an empty |vpn_provider_extension_id| use a | 29 if (!third_party) |
| 30 // single built-in VPN providers. In the future, we may distinguish between | 30 return !network_uses_third_party_provider; |
| 31 // multiple built-in providers based on the |Provider.Type| property. | 31 return network_uses_third_party_provider && |
| 32 return network.vpn_provider_extension_id().empty(); | 32 network.third_party_vpn_provider_extension_id() == extension_id; |
| 33 } | 33 } |
| 34 | 34 |
| 35 VPNProvider::VPNProvider(const Key& key, const std::string& name) | 35 VPNProvider::VPNProvider(const Key& key, const std::string& name) |
| 36 : key(key), name(name) { | 36 : key(key), name(name) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 VPNDelegate::Observer::~Observer() { | 39 VPNDelegate::Observer::~Observer() { |
| 40 } | 40 } |
| 41 | 41 |
| 42 VPNDelegate::VPNDelegate() { | 42 VPNDelegate::VPNDelegate() { |
| 43 } | 43 } |
| 44 | 44 |
| 45 VPNDelegate::~VPNDelegate() { | 45 VPNDelegate::~VPNDelegate() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 void VPNDelegate::AddObserver(Observer* observer) { | 48 void VPNDelegate::AddObserver(Observer* observer) { |
| 49 observer_list_.AddObserver(observer); | 49 observer_list_.AddObserver(observer); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void VPNDelegate::RemoveObserver(Observer* observer) { | 52 void VPNDelegate::RemoveObserver(Observer* observer) { |
| 53 observer_list_.RemoveObserver(observer); | 53 observer_list_.RemoveObserver(observer); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void VPNDelegate::NotifyObservers() { | 56 void VPNDelegate::NotifyObservers() { |
| 57 FOR_EACH_OBSERVER(Observer, observer_list_, OnVPNProvidersChanged()); | 57 FOR_EACH_OBSERVER(Observer, observer_list_, OnVPNProvidersChanged()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 } // namespace ash | 60 } // namespace ash |
| OLD | NEW |