Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
tdanderson
2016/09/23 22:14:10
2016 here and in the .cc?
varkha
2016/09/29 20:31:01
Done.
| |
| 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 UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ | |
| 6 #define UI_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 "base/macros.h" | |
| 15 #include "chromeos/network/network_state_handler.h" | |
| 16 #include "ui/chromeos/network/network_icon_animation_observer.h" | |
| 17 #include "ui/chromeos/network/network_list_view_base.h" | |
| 18 #include "ui/chromeos/ui_chromeos_export.h" | |
| 19 #include "ui/gfx/image/image_skia.h" | |
| 20 #include "ui/views/controls/button/button.h" | |
| 21 | |
| 22 namespace views { | |
| 23 class Label; | |
| 24 class View; | |
| 25 } | |
| 26 | |
| 27 namespace ui { | |
| 28 | |
| 29 struct NetworkInfo; | |
| 30 class NetworkListDelegate; | |
| 31 | |
| 32 // A list of available networks of a given type. This class is used for all | |
| 33 // network types except VPNs. For VPNs, see the |VPNList| class. | |
| 34 class UI_CHROMEOS_EXPORT NetworkListViewMd | |
| 35 : public NetworkListViewBase, | |
| 36 public network_icon::AnimationObserver, | |
| 37 public views::ButtonListener { | |
| 38 public: | |
| 39 explicit NetworkListViewMd(NetworkListDelegate* delegate); | |
| 40 ~NetworkListViewMd() override; | |
| 41 | |
| 42 // NetworkListViewBase: | |
| 43 void Update() override; | |
| 44 bool IsNetworkEntry(views::View* view, | |
| 45 std::string* service_path) const override; | |
| 46 | |
| 47 private: | |
| 48 class WifiHeaderRowView; | |
| 49 | |
| 50 // Clears |network_list_| and adds to it |networks| that match |delegate_|'s | |
| 51 // network type pattern. | |
| 52 void UpdateNetworks( | |
| 53 const chromeos::NetworkStateHandler::NetworkStateList& networks); | |
| 54 | |
| 55 // Updates |network_list_| entries and sets |this| to observe network icon | |
| 56 // animations when any of the networks are in connecting state. | |
| 57 void UpdateNetworkIcons(); | |
| 58 | |
| 59 // Orders entries in |network_list_| such that higher priority network types | |
| 60 // are at the top of the list. | |
| 61 void OrderNetworks(); | |
| 62 | |
| 63 // Refreshes a list of child views, updates |network_map_| and | |
| 64 // |service_path_map_| and performs layout making sure selected view if any is | |
| 65 // scrolled into view. | |
| 66 void UpdateNetworkListInternal(); | |
| 67 | |
| 68 // Adds new or updates existing child views including header row and messages. | |
| 69 void UpdateNetworkListEntries(std::set<std::string>* new_service_paths); | |
| 70 | |
| 71 // Adds or updates child views representing the network connections and | |
| 72 // updates |child_index| if |is_wifi| matches the attribute of a network | |
| 73 // connection. Adds the service path of each added connection to | |
| 74 // |new_service_paths|. | |
| 75 void UpdateNetworkChildren(bool is_wifi, | |
| 76 std::set<std::string>* new_service_paths, | |
| 77 int* child_index); | |
| 78 void UpdateNetworkChild(int index, const NetworkInfo* info); | |
| 79 | |
| 80 // Reorders children of |container_| as necessary placing |view| at |index|. | |
|
Evan Stade
2016/09/23 21:32:13
I see that this is a member of NetworkListViewBase
varkha
2016/09/29 20:31:02
Done.
| |
| 81 bool PlaceViewAtIndex(views::View* view, int index); | |
| 82 | |
| 83 // Creates a |label| with text specified by |message_id| and adds it to | |
| 84 // |container_| if necessary or updates the text and reorders the |container_| | |
| 85 // placing the label at |child_index| and incrementing the index. | |
| 86 // When |message_id| is zero removes the |label| from the |container_| and | |
| 87 // destroys it. | |
| 88 void UpdateInfoLabel(int message_id, int* child_index, views::Label** label); | |
| 89 | |
| 90 // Creates a Wi-Fi header row |view| and adds it to |container_| if necessary | |
| 91 // and reorders the |container_| placing the |view| at |child_index|. Always | |
| 92 // increments the |*child_index|. | |
| 93 void UpdateWifiHeaderRow(bool enabled, | |
| 94 int* child_index, | |
| 95 WifiHeaderRowView** view); | |
| 96 | |
| 97 // network_icon::AnimationObserver: | |
| 98 void NetworkIconChanged() override; | |
| 99 | |
| 100 // views::ButtonListener: | |
| 101 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | |
| 102 | |
| 103 bool needs_relayout_; | |
| 104 NetworkListDelegate* delegate_; | |
| 105 | |
| 106 views::Label* no_wifi_networks_view_; | |
| 107 views::Label* no_cellular_networks_view_; | |
| 108 WifiHeaderRowView* wifi_header_view_; | |
| 109 | |
| 110 // An owned list of network info. | |
| 111 std::vector<std::unique_ptr<NetworkInfo>> network_list_; | |
| 112 | |
| 113 typedef std::map<views::View*, std::string> NetworkMap; | |
| 114 NetworkMap network_map_; | |
| 115 | |
| 116 // A map of network service paths to their view. | |
| 117 typedef std::map<std::string, views::View*> ServicePathMap; | |
| 118 ServicePathMap service_path_map_; | |
| 119 | |
| 120 DISALLOW_COPY_AND_ASSIGN(NetworkListViewMd); | |
| 121 }; | |
| 122 | |
| 123 } // namespace ui | |
| 124 | |
| 125 #endif // UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ | |
| OLD | NEW |