| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "ash/common/system/chromeos/network/network_list_md.h" | 5 #include "ash/common/system/chromeos/network/network_list_md.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "ash/common/strings/grit/ash_strings.h" | 9 #include "ash/common/strings/grit/ash_strings.h" |
| 10 #include "ash/common/system/chromeos/network/network_icon.h" | 10 #include "ash/common/system/chromeos/network/network_icon.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 CHECK(container()); | 297 CHECK(container()); |
| 298 | 298 |
| 299 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 299 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| 300 | 300 |
| 301 NetworkStateHandler::NetworkStateList network_list; | 301 NetworkStateHandler::NetworkStateList network_list; |
| 302 handler->GetVisibleNetworkList(&network_list); | 302 handler->GetVisibleNetworkList(&network_list); |
| 303 UpdateNetworks(network_list); | 303 UpdateNetworks(network_list); |
| 304 | 304 |
| 305 NetworkStateHandler::NetworkStateList tether_network_list; | 305 NetworkStateHandler::NetworkStateList tether_network_list; |
| 306 handler->GetTetherNetworkList(0 /* no limit */, &tether_network_list); | 306 handler->GetTetherNetworkList(0 /* no limit */, &tether_network_list); |
| 307 for (const auto& tether_network : tether_network_list) { | 307 for (const auto* tether_network : tether_network_list) { |
| 308 network_list_.push_back( | 308 network_list_.push_back( |
| 309 base::MakeUnique<NetworkInfo>(tether_network->guid())); | 309 base::MakeUnique<NetworkInfo>(tether_network->guid())); |
| 310 } | 310 } |
| 311 | 311 |
| 312 UpdateNetworkIcons(); | 312 UpdateNetworkIcons(); |
| 313 OrderNetworks(); | 313 OrderNetworks(); |
| 314 UpdateNetworkListInternal(); | 314 UpdateNetworkListInternal(); |
| 315 } | 315 } |
| 316 | 316 |
| 317 bool NetworkListViewMd::IsNetworkEntry(views::View* view, | 317 bool NetworkListViewMd::IsNetworkEntry(views::View* view, |
| 318 std::string* guid) const { | 318 std::string* guid) const { |
| 319 std::map<views::View*, std::string>::const_iterator found = | 319 std::map<views::View*, std::string>::const_iterator found = |
| 320 network_map_.find(view); | 320 network_map_.find(view); |
| 321 if (found == network_map_.end()) | 321 if (found == network_map_.end()) |
| 322 return false; | 322 return false; |
| 323 *guid = found->second; | 323 *guid = found->second; |
| 324 return true; | 324 return true; |
| 325 } | 325 } |
| 326 | 326 |
| 327 void NetworkListViewMd::UpdateNetworks( | 327 void NetworkListViewMd::UpdateNetworks( |
| 328 const NetworkStateHandler::NetworkStateList& networks) { | 328 const NetworkStateHandler::NetworkStateList& networks) { |
| 329 SCOPED_NET_LOG_IF_SLOW(); | 329 SCOPED_NET_LOG_IF_SLOW(); |
| 330 network_list_.clear(); | 330 network_list_.clear(); |
| 331 const NetworkTypePattern pattern = delegate_->GetNetworkTypePattern(); | 331 const NetworkTypePattern pattern = delegate_->GetNetworkTypePattern(); |
| 332 for (const auto& network : networks) { | 332 for (const auto* network : networks) { |
| 333 if (pattern.MatchesType(network->type())) | 333 if (pattern.MatchesType(network->type())) |
| 334 network_list_.push_back(base::MakeUnique<NetworkInfo>(network->guid())); | 334 network_list_.push_back(base::MakeUnique<NetworkInfo>(network->guid())); |
| 335 } | 335 } |
| 336 } | 336 } |
| 337 | 337 |
| 338 void NetworkListViewMd::OrderNetworks() { | 338 void NetworkListViewMd::OrderNetworks() { |
| 339 struct CompareNetwork { | 339 struct CompareNetwork { |
| 340 explicit CompareNetwork(NetworkStateHandler* handler) : handler_(handler) {} | 340 explicit CompareNetwork(NetworkStateHandler* handler) : handler_(handler) {} |
| 341 | 341 |
| 342 // Returns true if |network1| is less than (i.e. is ordered before) | 342 // Returns true if |network1| is less than (i.e. is ordered before) |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 (*view)->SetEnabled(enabled); | 644 (*view)->SetEnabled(enabled); |
| 645 PlaceViewAtIndex(*view, child_index++); | 645 PlaceViewAtIndex(*view, child_index++); |
| 646 return child_index; | 646 return child_index; |
| 647 } | 647 } |
| 648 | 648 |
| 649 void NetworkListViewMd::NetworkIconChanged() { | 649 void NetworkListViewMd::NetworkIconChanged() { |
| 650 Update(); | 650 Update(); |
| 651 } | 651 } |
| 652 | 652 |
| 653 } // namespace ash | 653 } // namespace ash |
| OLD | NEW |