OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_NETWORK_LIST_H_ | 5 #ifndef ASH_SYSTEM_NETWORK_NETWORK_LIST_H_ |
6 #define ASH_SYSTEM_NETWORK_NETWORK_LIST_H_ | 6 #define ASH_SYSTEM_NETWORK_NETWORK_LIST_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 "ash/system/network/network_icon_animation_observer.h" | 14 #include "ash/system/network/network_icon_animation_observer.h" |
15 #include "ash/system/network/network_info.h" | 15 #include "ash/system/network/network_info.h" |
16 #include "ash/system/network/network_list_view_base.h" | 16 #include "ash/system/network/network_list_view_base.h" |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "chromeos/network/network_state_handler.h" | 18 #include "chromeos/network/network_state_handler.h" |
19 #include "chromeos/network/network_type_pattern.h" | 19 #include "chromeos/network/network_type_pattern.h" |
20 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" |
21 | 21 |
22 namespace views { | 22 namespace views { |
23 class Label; | 23 class Label; |
24 class Separator; | 24 class Separator; |
25 class View; | 25 class View; |
26 } | 26 } |
27 | 27 |
28 namespace ash { | 28 namespace ash { |
29 | |
30 struct NetworkInfo; | 29 struct NetworkInfo; |
31 class NetworkListDelegate; | |
32 class TriView; | 30 class TriView; |
33 | 31 |
34 // 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 |
35 // network types except VPNs. For VPNs, see the |VPNList| class. | 33 // network types except VPNs. For VPNs, see the |VPNList| class. |
36 class NetworkListView : public NetworkListViewBase, | 34 class NetworkListView : public NetworkListViewBase, |
37 public network_icon::AnimationObserver { | 35 public network_icon::AnimationObserver { |
38 public: | 36 public: |
39 class SectionHeaderRowView; | 37 class SectionHeaderRowView; |
40 | 38 |
41 explicit NetworkListView(NetworkListDelegate* delegate); | 39 explicit NetworkListView(tray::NetworkStateListDetailedView* detailed_view); |
42 ~NetworkListView() override; | 40 ~NetworkListView() override; |
43 | 41 |
44 // NetworkListViewBase: | 42 // NetworkListViewBase: |
45 void Update() override; | 43 void Update() override; |
46 bool IsNetworkEntry(views::View* view, std::string* guid) const override; | 44 bool IsNetworkEntry(views::View* view, std::string* guid) const override; |
47 | 45 |
48 private: | 46 private: |
49 // Clears |network_list_| and adds to it |networks| that match |delegate_|'s | 47 // Clears |network_list_| and adds to it |networks| that match |delegate_|'s |
50 // network type pattern. | 48 // network type pattern. |
51 void UpdateNetworks( | 49 void UpdateNetworks( |
(...skipping 13 matching lines...) Expand all Loading... |
65 void UpdateNetworkListInternal(); | 63 void UpdateNetworkListInternal(); |
66 | 64 |
67 // Adds new or updates existing child views including header row and messages. | 65 // Adds new or updates existing child views including header row and messages. |
68 // Returns a set of guids for the added network connections. | 66 // Returns a set of guids for the added network connections. |
69 std::unique_ptr<std::set<std::string>> UpdateNetworkListEntries(); | 67 std::unique_ptr<std::set<std::string>> UpdateNetworkListEntries(); |
70 | 68 |
71 // Creates the view which displays a warning message, if a VPN or proxy is | 69 // Creates the view which displays a warning message, if a VPN or proxy is |
72 // being used. | 70 // being used. |
73 TriView* CreateConnectionWarning(); | 71 TriView* CreateConnectionWarning(); |
74 | 72 |
| 73 // Creates and returns a View with the information in |info|. |
| 74 views::View* CreateViewForNetwork(const NetworkInfo& info); |
| 75 |
| 76 // Updates |view| with the information in |info|. Note that |view| is |
| 77 // guaranteed to be a View returned from |CreateViewForNetwork()|. |
| 78 void UpdateViewForNetwork(views::View* view, const NetworkInfo& info); |
| 79 |
| 80 // Creates the view of an extra icon appearing next to the network name |
| 81 // indicating that the network is controlled by an extension. If no extension |
| 82 // is registered for this network, returns |nullptr|. |
| 83 views::View* CreateControlledByExtensionView(const NetworkInfo& info); |
| 84 |
75 // Adds or updates child views representing the network connections when | 85 // Adds or updates child views representing the network connections when |
76 // |is_wifi| is matching the attribute of a network connection starting at | 86 // |is_wifi| is matching the attribute of a network connection starting at |
77 // |child_index|. Returns a set of guids for the added network | 87 // |child_index|. Returns a set of guids for the added network |
78 // connections. | 88 // connections. |
79 std::unique_ptr<std::set<std::string>> UpdateNetworkChildren( | 89 std::unique_ptr<std::set<std::string>> UpdateNetworkChildren( |
80 NetworkInfo::Type type, | 90 NetworkInfo::Type type, |
81 int child_index); | 91 int child_index); |
82 void UpdateNetworkChild(int index, const NetworkInfo* info); | 92 void UpdateNetworkChild(int index, const NetworkInfo* info); |
83 | 93 |
84 // Reorders children of |container()| as necessary placing |view| at |index|. | 94 // Reorders children of |container()| as necessary placing |view| at |index|. |
(...skipping 20 matching lines...) Expand all Loading... |
105 views::Separator** separator_view); | 115 views::Separator** separator_view); |
106 | 116 |
107 // network_icon::AnimationObserver: | 117 // network_icon::AnimationObserver: |
108 void NetworkIconChanged() override; | 118 void NetworkIconChanged() override; |
109 | 119 |
110 // Returns true if the info should be updated to the view for network, | 120 // Returns true if the info should be updated to the view for network, |
111 // otherwise false. | 121 // otherwise false. |
112 bool NeedUpdateViewForNetwork(const NetworkInfo& info) const; | 122 bool NeedUpdateViewForNetwork(const NetworkInfo& info) const; |
113 | 123 |
114 bool needs_relayout_; | 124 bool needs_relayout_; |
115 NetworkListDelegate* delegate_; | |
116 | 125 |
117 views::Label* no_wifi_networks_view_; | 126 views::Label* no_wifi_networks_view_; |
118 views::Label* no_cellular_networks_view_; | 127 views::Label* no_cellular_networks_view_; |
119 SectionHeaderRowView* cellular_header_view_; | 128 SectionHeaderRowView* cellular_header_view_; |
120 SectionHeaderRowView* tether_header_view_; | 129 SectionHeaderRowView* tether_header_view_; |
121 SectionHeaderRowView* wifi_header_view_; | 130 SectionHeaderRowView* wifi_header_view_; |
122 views::Separator* cellular_separator_view_; | 131 views::Separator* cellular_separator_view_; |
123 views::Separator* tether_separator_view_; | 132 views::Separator* tether_separator_view_; |
124 views::Separator* wifi_separator_view_; | 133 views::Separator* wifi_separator_view_; |
125 TriView* connection_warning_; | 134 TriView* connection_warning_; |
(...skipping 11 matching lines...) Expand all Loading... |
137 // Save a map of network guids to their infos against current |network_list_|. | 146 // Save a map of network guids to their infos against current |network_list_|. |
138 using NetworkInfoMap = std::map<std::string, std::unique_ptr<NetworkInfo>>; | 147 using NetworkInfoMap = std::map<std::string, std::unique_ptr<NetworkInfo>>; |
139 NetworkInfoMap last_network_info_map_; | 148 NetworkInfoMap last_network_info_map_; |
140 | 149 |
141 DISALLOW_COPY_AND_ASSIGN(NetworkListView); | 150 DISALLOW_COPY_AND_ASSIGN(NetworkListView); |
142 }; | 151 }; |
143 | 152 |
144 } // namespace ash | 153 } // namespace ash |
145 | 154 |
146 #endif // ASH_SYSTEM_NETWORK_NETWORK_LIST_H_ | 155 #endif // ASH_SYSTEM_NETWORK_NETWORK_LIST_H_ |
OLD | NEW |