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

Side by Side 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 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 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
7
8 #include <map>
9 #include <string>
10
11 #include "ash/system/chromeos/network/vpn_delegate.h"
12 #include "ash/system/tray/view_click_listener.h"
13 #include "base/macros.h"
14 #include "chromeos/network/network_state_handler.h"
15 #include "ui/chromeos/network/network_list_view_base.h"
16
17 namespace chromeos {
18 class NetworkState;
19 }
20
21 namespace ui {
22 class NetworkListDelegate;
23 }
24
25 namespace views {
26 class View;
27 }
28
29 namespace ash {
30
31 class HoverHighlightView;
32
33 // A list of VPN providers and networks. If there currently is a connected or
34 // connecting network, only that network is shown, followed by a disconnect
35 // button. Otherwise, a hierarchical list of all available VPN providers and
36 // networks is shown, allowing the user to see at a glance which provider each
37 // network belongs to.
38 //
39 // Networks are arranged in shill's priority order within each provider and the
40 // providers are arranged in the order of their highest priority network.
41 // Clicking on a disconnected network triggers a connection attempt. Clicking on
42 // the currently connected or connecting network shows its configuration dialog.
43 // Clicking on a provider shows the provider's "add network" dialog.
44 class VPNListView : public ui::NetworkListViewBase,
45 public VPNDelegate::Observer,
46 public ViewClickListener {
47 public:
48 explicit VPNListView(ui::NetworkListDelegate* delegate);
49 ~VPNListView() override;
50
51 // ui::NetworkListViewBase:
52 void Update() override;
53 bool IsNetworkEntry(views::View* view,
54 std::string* service_path) const override;
55
56 // VPNDelegate::Observer:
57 void OnVPNProvidersChanged() override;
58
59 // ViewClickListener:
60 void OnViewClicked(views::View* sender) override;
61
62 private:
63 // Adds a connected or connecting network, followed by a disconnect button, to
64 // the list.
65 void AddConnectedOrConnectingNetwork(const chromeos::NetworkState* network);
66
67 // Adds the VPN provider identified by |key| to the list, along with any
68 // networks that belong to this provider.
69 void AddProviderAndNetworks(
70 const VPNProvider::Key& key,
71 const std::string& name,
72 const chromeos::NetworkStateHandler::NetworkStateList& networks);
73
74 // Adds all available VPN providers and networks to the list.
75 void AddProvidersAndNetworks(
76 const chromeos::NetworkStateHandler::NetworkStateList& networks);
77
78 ui::NetworkListDelegate* const delegate_;
79
80 // The service path of the currently connected or connecting network, or an
81 // empty string if there is no connected or connecting network.
82 std::string connected_or_connecting_service_path_;
83
84 // The disconnect button shown underneath the currently connected or
85 // connecting network, or a nullptr if there is no connected or connecting
86 // network.
87 HoverHighlightView* disconnect_button_ = nullptr;
88
89 // A mapping from each VPN provider's list entry to the provider's key.
90 std::map<const views::View* const, VPNProvider::Key> provider_view_key_map_;
91
92 // A mapping from each network's list entry to the network's service path.
93 std::map<const views::View* const, std::string>
94 network_view_service_path_map_;
95
96 DISALLOW_COPY_AND_ASSIGN(VPNListView);
97 };
98
99 } // namespace ash
100
101 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698