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

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

Issue 2510083006: chromeos: Move ownership of ash VPN provider list from chrome into ash (Closed)
Patch Set: rebase 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
index 00eb3e26c8314338d0463641380921b5737bc5e4..44fa49c969884a365c90168c7a4e830e77f7a35b 100644
--- a/ash/common/system/chromeos/network/vpn_delegate.cc
+++ b/ash/common/system/chromeos/network/vpn_delegate.cc
@@ -4,8 +4,10 @@
#include "ash/common/system/chromeos/network/vpn_delegate.h"
+#include "ash/common/strings/grit/ash_strings.h"
#include "chromeos/network/network_state.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
+#include "ui/base/l10n/l10n_util.h"
namespace ash {
@@ -33,12 +35,26 @@ bool VPNProvider::Key::MatchesNetwork(
VPNProvider::VPNProvider(const Key& key, const std::string& name)
: key(key), name(name) {}
+bool VPNProvider::operator==(const VPNProvider& other) const {
+ return key == other.key && name == other.name;
+}
+
VPNDelegate::Observer::~Observer() {}
-VPNDelegate::VPNDelegate() {}
+VPNDelegate::VPNDelegate() {
+ AddBuiltInProvider();
+}
VPNDelegate::~VPNDelegate() {}
+bool VPNDelegate::HaveThirdPartyVPNProviders() const {
+ for (const VPNProvider& provider : vpn_providers_) {
+ if (provider.key.third_party)
+ return true;
+ }
+ return false;
+}
+
void VPNDelegate::AddObserver(Observer* observer) {
observer_list_.AddObserver(observer);
}
@@ -47,9 +63,25 @@ void VPNDelegate::RemoveObserver(Observer* observer) {
observer_list_.RemoveObserver(observer);
}
+void VPNDelegate::SetThirdPartyVpnProviders(
+ const std::vector<VPNProvider>& providers) {
+ // Reset the list with the extension-backed providers.
+ vpn_providers_ = providers;
+ AddBuiltInProvider();
+ NotifyObservers();
+}
+
void VPNDelegate::NotifyObservers() {
for (auto& observer : observer_list_)
observer.OnVPNProvidersChanged();
}
+void VPNDelegate::AddBuiltInProvider() {
+ // The VPNProvider::Key() constructor generates a key that identifies that
+ // built-in provider and has no extension ID.
+ vpn_providers_.push_back(VPNProvider(
+ VPNProvider::Key(),
+ l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_VPN_BUILT_IN_PROVIDER)));
stevenjb 2016/11/21 20:23:18 Can we make this an empty string and modify the Vi
James Cook 2016/11/21 23:58:38 Done.
+}
+
} // namespace ash

Powered by Google App Engine
This is Rietveld 408576698