OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chromeos/dbus/fake_shill_manager_client.h" | 5 #include "chromeos/dbus/fake_shill_manager_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 FROM_HERE, base::Bind( | 137 FROM_HERE, base::Bind( |
138 &FakeShillManagerClient::PassStubGeoNetworks, | 138 &FakeShillManagerClient::PassStubGeoNetworks, |
139 weak_ptr_factory_.GetWeakPtr(), | 139 weak_ptr_factory_.GetWeakPtr(), |
140 callback)); | 140 callback)); |
141 } | 141 } |
142 | 142 |
143 void FakeShillManagerClient::SetProperty(const std::string& name, | 143 void FakeShillManagerClient::SetProperty(const std::string& name, |
144 const base::Value& value, | 144 const base::Value& value, |
145 const base::Closure& callback, | 145 const base::Closure& callback, |
146 const ErrorCallback& error_callback) { | 146 const ErrorCallback& error_callback) { |
147 VLOG(2) << "SetProperty: " << name; | |
147 stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy()); | 148 stub_properties_.SetWithoutPathExpansion(name, value.DeepCopy()); |
148 CallNotifyObserversPropertyChanged(name); | 149 CallNotifyObserversPropertyChanged(name); |
149 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 150 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
150 } | 151 } |
151 | 152 |
152 void FakeShillManagerClient::RequestScan(const std::string& type, | 153 void FakeShillManagerClient::RequestScan(const std::string& type, |
153 const base::Closure& callback, | 154 const base::Closure& callback, |
154 const ErrorCallback& error_callback) { | 155 const ErrorCallback& error_callback) { |
155 // For Stub purposes, default to a Wifi scan. | 156 // For Stub purposes, default to a Wifi scan. |
156 std::string device_type = shill::kTypeWifi; | 157 std::string device_type = shill::kTypeWifi; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 | 440 |
440 void FakeShillManagerClient::SetManagerProperty(const std::string& key, | 441 void FakeShillManagerClient::SetManagerProperty(const std::string& key, |
441 const base::Value& value) { | 442 const base::Value& value) { |
442 SetProperty(key, value, | 443 SetProperty(key, value, |
443 base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback)); | 444 base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback)); |
444 } | 445 } |
445 | 446 |
446 void FakeShillManagerClient::AddManagerService(const std::string& service_path, | 447 void FakeShillManagerClient::AddManagerService(const std::string& service_path, |
447 bool add_to_visible_list, | 448 bool add_to_visible_list, |
448 bool add_to_watch_list) { | 449 bool add_to_watch_list) { |
450 VLOG(2) << "AddManagerService: " << service_path | |
451 << " Visible: " << add_to_visible_list; | |
449 // Always add to ServiceCompleteListProperty. | 452 // Always add to ServiceCompleteListProperty. |
450 GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent( | 453 GetListProperty(shill::kServiceCompleteListProperty)->AppendIfNotPresent( |
451 base::Value::CreateStringValue(service_path)); | 454 base::Value::CreateStringValue(service_path)); |
452 // If visible, add to Services and notify if new. | 455 // If visible, add to Services and notify if new. |
453 if (add_to_visible_list && | 456 if (add_to_visible_list && |
454 GetListProperty(shill::kServicesProperty)->AppendIfNotPresent( | 457 GetListProperty(shill::kServicesProperty)->AppendIfNotPresent( |
455 base::Value::CreateStringValue(service_path))) { | 458 base::Value::CreateStringValue(service_path))) { |
456 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 459 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
457 } | 460 } |
458 if (add_to_watch_list) | 461 if (add_to_watch_list) |
459 AddServiceToWatchList(service_path); | 462 AddServiceToWatchList(service_path); |
460 } | 463 } |
461 | 464 |
462 void FakeShillManagerClient::RemoveManagerService( | 465 void FakeShillManagerClient::RemoveManagerService( |
463 const std::string& service_path, | 466 const std::string& service_path, |
464 bool remove_from_complete_list) { | 467 bool remove_from_complete_list) { |
468 VLOG(2) << "RemoveManagerService: " << service_path; | |
465 base::StringValue service_path_value(service_path); | 469 base::StringValue service_path_value(service_path); |
466 if (remove_from_complete_list) { | 470 if (remove_from_complete_list) { |
467 GetListProperty(shill::kServiceCompleteListProperty)->Remove( | 471 GetListProperty(shill::kServiceCompleteListProperty)->Remove( |
468 service_path_value, NULL); | 472 service_path_value, NULL); |
469 } | 473 } |
470 if (GetListProperty(shill::kServicesProperty)->Remove( | 474 if (GetListProperty(shill::kServicesProperty)->Remove( |
471 service_path_value, NULL)) { | 475 service_path_value, NULL)) { |
472 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 476 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
473 } | 477 } |
474 if (GetListProperty(shill::kServiceWatchListProperty)->Remove( | 478 if (GetListProperty(shill::kServiceWatchListProperty)->Remove( |
475 service_path_value, NULL)) { | 479 service_path_value, NULL)) { |
476 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); | 480 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
477 } | 481 } |
478 } | 482 } |
479 | 483 |
480 void FakeShillManagerClient::ClearManagerServices() { | 484 void FakeShillManagerClient::ClearManagerServices() { |
485 VLOG(1) << "ClearManagerServices"; | |
481 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); | 486 GetListProperty(shill::kServiceCompleteListProperty)->Clear(); |
482 GetListProperty(shill::kServicesProperty)->Clear(); | 487 GetListProperty(shill::kServicesProperty)->Clear(); |
483 GetListProperty(shill::kServiceWatchListProperty)->Clear(); | 488 GetListProperty(shill::kServiceWatchListProperty)->Clear(); |
484 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 489 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
485 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); | 490 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
486 } | 491 } |
487 | 492 |
488 void FakeShillManagerClient::ServiceStateChanged( | 493 void FakeShillManagerClient::ServiceStateChanged( |
489 const std::string& service_path, | 494 const std::string& service_path, |
490 const std::string& state) { | 495 const std::string& state) { |
491 if (service_path == default_service_ && !IsConnectedState(state)) { | 496 if (service_path == default_service_ && !IsConnectedState(state)) { |
492 // Default service is no longer connected; clear. | 497 // Default service is no longer connected; clear. |
493 default_service_.clear(); | 498 default_service_.clear(); |
494 base::StringValue default_service_value(default_service_); | 499 base::StringValue default_service_value(default_service_); |
495 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); | 500 SetManagerProperty(shill::kDefaultServiceProperty, default_service_value); |
496 } | 501 } |
497 } | 502 } |
498 | 503 |
499 void FakeShillManagerClient::SortManagerServices() { | 504 void FakeShillManagerClient::SortManagerServices() { |
505 VLOG(1) << "SortManagerServices"; | |
500 SortServiceList(shill::kServicesProperty); | 506 SortServiceList(shill::kServicesProperty); |
501 SortServiceList(shill::kServiceCompleteListProperty); | 507 SortServiceList(shill::kServiceCompleteListProperty); |
502 } | 508 } |
503 | 509 |
504 void FakeShillManagerClient::SortServiceList(const std::string& property) { | 510 void FakeShillManagerClient::SortServiceList(const std::string& property) { |
505 static const char* ordered_types[] = { | 511 static const char* ordered_types[] = { |
506 shill::kTypeEthernet, | 512 shill::kTypeEthernet, |
507 shill::kTypeWifi, | 513 shill::kTypeWifi, |
508 shill::kTypeCellular, | 514 shill::kTypeCellular, |
509 shill::kTypeWimax, | 515 shill::kTypeWimax, |
(...skipping 11 matching lines...) Expand all Loading... | |
521 service_list->Clear(); | 527 service_list->Clear(); |
522 for (size_t i = 0; i < active_services.size(); ++i) | 528 for (size_t i = 0; i < active_services.size(); ++i) |
523 service_list->AppendString(active_services[i]); | 529 service_list->AppendString(active_services[i]); |
524 for (size_t i = 0; i < inactive_services.size(); ++i) | 530 for (size_t i = 0; i < inactive_services.size(); ++i) |
525 service_list->AppendString(inactive_services[i]); | 531 service_list->AppendString(inactive_services[i]); |
526 } | 532 } |
527 | 533 |
528 if (property != shill::kServicesProperty) | 534 if (property != shill::kServicesProperty) |
529 return; | 535 return; |
530 | 536 |
531 CallNotifyObserversPropertyChanged(property); | |
stevenjb
2014/05/28 22:47:22
This is redundant and was triggering extra/unneces
stevenjb
2014/05/29 22:18:00
Actually, this is not redundant when SetviceList a
| |
532 | |
533 // Set the first active service as the Default service. | 537 // Set the first active service as the Default service. |
534 std::string new_default_service; | 538 std::string new_default_service; |
535 if (!active_services.empty()) { | 539 if (!active_services.empty()) { |
536 ShillServiceClient::TestInterface* service_client = | 540 ShillServiceClient::TestInterface* service_client = |
537 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 541 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
538 std::string service_path = active_services[0]; | 542 std::string service_path = active_services[0]; |
539 const base::DictionaryValue* properties = | 543 const base::DictionaryValue* properties = |
540 service_client->GetServiceProperties(service_path); | 544 service_client->GetServiceProperties(service_path); |
541 if (!properties) { | 545 if (!properties) { |
542 LOG(ERROR) << "Properties not found for service: " << service_path; | 546 LOG(ERROR) << "Properties not found for service: " << service_path; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
613 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); | 617 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); |
614 devices->SetDeviceProperty("/device/eth1", | 618 devices->SetDeviceProperty("/device/eth1", |
615 shill::kAddressProperty, | 619 shill::kAddressProperty, |
616 base::StringValue("0123456789ab")); | 620 base::StringValue("0123456789ab")); |
617 base::ListValue eth_ip_configs; | 621 base::ListValue eth_ip_configs; |
618 eth_ip_configs.AppendString("ipconfig_v4_path"); | 622 eth_ip_configs.AppendString("ipconfig_v4_path"); |
619 eth_ip_configs.AppendString("ipconfig_v6_path"); | 623 eth_ip_configs.AppendString("ipconfig_v6_path"); |
620 devices->SetDeviceProperty("/device/eth1", | 624 devices->SetDeviceProperty("/device/eth1", |
621 shill::kIPConfigsProperty, | 625 shill::kIPConfigsProperty, |
622 eth_ip_configs); | 626 eth_ip_configs); |
623 services->AddService("eth1", "eth1", | 627 services->AddService("/service/eth1", "eth1", |
624 shill::kTypeEthernet, | 628 shill::kTypeEthernet, |
625 state, | 629 state, |
626 add_to_visible, add_to_watchlist); | 630 add_to_visible, add_to_watchlist); |
627 profiles->AddService(shared_profile, "eth1"); | 631 profiles->AddService(shared_profile, "/service/eth1"); |
628 } | 632 } |
629 | 633 |
630 // Wifi | 634 // Wifi |
631 state = GetInitialStateForType(shill::kTypeWifi, &enabled); | 635 state = GetInitialStateForType(shill::kTypeWifi, &enabled); |
632 if (state != kTechnologyUnavailable) { | 636 if (state != kTechnologyUnavailable) { |
633 bool portaled = false; | 637 bool portaled = false; |
634 if (state == shill::kStatePortal) { | 638 if (state == shill::kStatePortal) { |
635 portaled = true; | 639 portaled = true; |
636 state = shill::kStateIdle; | 640 state = shill::kStateIdle; |
637 } | 641 } |
638 AddTechnology(shill::kTypeWifi, enabled); | 642 AddTechnology(shill::kTypeWifi, enabled); |
639 devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); | 643 devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); |
640 devices->SetDeviceProperty("/device/wifi1", | 644 devices->SetDeviceProperty("/device/wifi1", |
641 shill::kAddressProperty, | 645 shill::kAddressProperty, |
642 base::StringValue("23456789abc")); | 646 base::StringValue("23456789abc")); |
643 base::ListValue wifi_ip_configs; | 647 base::ListValue wifi_ip_configs; |
644 wifi_ip_configs.AppendString("ipconfig_v4_path"); | 648 wifi_ip_configs.AppendString("ipconfig_v4_path"); |
645 wifi_ip_configs.AppendString("ipconfig_v6_path"); | 649 wifi_ip_configs.AppendString("ipconfig_v6_path"); |
646 devices->SetDeviceProperty("/device/wifi1", | 650 devices->SetDeviceProperty("/device/wifi1", |
647 shill::kIPConfigsProperty, | 651 shill::kIPConfigsProperty, |
648 wifi_ip_configs); | 652 wifi_ip_configs); |
649 | 653 |
650 services->AddService("wifi1", | 654 services->AddService("/service/wifi1", |
651 "wifi1", | 655 "wifi1", |
652 shill::kTypeWifi, | 656 shill::kTypeWifi, |
653 state, | 657 state, |
654 add_to_visible, add_to_watchlist); | 658 add_to_visible, add_to_watchlist); |
655 services->SetServiceProperty("wifi1", | 659 services->SetServiceProperty("/service/wifi1", |
656 shill::kSecurityProperty, | 660 shill::kSecurityProperty, |
657 base::StringValue(shill::kSecurityWep)); | 661 base::StringValue(shill::kSecurityWep)); |
658 profiles->AddService(shared_profile, "wifi1"); | 662 profiles->AddService(shared_profile, "/service/wifi1"); |
659 | 663 |
660 services->AddService("wifi2", | 664 services->AddService("/service/wifi2", |
661 "wifi2_PSK", | 665 "wifi2_PSK", |
662 shill::kTypeWifi, | 666 shill::kTypeWifi, |
663 shill::kStateIdle, | 667 shill::kStateIdle, |
664 add_to_visible, add_to_watchlist); | 668 add_to_visible, add_to_watchlist); |
665 services->SetServiceProperty("wifi2", | 669 services->SetServiceProperty("/service/wifi2", |
666 shill::kSecurityProperty, | 670 shill::kSecurityProperty, |
667 base::StringValue(shill::kSecurityPsk)); | 671 base::StringValue(shill::kSecurityPsk)); |
668 | 672 |
669 base::FundamentalValue strength_value(80); | 673 base::FundamentalValue strength_value(80); |
670 services->SetServiceProperty( | 674 services->SetServiceProperty( |
671 "wifi2", shill::kSignalStrengthProperty, strength_value); | 675 "/service/wifi2", shill::kSignalStrengthProperty, strength_value); |
672 profiles->AddService(shared_profile, "wifi2"); | 676 profiles->AddService(shared_profile, "/service/wifi2"); |
673 | 677 |
674 if (portaled) { | 678 if (portaled) { |
675 const std::string kPortaledWifiPath = "portaled_wifi"; | 679 const std::string kPortaledWifiPath = "/service/portaled_wifi"; |
676 services->AddService(kPortaledWifiPath, | 680 services->AddService(kPortaledWifiPath, |
677 "Portaled Wifi", | 681 "Portaled Wifi", |
678 shill::kTypeWifi, | 682 shill::kTypeWifi, |
679 shill::kStatePortal, | 683 shill::kStatePortal, |
680 add_to_visible, add_to_watchlist); | 684 add_to_visible, add_to_watchlist); |
681 services->SetServiceProperty(kPortaledWifiPath, | 685 services->SetServiceProperty(kPortaledWifiPath, |
682 shill::kSecurityProperty, | 686 shill::kSecurityProperty, |
683 base::StringValue(shill::kSecurityNone)); | 687 base::StringValue(shill::kSecurityNone)); |
684 services->SetConnectBehavior(kPortaledWifiPath, | 688 services->SetConnectBehavior(kPortaledWifiPath, |
685 base::Bind(&UpdatePortaledWifiState, | 689 base::Bind(&UpdatePortaledWifiState, |
686 "portaled_wifi")); | 690 "portaled_wifi")); |
687 services->SetServiceProperty(kPortaledWifiPath, | 691 services->SetServiceProperty(kPortaledWifiPath, |
688 shill::kConnectableProperty, | 692 shill::kConnectableProperty, |
689 base::FundamentalValue(true)); | 693 base::FundamentalValue(true)); |
690 profiles->AddService(shared_profile, kPortaledWifiPath); | 694 profiles->AddService(shared_profile, kPortaledWifiPath); |
691 } | 695 } |
692 } | 696 } |
693 | 697 |
694 // Wimax | 698 // Wimax |
695 state = GetInitialStateForType(shill::kTypeWimax, &enabled); | 699 state = GetInitialStateForType(shill::kTypeWimax, &enabled); |
696 if (state != kTechnologyUnavailable) { | 700 if (state != kTechnologyUnavailable) { |
697 AddTechnology(shill::kTypeWimax, enabled); | 701 AddTechnology(shill::kTypeWimax, enabled); |
698 devices->AddDevice( | 702 devices->AddDevice( |
699 "/device/wimax1", shill::kTypeWimax, "stub_wimax_device1"); | 703 "/device/wimax1", shill::kTypeWimax, "stub_wimax_device1"); |
700 | 704 |
701 services->AddService("wimax1", | 705 services->AddService("/service/wimax1", |
702 "wimax1", | 706 "wimax1", |
703 shill::kTypeWimax, | 707 shill::kTypeWimax, |
704 state, | 708 state, |
705 add_to_visible, add_to_watchlist); | 709 add_to_visible, add_to_watchlist); |
706 services->SetServiceProperty( | 710 services->SetServiceProperty("/service/wimax1", |
707 "wimax1", shill::kConnectableProperty, base::FundamentalValue(true)); | 711 shill::kConnectableProperty, |
712 base::FundamentalValue(true)); | |
708 } | 713 } |
709 | 714 |
710 // Cellular | 715 // Cellular |
711 state = GetInitialStateForType(shill::kTypeCellular, &enabled); | 716 state = GetInitialStateForType(shill::kTypeCellular, &enabled); |
712 if (state != kTechnologyUnavailable) { | 717 if (state != kTechnologyUnavailable) { |
713 bool activated = false; | 718 bool activated = false; |
714 if (state == kNetworkActivated) { | 719 if (state == kNetworkActivated) { |
715 activated = true; | 720 activated = true; |
716 state = shill::kStateIdle; | 721 state = shill::kStateIdle; |
717 } | 722 } |
718 AddTechnology(shill::kTypeCellular, enabled); | 723 AddTechnology(shill::kTypeCellular, enabled); |
719 devices->AddDevice( | 724 devices->AddDevice( |
720 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); | 725 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); |
721 devices->SetDeviceProperty("/device/cellular1", | 726 devices->SetDeviceProperty("/device/cellular1", |
722 shill::kCarrierProperty, | 727 shill::kCarrierProperty, |
723 base::StringValue(shill::kCarrierSprint)); | 728 base::StringValue(shill::kCarrierSprint)); |
724 | 729 |
725 services->AddService("cellular1", | 730 services->AddService("/service/cellular1", |
726 "cellular1", | 731 "cellular1", |
727 shill::kTypeCellular, | 732 shill::kTypeCellular, |
728 state, | 733 state, |
729 add_to_visible, add_to_watchlist); | 734 add_to_visible, add_to_watchlist); |
730 base::StringValue technology_value(shill::kNetworkTechnologyGsm); | 735 base::StringValue technology_value(shill::kNetworkTechnologyGsm); |
731 services->SetServiceProperty( | 736 services->SetServiceProperty("/service/cellular1", |
732 "cellular1", shill::kNetworkTechnologyProperty, technology_value); | 737 shill::kNetworkTechnologyProperty, |
738 technology_value); | |
733 | 739 |
734 if (activated) { | 740 if (activated) { |
735 services->SetServiceProperty( | 741 services->SetServiceProperty( |
736 "cellular1", | 742 "/service/cellular1", |
737 shill::kActivationStateProperty, | 743 shill::kActivationStateProperty, |
738 base::StringValue(shill::kActivationStateActivated)); | 744 base::StringValue(shill::kActivationStateActivated)); |
739 services->SetServiceProperty("cellular1", | 745 services->SetServiceProperty("/service/cellular1", |
740 shill::kConnectableProperty, | 746 shill::kConnectableProperty, |
741 base::FundamentalValue(true)); | 747 base::FundamentalValue(true)); |
742 } else { | 748 } else { |
743 services->SetServiceProperty( | 749 services->SetServiceProperty( |
744 "cellular1", | 750 "/service/cellular1", |
745 shill::kActivationStateProperty, | 751 shill::kActivationStateProperty, |
746 base::StringValue(shill::kActivationStateNotActivated)); | 752 base::StringValue(shill::kActivationStateNotActivated)); |
747 } | 753 } |
748 | 754 |
749 services->SetServiceProperty("cellular1", | 755 services->SetServiceProperty("/service/cellular1", |
750 shill::kRoamingStateProperty, | 756 shill::kRoamingStateProperty, |
751 base::StringValue(shill::kRoamingStateHome)); | 757 base::StringValue(shill::kRoamingStateHome)); |
752 } | 758 } |
753 | 759 |
754 // VPN | 760 // VPN |
755 state = GetInitialStateForType(shill::kTypeVPN, &enabled); | 761 state = GetInitialStateForType(shill::kTypeVPN, &enabled); |
756 if (state != kTechnologyUnavailable) { | 762 if (state != kTechnologyUnavailable) { |
757 // Set the "Provider" dictionary properties. Note: when setting these in | 763 // Set the "Provider" dictionary properties. Note: when setting these in |
758 // Shill, "Provider.Type", etc keys are used, but when reading the values | 764 // Shill, "Provider.Type", etc keys are used, but when reading the values |
759 // "Provider" . "Type", etc keys are used. Here we are setting the values | 765 // "Provider" . "Type", etc keys are used. Here we are setting the values |
760 // that will be read (by the UI, tests, etc). | 766 // that will be read (by the UI, tests, etc). |
761 base::DictionaryValue provider_properties; | 767 base::DictionaryValue provider_properties; |
762 provider_properties.SetString(shill::kTypeProperty, | 768 provider_properties.SetString(shill::kTypeProperty, |
763 shill::kProviderOpenVpn); | 769 shill::kProviderOpenVpn); |
764 provider_properties.SetString(shill::kHostProperty, "vpn_host"); | 770 provider_properties.SetString(shill::kHostProperty, "vpn_host"); |
765 | 771 |
766 services->AddService("vpn1", | 772 services->AddService("/service/vpn1", |
767 "vpn1", | 773 "vpn1", |
768 shill::kTypeVPN, | 774 shill::kTypeVPN, |
769 state, | 775 state, |
770 add_to_visible, add_to_watchlist); | 776 add_to_visible, add_to_watchlist); |
771 services->SetServiceProperty( | 777 services->SetServiceProperty( |
772 "vpn1", shill::kProviderProperty, provider_properties); | 778 "/service/vpn1", shill::kProviderProperty, provider_properties); |
773 profiles->AddService(shared_profile, "vpn1"); | 779 profiles->AddService(shared_profile, "/service/vpn1"); |
774 | 780 |
775 services->AddService("vpn2", | 781 services->AddService("/service/vpn2", |
776 "vpn2", | 782 "vpn2", |
777 shill::kTypeVPN, | 783 shill::kTypeVPN, |
778 shill::kStateIdle, | 784 shill::kStateIdle, |
779 add_to_visible, add_to_watchlist); | 785 add_to_visible, add_to_watchlist); |
780 services->SetServiceProperty( | 786 services->SetServiceProperty( |
781 "vpn2", shill::kProviderProperty, provider_properties); | 787 "/service/vpn2", shill::kProviderProperty, provider_properties); |
782 } | 788 } |
783 | 789 |
784 SortManagerServices(); | 790 SortManagerServices(); |
785 } | 791 } |
786 | 792 |
787 // Private methods | 793 // Private methods |
788 | 794 |
789 void FakeShillManagerClient::AddServiceToWatchList( | 795 void FakeShillManagerClient::AddServiceToWatchList( |
790 const std::string& service_path) { | 796 const std::string& service_path) { |
791 // Remove and insert the service, moving it to the front of the watch list. | 797 // Remove and insert the service, moving it to the front of the watch list. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 return; | 830 return; |
825 base::MessageLoop::current()->PostTask( | 831 base::MessageLoop::current()->PostTask( |
826 FROM_HERE, | 832 FROM_HERE, |
827 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, | 833 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, |
828 weak_ptr_factory_.GetWeakPtr(), | 834 weak_ptr_factory_.GetWeakPtr(), |
829 property)); | 835 property)); |
830 } | 836 } |
831 | 837 |
832 void FakeShillManagerClient::NotifyObserversPropertyChanged( | 838 void FakeShillManagerClient::NotifyObserversPropertyChanged( |
833 const std::string& property) { | 839 const std::string& property) { |
840 VLOG(1) << "NotifyObserversPropertyChanged: " << property; | |
834 if (property == shill::kServicesProperty || | 841 if (property == shill::kServicesProperty || |
835 property == shill::kServiceWatchListProperty) { | 842 property == shill::kServiceWatchListProperty) { |
836 scoped_ptr<base::ListValue> services(GetEnabledServiceList(property)); | 843 scoped_ptr<base::ListValue> services(GetEnabledServiceList(property)); |
837 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 844 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, |
838 observer_list_, | 845 observer_list_, |
839 OnPropertyChanged(property, *(services.get()))); | 846 OnPropertyChanged(property, *(services.get()))); |
840 return; | 847 return; |
841 } | 848 } |
842 if (property == shill::kDevicesProperty) { | 849 if (property == shill::kDevicesProperty) { |
843 base::ListValue* devices = NULL; | 850 base::ListValue* devices = NULL; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
930 } | 937 } |
931 | 938 |
932 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, | 939 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, |
933 const base::Closure& callback) { | 940 const base::Closure& callback) { |
934 if (!device_path.empty()) { | 941 if (!device_path.empty()) { |
935 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> | 942 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> |
936 SetDeviceProperty(device_path, | 943 SetDeviceProperty(device_path, |
937 shill::kScanningProperty, | 944 shill::kScanningProperty, |
938 base::FundamentalValue(false)); | 945 base::FundamentalValue(false)); |
939 } | 946 } |
947 VLOG(2) << "ScanCompleted"; | |
940 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 948 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
941 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); | 949 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
942 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 950 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
943 } | 951 } |
944 | 952 |
945 void FakeShillManagerClient::ParseCommandLineSwitch() { | 953 void FakeShillManagerClient::ParseCommandLineSwitch() { |
946 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 954 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
947 if (command_line->HasSwitch(switches::kShillStub)) { | 955 if (command_line->HasSwitch(switches::kShillStub)) { |
948 std::string option_str = | 956 std::string option_str = |
949 command_line->GetSwitchValueASCII(switches::kShillStub); | 957 command_line->GetSwitchValueASCII(switches::kShillStub); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1051 *enabled = true; | 1059 *enabled = true; |
1052 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || | 1060 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || |
1053 (state == kNetworkActivated && type != shill::kTypeCellular)) { | 1061 (state == kNetworkActivated && type != shill::kTypeCellular)) { |
1054 LOG(WARNING) << "Invalid state: " << state << " for " << type; | 1062 LOG(WARNING) << "Invalid state: " << state << " for " << type; |
1055 return shill::kStateIdle; | 1063 return shill::kStateIdle; |
1056 } | 1064 } |
1057 return state; | 1065 return state; |
1058 } | 1066 } |
1059 | 1067 |
1060 } // namespace chromeos | 1068 } // namespace chromeos |
OLD | NEW |