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

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: Updated after latest round of UI reviews. 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
« no previous file with comments | « ash/system/chromeos/network/tray_vpn.cc ('k') | ash/system/chromeos/network/vpn_list_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..df18b5b5c8e9a61ddbe10f4994f5693d059ae1b3
--- /dev/null
+++ b/ash/system/chromeos/network/vpn_list_view.h
@@ -0,0 +1,95 @@
+// 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 {
+
+// A list of VPN providers and networks that shows VPN providers and networks in
+// a hierarchical layout, allowing the user to see at a glance which provider a
+// network belongs to. The only exception is the currently connected or
+// connecting network, which is detached from its provider and moved to the top.
+// If there is a connected network, a disconnect button is shown next to its
+// name.
+//
+// Disconnected 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 network to the list.
+ void AddNetwork(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_;
+
+ // 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_;
+
+ // Whether the list is currently empty (i.e., the next entry added will become
+ // the topmost entry).
+ bool list_empty_ = true;
+
+ DISALLOW_COPY_AND_ASSIGN(VPNListView);
+};
+
+} // namespace ash
+
+#endif // ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
« no previous file with comments | « ash/system/chromeos/network/tray_vpn.cc ('k') | ash/system/chromeos/network/vpn_list_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698