| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/chromeos/network/network_list.h" | 5 #include "ui/chromeos/network/network_list.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 bool prohibited_by_policy = IsProhibitedByPolicy(network); | 125 bool prohibited_by_policy = IsProhibitedByPolicy(network); |
| 126 info->image = | 126 info->image = |
| 127 network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST); | 127 network_icon::GetImageForNetwork(network, network_icon::ICON_TYPE_LIST); |
| 128 info->label = | 128 info->label = |
| 129 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST); | 129 network_icon::GetLabelForNetwork(network, network_icon::ICON_TYPE_LIST); |
| 130 info->highlight = | 130 info->highlight = |
| 131 network->IsConnectedState() || network->IsConnectingState(); | 131 network->IsConnectedState() || network->IsConnectingState(); |
| 132 info->disable = | 132 info->disable = |
| 133 (network->activation_state() == shill::kActivationStateActivating) || | 133 (network->activation_state() == shill::kActivationStateActivating) || |
| 134 prohibited_by_policy; | 134 prohibited_by_policy; |
| 135 info->is_wifi = network->Matches(NetworkTypePattern::WiFi()); |
| 135 if (prohibited_by_policy) { | 136 if (prohibited_by_policy) { |
| 136 info->tooltip = | 137 info->tooltip = |
| 137 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED); | 138 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_PROHIBITED); |
| 138 } | 139 } |
| 139 if (!animating && network->IsConnectingState()) | 140 if (!animating && network->IsConnectingState()) |
| 140 animating = true; | 141 animating = true; |
| 141 } | 142 } |
| 142 if (animating) | 143 if (animating) |
| 143 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); | 144 network_icon::NetworkIconAnimation::GetInstance()->AddObserver(this); |
| 144 else | 145 else |
| 145 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); | 146 network_icon::NetworkIconAnimation::GetInstance()->RemoveObserver(this); |
| 146 } | 147 } |
| 147 | 148 |
| 148 void NetworkListView::UpdateNetworkListInternal() { | 149 void NetworkListView::UpdateNetworkListInternal() { |
| 149 SCOPED_NET_LOG_IF_SLOW(); | 150 SCOPED_NET_LOG_IF_SLOW(); |
| 150 // Get the updated list entries | 151 // Get the updated list entries |
| 151 network_map_.clear(); | 152 network_map_.clear(); |
| 152 std::set<std::string> new_service_paths; | 153 std::set<std::string> new_service_paths; |
| 153 bool needs_relayout = UpdateNetworkListEntries(&new_service_paths); | 154 bool needs_relayout = UpdateNetworkListEntries(&new_service_paths); |
| 154 | 155 |
| 155 // Remove old children | 156 // Remove old children |
| 156 std::set<std::string> remove_service_paths; | 157 std::set<std::string> remove_service_paths; |
| 157 for (ServicePathMap::const_iterator it = service_path_map_.begin(); | 158 for (ServicePathMap::const_iterator it = service_path_map_.begin(); |
| 158 it != service_path_map_.end(); | 159 it != service_path_map_.end(); |
| 159 ++it) { | 160 ++it) { |
| 160 if (new_service_paths.find(it->first) == new_service_paths.end()) { | 161 if (new_service_paths.find(it->first) == new_service_paths.end()) { |
| 161 remove_service_paths.insert(it->first); | 162 remove_service_paths.insert(it->first); |
| 162 network_map_.erase(it->second); | 163 network_map_.erase(it->second); |
| 163 container_->RemoveChildView(it->second); | 164 delete it->second; |
| 164 needs_relayout = true; | 165 needs_relayout = true; |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 | 168 |
| 168 for (std::set<std::string>::const_iterator remove_it = | 169 for (std::set<std::string>::const_iterator remove_it = |
| 169 remove_service_paths.begin(); | 170 remove_service_paths.begin(); |
| 170 remove_it != remove_service_paths.end(); | 171 remove_it != remove_service_paths.end(); |
| 171 ++remove_it) { | 172 ++remove_it) { |
| 172 service_path_map_.erase(*remove_it); | 173 service_path_map_.erase(*remove_it); |
| 173 } | 174 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 if (!*label) { | 304 if (!*label) { |
| 304 *label = delegate_->CreateInfoLabel(); | 305 *label = delegate_->CreateInfoLabel(); |
| 305 (*label)->SetText(text); | 306 (*label)->SetText(text); |
| 306 container_->AddChildViewAt(*label, index); | 307 container_->AddChildViewAt(*label, index); |
| 307 needs_relayout = true; | 308 needs_relayout = true; |
| 308 } else { | 309 } else { |
| 309 (*label)->SetText(text); | 310 (*label)->SetText(text); |
| 310 needs_relayout = PlaceViewAtIndex(*label, index); | 311 needs_relayout = PlaceViewAtIndex(*label, index); |
| 311 } | 312 } |
| 312 } else if (*label) { | 313 } else if (*label) { |
| 313 container_->RemoveChildView(*label); | |
| 314 delete *label; | 314 delete *label; |
| 315 *label = NULL; | 315 *label = NULL; |
| 316 needs_relayout = true; | 316 needs_relayout = true; |
| 317 } | 317 } |
| 318 return needs_relayout; | 318 return needs_relayout; |
| 319 } | 319 } |
| 320 | 320 |
| 321 void NetworkListView::NetworkIconChanged() { | 321 void NetworkListView::NetworkIconChanged() { |
| 322 Update(); | 322 Update(); |
| 323 } | 323 } |
| 324 | 324 |
| 325 } // namespace ui | 325 } // namespace ui |
| OLD | NEW |