OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ASH_SYSTEM_NETWORK_VPN_LIST_VIEW_H_ | 5 #ifndef ASH_SYSTEM_NETWORK_VPN_LIST_VIEW_H_ |
6 #define ASH_SYSTEM_NETWORK_VPN_LIST_VIEW_H_ | 6 #define ASH_SYSTEM_NETWORK_VPN_LIST_VIEW_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ash/system/network/network_list_view_base.h" | 11 #include "ash/system/network/network_list_view_base.h" |
12 #include "ash/system/network/vpn_list.h" | 12 #include "ash/system/network/vpn_list.h" |
13 #include "ash/system/tray/view_click_listener.h" | 13 #include "ash/system/tray/view_click_listener.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "chromeos/network/network_state_handler.h" | 15 #include "chromeos/network/network_state_handler.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 class NetworkState; | 18 class NetworkState; |
19 } | 19 } |
20 | 20 |
21 namespace ash { | |
22 class NetworkListDelegate; | |
23 } | |
24 | |
25 namespace views { | 21 namespace views { |
26 class View; | 22 class View; |
27 } | 23 } |
28 | 24 |
29 namespace ash { | 25 namespace ash { |
| 26 namespace tray { |
| 27 class NetworkStateListDetailedView; |
| 28 } |
30 | 29 |
31 // A list of VPN providers and networks that shows VPN providers and networks in | 30 // A list of VPN providers and networks that shows VPN providers and networks in |
32 // a hierarchical layout, allowing the user to see at a glance which provider a | 31 // a hierarchical layout, allowing the user to see at a glance which provider a |
33 // network belongs to. The only exception is the currently connected or | 32 // network belongs to. The only exception is the currently connected or |
34 // connecting network, which is detached from its provider and moved to the top. | 33 // connecting network, which is detached from its provider and moved to the top. |
35 // If there is a connected network, a disconnect button is shown next to its | 34 // If there is a connected network, a disconnect button is shown next to its |
36 // name. | 35 // name. |
37 // | 36 // |
38 // Disconnected networks are arranged in shill's priority order within each | 37 // Disconnected networks are arranged in shill's priority order within each |
39 // provider and the providers are arranged in the order of their highest | 38 // provider and the providers are arranged in the order of their highest |
40 // priority network. Clicking on a disconnected network triggers a connection | 39 // priority network. Clicking on a disconnected network triggers a connection |
41 // attempt. Clicking on the currently connected or connecting network shows its | 40 // attempt. Clicking on the currently connected or connecting network shows its |
42 // configuration dialog. Clicking on a provider shows the provider's "add | 41 // configuration dialog. Clicking on a provider shows the provider's "add |
43 // network" dialog. | 42 // network" dialog. |
44 class VPNListView : public NetworkListViewBase, | 43 class VPNListView : public NetworkListViewBase, |
45 public VpnList::Observer, | 44 public VpnList::Observer, |
46 public ViewClickListener { | 45 public ViewClickListener { |
47 public: | 46 public: |
48 explicit VPNListView(NetworkListDelegate* delegate); | 47 explicit VPNListView(tray::NetworkStateListDetailedView* detailed_view); |
49 ~VPNListView() override; | 48 ~VPNListView() override; |
50 | 49 |
51 // NetworkListViewBase: | 50 // NetworkListViewBase: |
52 void Update() override; | 51 void Update() override; |
53 bool IsNetworkEntry(views::View* view, std::string* guid) const override; | 52 bool IsNetworkEntry(views::View* view, std::string* guid) const override; |
54 | 53 |
55 // VpnList::Observer: | 54 // VpnList::Observer: |
56 void OnVPNProvidersChanged() override; | 55 void OnVPNProvidersChanged() override; |
57 | 56 |
58 // ViewClickListener: | 57 // ViewClickListener: |
59 void OnViewClicked(views::View* sender) override; | 58 void OnViewClicked(views::View* sender) override; |
60 | 59 |
61 private: | 60 private: |
62 // Adds a network to the list. | 61 // Adds a network to the list. |
63 void AddNetwork(const chromeos::NetworkState* network); | 62 void AddNetwork(const chromeos::NetworkState* network); |
64 | 63 |
65 // Adds the VPN provider identified by |vpn_provider| to the list, along with | 64 // Adds the VPN provider identified by |vpn_provider| to the list, along with |
66 // any networks that belong to this provider. | 65 // any networks that belong to this provider. |
67 void AddProviderAndNetworks( | 66 void AddProviderAndNetworks( |
68 const VPNProvider& vpn_provider, | 67 const VPNProvider& vpn_provider, |
69 const chromeos::NetworkStateHandler::NetworkStateList& networks); | 68 const chromeos::NetworkStateHandler::NetworkStateList& networks); |
70 | 69 |
71 // Adds all available VPN providers and networks to the list. | 70 // Adds all available VPN providers and networks to the list. |
72 void AddProvidersAndNetworks( | 71 void AddProvidersAndNetworks( |
73 const chromeos::NetworkStateHandler::NetworkStateList& networks); | 72 const chromeos::NetworkStateHandler::NetworkStateList& networks); |
74 | 73 |
75 NetworkListDelegate* const delegate_; | |
76 | |
77 // A mapping from each VPN provider's list entry to the provider. | 74 // A mapping from each VPN provider's list entry to the provider. |
78 std::map<const views::View* const, VPNProvider> provider_view_map_; | 75 std::map<const views::View* const, VPNProvider> provider_view_map_; |
79 | 76 |
80 // A mapping from each network's list entry to the network's guid. | 77 // A mapping from each network's list entry to the network's guid. |
81 std::map<const views::View* const, std::string> network_view_guid_map_; | 78 std::map<const views::View* const, std::string> network_view_guid_map_; |
82 | 79 |
83 // Whether the list is currently empty (i.e., the next entry added will become | 80 // Whether the list is currently empty (i.e., the next entry added will become |
84 // the topmost entry). | 81 // the topmost entry). |
85 bool list_empty_ = true; | 82 bool list_empty_ = true; |
86 | 83 |
87 DISALLOW_COPY_AND_ASSIGN(VPNListView); | 84 DISALLOW_COPY_AND_ASSIGN(VPNListView); |
88 }; | 85 }; |
89 | 86 |
90 } // namespace ash | 87 } // namespace ash |
91 | 88 |
92 #endif // ASH_SYSTEM_NETWORK_VPN_LIST_VIEW_H_ | 89 #endif // ASH_SYSTEM_NETWORK_VPN_LIST_VIEW_H_ |
OLD | NEW |