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

Side by Side Diff: ash/common/system/chromeos/network/vpn_list.cc

Issue 2732813002: chromeos: Move files in //ash/common to //ash, part 1 (Closed)
Patch Set: rebase Created 3 years, 9 months 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
(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/common/system/chromeos/network/vpn_list.h"
6
7 #include <utility>
8
9 #include "base/logging.h"
10
11 namespace ash {
12
13 VPNProvider::VPNProvider() : third_party(false) {}
14
15 VPNProvider::VPNProvider(const std::string& extension_id,
16 const std::string& third_party_provider_name)
17 : third_party(true),
18 extension_id(extension_id),
19 third_party_provider_name(third_party_provider_name) {
20 DCHECK(!extension_id.empty());
21 DCHECK(!third_party_provider_name.empty());
22 }
23
24 bool VPNProvider::operator==(const VPNProvider& other) const {
25 return third_party == other.third_party &&
26 extension_id == other.extension_id &&
27 third_party_provider_name == other.third_party_provider_name;
28 }
29
30 VpnList::Observer::~Observer() {}
31
32 VpnList::VpnList() {
33 AddBuiltInProvider();
34 }
35
36 VpnList::~VpnList() {}
37
38 bool VpnList::HaveThirdPartyVPNProviders() const {
39 for (const VPNProvider& provider : vpn_providers_) {
40 if (provider.third_party)
41 return true;
42 }
43 return false;
44 }
45
46 void VpnList::AddObserver(Observer* observer) {
47 observer_list_.AddObserver(observer);
48 }
49
50 void VpnList::RemoveObserver(Observer* observer) {
51 observer_list_.RemoveObserver(observer);
52 }
53
54 void VpnList::BindRequest(mojom::VpnListRequest request) {
55 bindings_.AddBinding(this, std::move(request));
56 }
57
58 void VpnList::SetThirdPartyVpnProviders(
59 std::vector<mojom::ThirdPartyVpnProviderPtr> providers) {
60 vpn_providers_.clear();
61 vpn_providers_.reserve(providers.size() + 1);
62 // Add the OpenVPN provider.
63 AddBuiltInProvider();
64 // Append the extension-backed providers.
65 for (const auto& provider : providers) {
66 vpn_providers_.push_back(
67 VPNProvider(provider->extension_id, provider->name));
68 }
69 NotifyObservers();
70 }
71
72 void VpnList::NotifyObservers() {
73 for (auto& observer : observer_list_)
74 observer.OnVPNProvidersChanged();
75 }
76
77 void VpnList::AddBuiltInProvider() {
78 // The VPNProvider() constructor generates the built-in provider and has no
79 // extension ID.
80 vpn_providers_.push_back(VPNProvider());
81 }
82
83 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/vpn_list.h ('k') | ash/common/system/chromeos/network/vpn_list_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698