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.
5 #ifndef ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
6 #define ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_
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"
22 class NetworkListDelegate
;
31 // 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
33 // 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.
35 // If there is a connected network, a disconnect button is shown next to its
38 // Disconnected networks are arranged in shill's priority order within each
39 // provider and the providers are arranged in the order of their highest
40 // priority network. Clicking on a disconnected network triggers a connection
41 // attempt. Clicking on the currently connected or connecting network shows its
42 // configuration dialog. Clicking on a provider shows the provider's "add
44 class VPNListView
: public ui::NetworkListViewBase
,
45 public VPNDelegate::Observer
,
46 public ViewClickListener
{
48 explicit VPNListView(ui::NetworkListDelegate
* delegate
);
49 ~VPNListView() override
;
51 // ui::NetworkListViewBase:
52 void Update() override
;
53 bool IsNetworkEntry(views::View
* view
,
54 std::string
* service_path
) const override
;
56 // VPNDelegate::Observer:
57 void OnVPNProvidersChanged() override
;
60 void OnViewClicked(views::View
* sender
) override
;
63 // Adds a network to the list.
64 void AddNetwork(const chromeos::NetworkState
* network
);
66 // Adds the VPN provider identified by |key| to the list, along with any
67 // networks that belong to this provider.
68 void AddProviderAndNetworks(
69 const VPNProvider::Key
& key
,
70 const std::string
& name
,
71 const chromeos::NetworkStateHandler::NetworkStateList
& networks
);
73 // Adds all available VPN providers and networks to the list.
74 void AddProvidersAndNetworks(
75 const chromeos::NetworkStateHandler::NetworkStateList
& networks
);
77 ui::NetworkListDelegate
* const delegate_
;
79 // A mapping from each VPN provider's list entry to the provider's key.
80 std::map
<const views::View
* const, VPNProvider::Key
> provider_view_key_map_
;
82 // A mapping from each network's list entry to the network's service path.
83 std::map
<const views::View
* const, std::string
>
84 network_view_service_path_map_
;
86 // Whether the list is currently empty (i.e., the next entry added will become
87 // the topmost entry).
88 bool list_empty_
= true;
90 DISALLOW_COPY_AND_ASSIGN(VPNListView
);
95 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_VPN_LIST_VIEW_H_