OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 UI_CHROMEOS_NETWORK_NETWORK_LIST_H_ | 5 #ifndef UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ |
6 #define UI_CHROMEOS_NETWORK_NETWORK_LIST_H_ | 6 #define UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
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 #include "ui/chromeos/network/network_icon_animation_observer.h" | 16 #include "ui/chromeos/network/network_icon_animation_observer.h" |
17 #include "ui/chromeos/network/network_list_view_base.h" | 17 #include "ui/chromeos/network/network_list_view_base.h" |
18 #include "ui/chromeos/ui_chromeos_export.h" | 18 #include "ui/chromeos/ui_chromeos_export.h" |
19 #include "ui/gfx/image/image_skia.h" | 19 #include "ui/gfx/image/image_skia.h" |
| 20 #include "ui/views/controls/button/button.h" |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 class Label; | 23 class Label; |
23 class View; | 24 class View; |
24 } | 25 } |
25 | 26 |
26 namespace ui { | 27 namespace ui { |
27 | 28 |
28 struct NetworkInfo; | 29 struct NetworkInfo; |
29 class NetworkListDelegate; | 30 class NetworkListDelegate; |
30 | 31 |
31 // A list of available networks of a given type. This class is used for all | 32 // A list of available networks of a given type. This class is used for all |
32 // network types except VPNs. For VPNs, see the |VPNList| class. | 33 // network types except VPNs. For VPNs, see the |VPNList| class. |
33 class UI_CHROMEOS_EXPORT NetworkListView | 34 class UI_CHROMEOS_EXPORT NetworkListViewMd |
34 : public NetworkListViewBase, | 35 : public NetworkListViewBase, |
35 public network_icon::AnimationObserver { | 36 public network_icon::AnimationObserver, |
| 37 public views::ButtonListener { |
36 public: | 38 public: |
37 explicit NetworkListView(NetworkListDelegate* delegate); | 39 explicit NetworkListViewMd(NetworkListDelegate* delegate); |
38 ~NetworkListView() override; | 40 ~NetworkListViewMd() override; |
39 | 41 |
40 // NetworkListViewBase: | 42 // NetworkListViewBase: |
41 void Update() override; | 43 void Update() override; |
42 bool IsNetworkEntry(views::View* view, | 44 bool IsNetworkEntry(views::View* view, |
43 std::string* service_path) const override; | 45 std::string* service_path) const override; |
44 | 46 |
45 private: | 47 private: |
| 48 class WiFiHeaderRowView; |
| 49 |
46 void UpdateNetworks( | 50 void UpdateNetworks( |
47 const chromeos::NetworkStateHandler::NetworkStateList& networks); | 51 const chromeos::NetworkStateHandler::NetworkStateList& networks); |
48 void UpdateNetworkIcons(); | 52 void UpdateNetworkIcons(); |
| 53 void OrderNetworks(); |
49 void UpdateNetworkListInternal(); | 54 void UpdateNetworkListInternal(); |
50 void HandleRelayout(); | 55 void HandleRelayout(); |
51 bool UpdateNetworkListEntries(std::set<std::string>* new_service_paths); | 56 bool UpdateNetworkListEntries(std::set<std::string>* new_service_paths); |
52 bool UpdateNetworkChildren(std::set<std::string>* new_service_paths, | 57 bool UpdateNetworkChildren(std::set<std::string>* new_service_paths, |
53 int* child_index, | 58 int* child_index, |
54 bool highlighted); | 59 bool wifi); |
55 bool UpdateNetworkChild(int index, const NetworkInfo* info); | 60 bool UpdateNetworkChild(int index, const NetworkInfo* info); |
56 bool PlaceViewAtIndex(views::View* view, int index); | 61 bool PlaceViewAtIndex(views::View* view, int index); |
57 bool UpdateInfoLabel(int message_id, int index, views::Label** label); | 62 bool UpdateInfoLabel(int message_id, int index, views::Label** label); |
| 63 bool UpdateWiFiHeaderRow(bool enabled, int index, WiFiHeaderRowView** view); |
58 | 64 |
59 // network_icon::AnimationObserver: | 65 // network_icon::AnimationObserver: |
60 void NetworkIconChanged() override; | 66 void NetworkIconChanged() override; |
61 | 67 |
| 68 // views::ButtonListener: |
| 69 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 70 |
62 NetworkListDelegate* delegate_; | 71 NetworkListDelegate* delegate_; |
63 | 72 |
64 views::Label* no_wifi_networks_view_; | 73 views::Label* no_wifi_networks_view_; |
65 views::Label* no_cellular_networks_view_; | 74 views::Label* no_cellular_networks_view_; |
| 75 WiFiHeaderRowView* wifi_header_view_; |
66 | 76 |
67 // An owned list of network info. | 77 // An owned list of network info. |
68 std::vector<std::unique_ptr<NetworkInfo>> network_list_; | 78 std::vector<std::unique_ptr<NetworkInfo>> network_list_; |
69 | 79 |
70 typedef std::map<views::View*, std::string> NetworkMap; | 80 typedef std::map<views::View*, std::string> NetworkMap; |
71 NetworkMap network_map_; | 81 NetworkMap network_map_; |
72 | 82 |
73 // A map of network service paths to their view. | 83 // A map of network service paths to their view. |
74 typedef std::map<std::string, views::View*> ServicePathMap; | 84 typedef std::map<std::string, views::View*> ServicePathMap; |
75 ServicePathMap service_path_map_; | 85 ServicePathMap service_path_map_; |
76 | 86 |
77 DISALLOW_COPY_AND_ASSIGN(NetworkListView); | 87 DISALLOW_COPY_AND_ASSIGN(NetworkListViewMd); |
78 }; | 88 }; |
79 | 89 |
80 } // namespace ui | 90 } // namespace ui |
81 | 91 |
82 #endif // UI_CHROMEOS_NETWORK_NETWORK_LIST_H_ | 92 #endif // UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ |
OLD | NEW |