1 // Copyright (c) 2012 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_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_LIST_DETAILED_VIEW_H 6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_LIST_DETAILED_VIEW_H 7 8 #include <map> 9 #include <string> 10 #include <vector> 11 12 #include "ash/system/chromeos/network/network_detailed_view.h" 13 #include "ash/system/chromeos/network/network_icon.h" 14 #include "ash/system/chromeos/network/network_icon_animation_observer.h" 15 #include "ash/system/tray/view_click_listener.h" 16 #include "ash/system/user/login_status.h" 17 #include "base/memory/scoped_vector.h" 18 #include "base/memory/weak_ptr.h" 19 #include "ui/views/controls/button/button.h" 20 21 namespace views { 22 class BubbleDelegateView; 23 } 24 25 namespace ash { 26 27 class SystemTrayItem; 28 29 namespace internal { 30 31 class HoverHighlightView; 32 class TrayPopupLabelButton; 33 34 namespace tray { 35 36 struct NetworkInfo; 37 38 class NetworkStateListDetailedView 39 : public NetworkDetailedView, 40 public views::ButtonListener, 41 public ViewClickListener, 42 public network_icon::AnimationObserver, 43 public base::SupportsWeakPtr<NetworkStateListDetailedView> { 44 public: 45 enum ListType { 46 LIST_TYPE_NETWORK, 47 LIST_TYPE_DEBUG_PREFERRED, 48 LIST_TYPE_VPN 49 }; 50 51 NetworkStateListDetailedView(SystemTrayItem* owner, 52 ListType list_type, 53 user::LoginStatus login); 54 virtual ~NetworkStateListDetailedView(); 55 56 // Overridden from NetworkDetailedView: 57 virtual void Init() OVERRIDE; 58 virtual DetailedViewType GetViewType() const OVERRIDE; 59 virtual void ManagerChanged() OVERRIDE; 60 virtual void NetworkListChanged() OVERRIDE; 61 virtual void NetworkServiceChanged( 62 const chromeos::NetworkState* network) OVERRIDE; 63 64 // network_icon::AnimationObserver overrides 65 virtual void NetworkIconChanged() OVERRIDE; 66 67 protected: 68 // Overridden from ButtonListener. 69 virtual void ButtonPressed(views::Button* sender, 70 const ui::Event& event) OVERRIDE; 71 72 // Overridden from ViewClickListener. 73 virtual void OnViewClicked(views::View* sender) OVERRIDE; 74 75 private: 76 typedef std::map<views::View*, std::string> NetworkMap; 77 typedef std::map<std::string, HoverHighlightView*> ServicePathMap; 78 79 // Create UI components. 80 void CreateHeaderEntry(); 81 void CreateHeaderButtons(); 82 void CreateNetworkExtra(); 83 84 // Update UI components. 85 void UpdateHeaderButtons(); 86 void UpdateTechnologyButton(TrayPopupHeaderButton* button, 87 const std::string& technology); 88 89 void UpdateNetworks( 90 const chromeos::NetworkStateHandler::NetworkStateList& networks); 91 void UpdatePreferred( 92 const chromeos::NetworkStateHandler::FavoriteStateList& favorites); 93 void UpdateNetworkList(); 94 bool CreateOrUpdateInfoLabel( 95 int index, const base::string16& text, views::Label** label); 96 bool UpdateNetworkChild(int index, const NetworkInfo* info); 97 bool OrderChild(views::View* view, int index); 98 bool UpdateNetworkListEntries(std::set<std::string>* new_service_paths); 99 void UpdateNetworkExtra(); 100 101 // Adds a settings entry when logged in, and an entry for changing proxy 102 // settings otherwise. 103 void CreateSettingsEntry(); 104 105 // Create and manage the network info bubble. 106 void ToggleInfoBubble(); 107 bool ResetInfoBubble(); 108 views::View* CreateNetworkInfoView(); 109 110 // Periodically request a network scan. 111 void CallRequestScan(); 112 113 // Handle toggile mobile action 114 void ToggleMobile(); 115 116 // Type of list (all networks or vpn) 117 ListType list_type_; 118 119 // Track login state. 120 user::LoginStatus login_; 121 122 // A map of child views to their network service path. 123 NetworkMap network_map_; 124 125 // A map of network service paths to their view. 126 ServicePathMap service_path_map_; 127 128 // An owned list of network info. 129 ScopedVector<NetworkInfo> network_list_; 130 131 // Child views. 132 TrayPopupHeaderButton* info_icon_; 133 TrayPopupHeaderButton* button_wifi_; 134 TrayPopupHeaderButton* button_mobile_; 135 TrayPopupLabelButton* other_wifi_; 136 TrayPopupLabelButton* turn_on_wifi_; 137 TrayPopupLabelButton* other_mobile_; 138 TrayPopupLabelButton* other_vpn_; 139 TrayPopupLabelButton* toggle_debug_preferred_networks_; 140 TrayPopupLabelButton* settings_; 141 TrayPopupLabelButton* proxy_settings_; 142 views::Label* scanning_view_; 143 views::Label* no_wifi_networks_view_; 144 views::Label* no_cellular_networks_view_; 145 146 // A small bubble for displaying network info. 147 views::BubbleDelegateView* info_bubble_; 148 149 DISALLOW_COPY_AND_ASSIGN(NetworkStateListDetailedView); 150 }; 151 152 } // namespace tray 153 } // namespace internal 154 } // namespace ash 155 156 #endif // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_LIST_DETAILED_VIEW 157