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

Unified Diff: ash/system/chromeos/network/vpn_list_view.h

Issue 980943005: Add ash UI for third-party VPNs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@f_2_407541_434711_remove_combined_name
Patch Set: Added a VPNProvider::Key abstraction. Created 5 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 side-by-side diff with in-line comments
Download patch
Index: ash/system/chromeos/network/vpn_list_view.h
diff --git a/ash/system/chromeos/network/vpn_list_view.h b/ash/system/chromeos/network/vpn_list_view.h
new file mode 100644
index 0000000000000000000000000000000000000000..f53e2d7eb03b13bada9dbb363f36abd28165fab6
--- /dev/null
+++ b/ash/system/chromeos/network/vpn_list_view.h
@@ -0,0 +1,101 @@
+// 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.
+
+#ifndef ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
+#define ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
+
+#include <map>
+#include <string>
+
+#include "ash/system/chromeos/network/vpn_delegate.h"
+#include "ash/system/tray/view_click_listener.h"
+#include "base/macros.h"
+#include "chromeos/network/network_state_handler.h"
+#include "ui/chromeos/network/network_list_view_base.h"
+
+namespace chromeos {
+class NetworkState;
+}
+
+namespace ui {
+class NetworkListDelegate;
+}
+
+namespace views {
+class View;
+}
+
+namespace ash {
+
+class HoverHighlightView;
+
+// A list of VPN providers and networks. If there currently is a connected or
+// connecting network, only that network is shown, followed by a disconnect
+// button. Otherwise, a hierarchical list of all available VPN providers and
+// networks is shown, allowing the user to see at a glance which provider each
+// network belongs to.
+//
+// Networks are arranged in shill's priority order within each provider and the
+// providers are arranged in the order of their highest priority network.
+// Clicking on a disconnected network triggers a connection attempt. Clicking on
+// the currently connected or connecting network shows its configuration dialog.
+// Clicking on a provider shows the provider's "add network" dialog.
+class VPNListView : public ui::NetworkListViewBase,
+ public VPNDelegate::Observer,
+ public ViewClickListener {
+ public:
+ explicit VPNListView(ui::NetworkListDelegate* delegate);
+ ~VPNListView() override;
+
+ // ui::NetworkListViewBase:
+ void Update() override;
+ bool IsNetworkEntry(views::View* view,
+ std::string* service_path) const override;
+
+ // VPNDelegate::Observer:
+ void OnVPNProvidersChanged() override;
+
+ // ViewClickListener:
+ void OnViewClicked(views::View* sender) override;
+
+ private:
+ // Adds a connected or connecting network, followed by a disconnect button, to
+ // the list.
+ void AddConnectedOrConnectingNetwork(const chromeos::NetworkState* network);
+
+ // Adds the VPN provider identified by |key| to the list, along with any
+ // networks that belong to this provider.
+ void AddProviderAndNetworks(
+ const VPNProvider::Key& key,
+ const std::string& name,
+ const chromeos::NetworkStateHandler::NetworkStateList& networks);
+
+ // Adds all available VPN providers and networks to the list.
+ void AddProvidersAndNetworks(
+ const chromeos::NetworkStateHandler::NetworkStateList& networks);
+
+ ui::NetworkListDelegate* const delegate_;
+
+ // The service path of the currently connected or connecting network, or an
+ // empty string if there is no connected or connecting network.
+ std::string connected_or_connecting_service_path_;
+
+ // The disconnect button shown underneath the currently connected or
+ // connecting network, or a nullptr if there is no connected or connecting
+ // network.
+ HoverHighlightView* disconnect_button_ = nullptr;
+
+ // A mapping from each VPN provider's list entry to the provider's key.
+ std::map<const views::View* const, VPNProvider::Key> provider_view_key_map_;
+
+ // A mapping from each network's list entry to the network's service path.
+ std::map<const views::View* const, std::string>
+ network_view_service_path_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(VPNListView);
+};
+
+} // namespace ash
+
+#endif // ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_

Powered by Google App Engine
This is Rietveld 408576698