Index: ui/chromeos/network/network_list_md.h |
diff --git a/ui/chromeos/network/network_list_md.h b/ui/chromeos/network/network_list_md.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..000da524f4346a5fde4912c20d39fcd84362c169 |
--- /dev/null |
+++ b/ui/chromeos/network/network_list_md.h |
@@ -0,0 +1,125 @@ |
+// 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.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ |
+#define UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ |
+ |
+#include <map> |
+#include <memory> |
+#include <set> |
+#include <string> |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "chromeos/network/network_state_handler.h" |
+#include "ui/chromeos/network/network_icon_animation_observer.h" |
+#include "ui/chromeos/network/network_list_view_base.h" |
+#include "ui/chromeos/ui_chromeos_export.h" |
+#include "ui/gfx/image/image_skia.h" |
+#include "ui/views/controls/button/button.h" |
+ |
+namespace views { |
+class Label; |
+class View; |
+} |
+ |
+namespace ui { |
+ |
+struct NetworkInfo; |
+class NetworkListDelegate; |
+ |
+// A list of available networks of a given type. This class is used for all |
+// network types except VPNs. For VPNs, see the |VPNList| class. |
+class UI_CHROMEOS_EXPORT NetworkListViewMd |
+ : public NetworkListViewBase, |
+ public network_icon::AnimationObserver, |
+ public views::ButtonListener { |
+ public: |
+ explicit NetworkListViewMd(NetworkListDelegate* delegate); |
+ ~NetworkListViewMd() override; |
+ |
+ // NetworkListViewBase: |
+ void Update() override; |
+ bool IsNetworkEntry(views::View* view, |
+ std::string* service_path) const override; |
+ |
+ private: |
+ class WifiHeaderRowView; |
+ |
+ // Clears |network_list_| and adds to it |networks| that match |delegate_|'s |
+ // network type pattern. |
+ void UpdateNetworks( |
+ const chromeos::NetworkStateHandler::NetworkStateList& networks); |
+ |
+ // Updates |network_list_| entries and sets |this| to observe network icon |
+ // animations when any of the networks are in connecting state. |
+ void UpdateNetworkIcons(); |
+ |
+ // Orders entries in |network_list_| such that higher priority network types |
+ // are at the top of the list. |
+ void OrderNetworks(); |
+ |
+ // Refreshes a list of child views, updates |network_map_| and |
+ // |service_path_map_| and performs layout making sure selected view if any is |
+ // scrolled into view. |
+ void UpdateNetworkListInternal(); |
+ |
+ // Adds new or updates existing child views including header row and messages. |
+ void UpdateNetworkListEntries(std::set<std::string>* new_service_paths); |
+ |
+ // Adds or updates child views representing the network connections and |
+ // updates |child_index| if |is_wifi| matches the attribute of a network |
+ // connection. Adds the service path of each added connection to |
+ // |new_service_paths|. |
+ void UpdateNetworkChildren(bool is_wifi, |
+ std::set<std::string>* new_service_paths, |
+ int* child_index); |
+ void UpdateNetworkChild(int index, const NetworkInfo* info); |
+ |
+ // 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.
|
+ bool PlaceViewAtIndex(views::View* view, int index); |
+ |
+ // Creates a |label| with text specified by |message_id| and adds it to |
+ // |container_| if necessary or updates the text and reorders the |container_| |
+ // placing the label at |child_index| and incrementing the index. |
+ // When |message_id| is zero removes the |label| from the |container_| and |
+ // destroys it. |
+ void UpdateInfoLabel(int message_id, int* child_index, views::Label** label); |
+ |
+ // Creates a Wi-Fi header row |view| and adds it to |container_| if necessary |
+ // and reorders the |container_| placing the |view| at |child_index|. Always |
+ // increments the |*child_index|. |
+ void UpdateWifiHeaderRow(bool enabled, |
+ int* child_index, |
+ WifiHeaderRowView** view); |
+ |
+ // network_icon::AnimationObserver: |
+ void NetworkIconChanged() override; |
+ |
+ // views::ButtonListener: |
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
+ |
+ bool needs_relayout_; |
+ NetworkListDelegate* delegate_; |
+ |
+ views::Label* no_wifi_networks_view_; |
+ views::Label* no_cellular_networks_view_; |
+ WifiHeaderRowView* wifi_header_view_; |
+ |
+ // An owned list of network info. |
+ std::vector<std::unique_ptr<NetworkInfo>> network_list_; |
+ |
+ typedef std::map<views::View*, std::string> NetworkMap; |
+ NetworkMap network_map_; |
+ |
+ // A map of network service paths to their view. |
+ typedef std::map<std::string, views::View*> ServicePathMap; |
+ ServicePathMap service_path_map_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NetworkListViewMd); |
+}; |
+ |
+} // namespace ui |
+ |
+#endif // UI_CHROMEOS_NETWORK_NETWORK_LIST_MD_H_ |