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

Unified Diff: ash/common/system/chromeos/network/vpn_delegate.cc

Issue 2522613004: Revert of chromeos: Convert ash VPNDelegate interface to mojo (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/system/chromeos/network/vpn_delegate.cc
diff --git a/ash/common/system/chromeos/network/vpn_delegate.cc b/ash/common/system/chromeos/network/vpn_delegate.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8a05b2bfd52f41984613f7a21189bf1b95036ca9
--- /dev/null
+++ b/ash/common/system/chromeos/network/vpn_delegate.cc
@@ -0,0 +1,74 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ash/common/system/chromeos/network/vpn_delegate.h"
+
+#include "base/logging.h"
+
+namespace ash {
+
+VPNProvider::VPNProvider() : third_party(false) {}
+
+VPNProvider::VPNProvider(const std::string& extension_id,
+ const std::string& third_party_provider_name)
+ : third_party(true),
+ extension_id(extension_id),
+ third_party_provider_name(third_party_provider_name) {
+ DCHECK(!extension_id.empty());
+ DCHECK(!third_party_provider_name.empty());
+}
+
+bool VPNProvider::operator==(const VPNProvider& other) const {
+ return third_party == other.third_party &&
+ extension_id == other.extension_id &&
+ third_party_provider_name == other.third_party_provider_name;
+}
+
+VPNDelegate::Observer::~Observer() {}
+
+VPNDelegate::VPNDelegate() {
+ AddBuiltInProvider();
+}
+
+VPNDelegate::~VPNDelegate() {}
+
+bool VPNDelegate::HaveThirdPartyVPNProviders() const {
+ for (const VPNProvider& provider : vpn_providers_) {
+ if (provider.third_party)
+ return true;
+ }
+ return false;
+}
+
+void VPNDelegate::AddObserver(Observer* observer) {
+ observer_list_.AddObserver(observer);
+}
+
+void VPNDelegate::RemoveObserver(Observer* observer) {
+ observer_list_.RemoveObserver(observer);
+}
+
+void VPNDelegate::SetThirdPartyVpnProviders(
+ const std::vector<VPNProvider>& third_party_providers) {
+ vpn_providers_.clear();
+ vpn_providers_.reserve(third_party_providers.size() + 1);
+ AddBuiltInProvider();
+ // Append the extension-backed providers.
+ vpn_providers_.insert(vpn_providers_.end(), third_party_providers.begin(),
+ third_party_providers.end());
+ NotifyObservers();
+}
+
+void VPNDelegate::NotifyObservers() {
+ for (auto& observer : observer_list_)
+ observer.OnVPNProvidersChanged();
+}
+
+void VPNDelegate::AddBuiltInProvider() {
+ // The VPNProvider() constructor generates the built-in provider and has no
+ // extension ID.
+ vpn_providers_.push_back(VPNProvider());
+}
+
+} // namespace ash
« no previous file with comments | « ash/common/system/chromeos/network/vpn_delegate.h ('k') | ash/common/system/chromeos/network/vpn_delegate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698