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

Side by Side Diff: ash/common/system/chromeos/network/vpn_list_view.cc

Issue 2510083006: chromeos: Move ownership of ash VPN provider list from chrome into ash (Closed)
Patch Set: rebase Created 4 years 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/vpn_list_view.h" 5 #include "ash/common/system/chromeos/network/vpn_list_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 const std::string& name, 443 const std::string& name,
444 const chromeos::NetworkStateHandler::NetworkStateList& networks) { 444 const chromeos::NetworkStateHandler::NetworkStateList& networks) {
445 // Add a visual separator, unless this is the topmost entry in the list. 445 // Add a visual separator, unless this is the topmost entry in the list.
446 if (!list_empty_) { 446 if (!list_empty_) {
447 views::Separator* const separator = 447 views::Separator* const separator =
448 new views::Separator(views::Separator::HORIZONTAL); 448 new views::Separator(views::Separator::HORIZONTAL);
449 separator->SetColor(kBorderLightColor); 449 separator->SetColor(kBorderLightColor);
450 container()->AddChildView(separator); 450 container()->AddChildView(separator);
451 } else { 451 } else {
452 list_empty_ = false; 452 list_empty_ = false;
453 } 453 }
stevenjb 2016/11/21 20:23:18 std::string vpn_name = key.third_party ? name : l1
James Cook 2016/11/21 23:58:38 Done. (I just passed in the whole provider.)
454 // Add a list entry for the VPN provider. 454 // Add a list entry for the VPN provider.
455 views::View* provider = nullptr; 455 views::View* provider = nullptr;
456 if (UseMd()) { 456 if (UseMd()) {
457 provider = new VPNListProviderEntryMd(this, name, 457 provider = new VPNListProviderEntryMd(this, name,
458 IDS_ASH_STATUS_TRAY_ADD_CONNECTION); 458 IDS_ASH_STATUS_TRAY_ADD_CONNECTION);
459 } else { 459 } else {
460 provider = new VPNListProviderEntry(this, name); 460 provider = new VPNListProviderEntry(this, name);
461 } 461 }
462 container()->AddChildView(provider); 462 container()->AddChildView(provider);
463 provider_view_key_map_[provider] = key; 463 provider_view_key_map_[provider] = key;
464 // Add the networks belonging to this provider, in the priority order returned 464 // Add the networks belonging to this provider, in the priority order returned
465 // by shill. 465 // by shill.
466 for (const chromeos::NetworkState* const& network : networks) { 466 for (const chromeos::NetworkState* const& network : networks) {
467 if (key.MatchesNetwork(*network)) 467 if (key.MatchesNetwork(*network))
468 AddNetwork(network); 468 AddNetwork(network);
469 } 469 }
470 } 470 }
471 471
472 void VPNListView::AddProvidersAndNetworks( 472 void VPNListView::AddProvidersAndNetworks(
473 const chromeos::NetworkStateHandler::NetworkStateList& networks) { 473 const chromeos::NetworkStateHandler::NetworkStateList& networks) {
474 // Get the list of VPN providers enabled in the primary user's profile. 474 // Get the list of VPN providers enabled in the primary user's profile.
475 std::vector<VPNProvider> providers = WmShell::Get() 475 std::vector<VPNProvider> providers =
476 ->system_tray_delegate() 476 WmShell::Get()->system_tray_delegate()->GetVPNDelegate()->vpn_providers();
477 ->GetVPNDelegate()
478 ->GetVPNProviders();
479 477
480 // Add providers with at least one configured network along with their 478 // Add providers with at least one configured network along with their
481 // networks. Providers are added in the order of their highest priority 479 // networks. Providers are added in the order of their highest priority
482 // network. 480 // network.
483 for (const chromeos::NetworkState* const& network : networks) { 481 for (const chromeos::NetworkState* const& network : networks) {
484 for (auto provider = providers.begin(); provider != providers.end(); 482 for (auto provider = providers.begin(); provider != providers.end();
485 ++provider) { 483 ++provider) {
486 if (!provider->key.MatchesNetwork(*network)) 484 if (!provider->key.MatchesNetwork(*network))
487 continue; 485 continue;
488 AddProviderAndNetworks(provider->key, provider->name, networks); 486 AddProviderAndNetworks(provider->key, provider->name, networks);
489 providers.erase(provider); 487 providers.erase(provider);
490 break; 488 break;
491 } 489 }
492 } 490 }
493 491
494 // Add providers without any configured networks, in the order that the 492 // Add providers without any configured networks, in the order that the
495 // providers were returned by the extensions system. 493 // providers were returned by the extensions system.
496 for (const VPNProvider& provider : providers) 494 for (const VPNProvider& provider : providers)
497 AddProviderAndNetworks(provider.key, provider.name, networks); 495 AddProviderAndNetworks(provider.key, provider.name, networks);
498 } 496 }
499 497
500 } // namespace ash 498 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698