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

Side by Side Diff: ash/common/system/chromeos/network/network_list_md.h

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 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 2016 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_COMMON_SYSTEM_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_
6 #define ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_
7
8 #include <map>
9 #include <memory>
10 #include <set>
11 #include <string>
12 #include <vector>
13
14 #include "ash/common/system/chromeos/network/network_icon_animation_observer.h"
15 #include "ash/common/system/chromeos/network/network_info.h"
16 #include "ash/common/system/chromeos/network/network_list_view_base.h"
17 #include "base/macros.h"
18 #include "chromeos/network/network_state_handler.h"
19 #include "chromeos/network/network_type_pattern.h"
20 #include "ui/gfx/image/image_skia.h"
21
22 namespace views {
23 class Label;
24 class Separator;
25 class View;
26 }
27
28 namespace ash {
29
30 struct NetworkInfo;
31 class NetworkListDelegate;
32
33 // A list of available networks of a given type. This class is used for all
34 // network types except VPNs. For VPNs, see the |VPNList| class.
35 class NetworkListViewMd : public NetworkListViewBase,
36 public network_icon::AnimationObserver {
37 public:
38 class SectionHeaderRowView;
39
40 explicit NetworkListViewMd(NetworkListDelegate* delegate);
41 ~NetworkListViewMd() override;
42
43 // NetworkListViewBase:
44 void Update() override;
45 bool IsNetworkEntry(views::View* view, std::string* guid) const override;
46
47 private:
48 // Clears |network_list_| and adds to it |networks| that match |delegate_|'s
49 // network type pattern.
50 void UpdateNetworks(
51 const chromeos::NetworkStateHandler::NetworkStateList& networks);
52
53 // Updates |network_list_| entries and sets |this| to observe network icon
54 // animations when any of the networks are in connecting state.
55 void UpdateNetworkIcons();
56
57 // Orders entries in |network_list_| such that higher priority network types
58 // are at the top of the list.
59 void OrderNetworks();
60
61 // Refreshes a list of child views, updates |network_map_| and
62 // |network_guid_map_| and performs layout making sure selected view if any is
63 // scrolled into view.
64 void UpdateNetworkListInternal();
65
66 // Adds new or updates existing child views including header row and messages.
67 // Returns a set of guids for the added network connections.
68 std::unique_ptr<std::set<std::string>> UpdateNetworkListEntries();
69
70 // Adds or updates child views representing the network connections when
71 // |is_wifi| is matching the attribute of a network connection starting at
72 // |child_index|. Returns a set of guids for the added network
73 // connections.
74 std::unique_ptr<std::set<std::string>> UpdateNetworkChildren(
75 NetworkInfo::Type type,
76 int child_index);
77 void UpdateNetworkChild(int index, const NetworkInfo* info);
78
79 // Reorders children of |container()| as necessary placing |view| at |index|.
80 void PlaceViewAtIndex(views::View* view, int index);
81
82 // Creates a Label with text specified by |message_id| and adds it to
83 // |container()| if necessary or updates the text and reorders the
84 // |container()| placing the label at |insertion_index|. When |message_id| is
85 // zero removes the |*label_ptr| from the |container()| and destroys it.
86 // |label_ptr| is an in / out parameter and is only modified if the Label is
87 // created or destroyed.
88 void UpdateInfoLabel(int message_id,
89 int insertion_index,
90 views::Label** label_ptr);
91
92 // Creates a cellular/Wi-Fi header row |view| and adds it to |container()| if
93 // necessary and reorders the |container()| placing the |view| at
94 // |child_index|. Returns the index where the next child should be inserted,
95 // i.e., the index directly after the last inserted child.
96 int UpdateSectionHeaderRow(chromeos::NetworkTypePattern pattern,
97 bool enabled,
98 int child_index,
99 SectionHeaderRowView** view,
100 views::Separator** separator_view);
101
102 // network_icon::AnimationObserver:
103 void NetworkIconChanged() override;
104
105 bool needs_relayout_;
106 NetworkListDelegate* delegate_;
107
108 views::Label* no_wifi_networks_view_;
109 views::Label* no_cellular_networks_view_;
110 SectionHeaderRowView* cellular_header_view_;
111 SectionHeaderRowView* tether_header_view_;
112 SectionHeaderRowView* wifi_header_view_;
113 views::Separator* cellular_separator_view_;
114 views::Separator* tether_separator_view_;
115 views::Separator* wifi_separator_view_;
116
117 // An owned list of network info.
118 std::vector<std::unique_ptr<NetworkInfo>> network_list_;
119
120 using NetworkMap = std::map<views::View*, std::string>;
121 NetworkMap network_map_;
122
123 // A map of network guids to their view.
124 typedef std::map<std::string, views::View*> NetworkGuidMap;
125 NetworkGuidMap network_guid_map_;
126
127 DISALLOW_COPY_AND_ASSIGN(NetworkListViewMd);
128 };
129
130 } // namespace ash
131
132 #endif // ASH_COMMON_SYSTEM_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/network/network_list_delegate.h ('k') | ash/common/system/chromeos/network/network_list_md.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698