Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Side by Side Diff: ash/system/network/network_list.cc

Issue 2961153003: [CrOS Tether] NetworkList: Remove code which erroneously added Tether networks twice. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/system/network/network_list.h" 5 #include "ash/system/network/network_list.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/metrics/user_metrics_recorder.h" 10 #include "ash/metrics/user_metrics_recorder.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 } 311 }
312 312
313 void NetworkListView::UpdateNetworkList() { 313 void NetworkListView::UpdateNetworkList() {
314 CHECK(scroll_content()); 314 CHECK(scroll_content());
315 315
316 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 316 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
317 317
318 NetworkStateHandler::NetworkStateList network_list; 318 NetworkStateHandler::NetworkStateList network_list;
319 handler->GetVisibleNetworkList(&network_list); 319 handler->GetVisibleNetworkList(&network_list);
320 UpdateNetworks(network_list); 320 UpdateNetworks(network_list);
321
322 // Add Tether networks.
323 NetworkStateHandler::NetworkStateList tether_network_list;
324 handler->GetVisibleNetworkListByType(NetworkTypePattern::Tether(),
325 &tether_network_list);
326 for (const auto* tether_network : tether_network_list) {
327 network_list_.push_back(
328 base::MakeUnique<NetworkInfo>(tether_network->guid()));
329 }
330
331 UpdateNetworkIcons(); 321 UpdateNetworkIcons();
332 UpdateNetworkListInternal(); 322 UpdateNetworkListInternal();
333 } 323 }
334 324
335 bool NetworkListView::IsNetworkEntry(views::View* view, 325 bool NetworkListView::IsNetworkEntry(views::View* view,
336 std::string* guid) const { 326 std::string* guid) const {
337 std::map<views::View*, std::string>::const_iterator found = 327 std::map<views::View*, std::string>::const_iterator found =
338 network_map_.find(view); 328 network_map_.find(view);
339 if (found == network_map_.end()) 329 if (found == network_map_.end())
340 return false; 330 return false;
341 *guid = found->second; 331 *guid = found->second;
342 return true; 332 return true;
343 } 333 }
344 334
345 void NetworkListView::UpdateNetworks( 335 void NetworkListView::UpdateNetworks(
346 const NetworkStateHandler::NetworkStateList& networks) { 336 const NetworkStateHandler::NetworkStateList& networks) {
347 SCOPED_NET_LOG_IF_SLOW(); 337 SCOPED_NET_LOG_IF_SLOW();
348 // |network_list_| contains all the info and is going to be cleared and 338 // |network_list_| contains all the info and is going to be cleared and
349 // recreated. Save them to |last_network_info_map_|. 339 // recreated. Save them to |last_network_info_map_|.
350 last_network_info_map_.clear(); 340 last_network_info_map_.clear();
351 for (auto& info : network_list_) 341 for (auto& info : network_list_)
352 last_network_info_map_[info->guid] = std::move(info); 342 last_network_info_map_[info->guid] = std::move(info);
353 343
354 network_list_.clear(); 344 network_list_.clear();
355 for (const auto* network : networks) { 345 for (const auto* network : networks) {
356 if (!NetworkTypePattern::NonVirtual().MatchesType(network->type())) 346 if (!NetworkTypePattern::NonVirtual().MatchesType(network->type()))
357 continue; 347 continue;
358
359 // Do not add Wi-Fi networks that are associated with a Tether network.
360 if (NetworkTypePattern::WiFi().MatchesType(network->type()) &&
361 !network->tether_guid().empty())
362 continue;
363
364 network_list_.push_back(base::MakeUnique<NetworkInfo>(network->guid())); 348 network_list_.push_back(base::MakeUnique<NetworkInfo>(network->guid()));
365 } 349 }
366 } 350 }
367 351
368 void NetworkListView::UpdateNetworkIcons() { 352 void NetworkListView::UpdateNetworkIcons() {
369 SCOPED_NET_LOG_IF_SLOW(); 353 SCOPED_NET_LOG_IF_SLOW();
370 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 354 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
371 355
372 // First, update state for all networks. 356 // First, update state for all networks.
373 bool animating = false; 357 bool animating = false;
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 TriView::Container::CENTER, views::CreateEmptyBorder(gfx::Insets( 717 TriView::Container::CENTER, views::CreateEmptyBorder(gfx::Insets(
734 0, 0, 0, kTrayPopupLabelRightPadding))); 718 0, 0, 0, kTrayPopupLabelRightPadding)));
735 719
736 // Nothing to the right of the text. 720 // Nothing to the right of the text.
737 connection_warning->SetContainerVisible(TriView::Container::END, false); 721 connection_warning->SetContainerVisible(TriView::Container::END, false);
738 return connection_warning; 722 return connection_warning;
739 } 723 }
740 724
741 } // namespace tray 725 } // namespace tray
742 } // namespace ash 726 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698