Chromium Code Reviews| 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; | |
|
pneubeck (no reviews)
2014/06/04 09:30:27
Just noting that these are ending up in release/pr
stevenjb
2014/06/04 19:49:58
Will switch to DVLOG
| |
| 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, |
| 510 shill::kTypeVPN | 516 shill::kTypeVPN |
| 511 }; | 517 }; |
| 512 | 518 |
| 513 base::ListValue* service_list = GetListProperty(property); | 519 base::ListValue* service_list = GetListProperty(property); |
| 520 scoped_ptr<base::ListValue> prev_service_list(service_list->DeepCopy()); | |
| 514 std::vector<std::string> active_services; | 521 std::vector<std::string> active_services; |
| 515 std::vector<std::string> inactive_services; | 522 std::vector<std::string> inactive_services; |
| 516 if (service_list && !service_list->empty()) { | 523 if (service_list && !service_list->empty()) { |
| 517 for (size_t i = 0; i < arraysize(ordered_types); ++i) { | 524 for (size_t i = 0; i < arraysize(ordered_types); ++i) { |
| 518 AppendServicesForType(service_list, ordered_types[i], | 525 AppendServicesForType(service_list, ordered_types[i], |
| 519 &active_services, &inactive_services); | 526 &active_services, &inactive_services); |
| 520 } | 527 } |
| 521 service_list->Clear(); | 528 service_list->Clear(); |
| 522 for (size_t i = 0; i < active_services.size(); ++i) | 529 for (size_t i = 0; i < active_services.size(); ++i) |
| 523 service_list->AppendString(active_services[i]); | 530 service_list->AppendString(active_services[i]); |
| 524 for (size_t i = 0; i < inactive_services.size(); ++i) | 531 for (size_t i = 0; i < inactive_services.size(); ++i) |
| 525 service_list->AppendString(inactive_services[i]); | 532 service_list->AppendString(inactive_services[i]); |
| 526 } | 533 } |
| 527 | 534 |
| 528 if (property != shill::kServicesProperty) | 535 if (property != shill::kServicesProperty) |
| 529 return; | 536 return; |
| 530 | 537 |
| 531 CallNotifyObserversPropertyChanged(property); | 538 if (!service_list->Equals(prev_service_list.get())) |
| 539 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | |
| 532 | 540 |
| 533 // Set the first active service as the Default service. | 541 // Set the first active service as the Default service. |
| 534 std::string new_default_service; | 542 std::string new_default_service; |
| 535 if (!active_services.empty()) { | 543 if (!active_services.empty()) { |
| 536 ShillServiceClient::TestInterface* service_client = | 544 ShillServiceClient::TestInterface* service_client = |
| 537 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); | 545 DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface(); |
| 538 std::string service_path = active_services[0]; | 546 std::string service_path = active_services[0]; |
| 539 const base::DictionaryValue* properties = | 547 const base::DictionaryValue* properties = |
| 540 service_client->GetServiceProperties(service_path); | 548 service_client->GetServiceProperties(service_path); |
| 541 if (!properties) { | 549 if (!properties) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 613 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); | 621 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); |
| 614 devices->SetDeviceProperty("/device/eth1", | 622 devices->SetDeviceProperty("/device/eth1", |
| 615 shill::kAddressProperty, | 623 shill::kAddressProperty, |
| 616 base::StringValue("0123456789ab")); | 624 base::StringValue("0123456789ab")); |
| 617 base::ListValue eth_ip_configs; | 625 base::ListValue eth_ip_configs; |
| 618 eth_ip_configs.AppendString("ipconfig_v4_path"); | 626 eth_ip_configs.AppendString("ipconfig_v4_path"); |
| 619 eth_ip_configs.AppendString("ipconfig_v6_path"); | 627 eth_ip_configs.AppendString("ipconfig_v6_path"); |
| 620 devices->SetDeviceProperty("/device/eth1", | 628 devices->SetDeviceProperty("/device/eth1", |
| 621 shill::kIPConfigsProperty, | 629 shill::kIPConfigsProperty, |
| 622 eth_ip_configs); | 630 eth_ip_configs); |
| 623 services->AddService("eth1", "eth1", | 631 services->AddService("/service/eth1", "eth1", |
| 624 shill::kTypeEthernet, | 632 shill::kTypeEthernet, |
| 625 state, | 633 state, |
| 626 add_to_visible, add_to_watchlist); | 634 add_to_visible, add_to_watchlist); |
| 627 profiles->AddService(shared_profile, "eth1"); | 635 profiles->AddService(shared_profile, "/service/eth1"); |
| 628 } | 636 } |
| 629 | 637 |
| 630 // Wifi | 638 // Wifi |
| 631 state = GetInitialStateForType(shill::kTypeWifi, &enabled); | 639 state = GetInitialStateForType(shill::kTypeWifi, &enabled); |
| 632 if (state != kTechnologyUnavailable) { | 640 if (state != kTechnologyUnavailable) { |
| 633 bool portaled = false; | 641 bool portaled = false; |
| 634 if (state == shill::kStatePortal) { | 642 if (state == shill::kStatePortal) { |
| 635 portaled = true; | 643 portaled = true; |
| 636 state = shill::kStateIdle; | 644 state = shill::kStateIdle; |
| 637 } | 645 } |
| 638 AddTechnology(shill::kTypeWifi, enabled); | 646 AddTechnology(shill::kTypeWifi, enabled); |
| 639 devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); | 647 devices->AddDevice("/device/wifi1", shill::kTypeWifi, "stub_wifi_device1"); |
| 640 devices->SetDeviceProperty("/device/wifi1", | 648 devices->SetDeviceProperty("/device/wifi1", |
| 641 shill::kAddressProperty, | 649 shill::kAddressProperty, |
| 642 base::StringValue("23456789abc")); | 650 base::StringValue("23456789abc")); |
| 643 base::ListValue wifi_ip_configs; | 651 base::ListValue wifi_ip_configs; |
| 644 wifi_ip_configs.AppendString("ipconfig_v4_path"); | 652 wifi_ip_configs.AppendString("ipconfig_v4_path"); |
| 645 wifi_ip_configs.AppendString("ipconfig_v6_path"); | 653 wifi_ip_configs.AppendString("ipconfig_v6_path"); |
| 646 devices->SetDeviceProperty("/device/wifi1", | 654 devices->SetDeviceProperty("/device/wifi1", |
| 647 shill::kIPConfigsProperty, | 655 shill::kIPConfigsProperty, |
| 648 wifi_ip_configs); | 656 wifi_ip_configs); |
| 649 | 657 |
| 650 services->AddService("wifi1", | 658 services->AddService("/service/wifi1", |
| 651 "wifi1", | 659 "wifi1", |
| 652 shill::kTypeWifi, | 660 shill::kTypeWifi, |
| 653 state, | 661 state, |
| 654 add_to_visible, add_to_watchlist); | 662 add_to_visible, add_to_watchlist); |
| 655 services->SetServiceProperty("wifi1", | 663 services->SetServiceProperty("/service/wifi1", |
| 656 shill::kSecurityProperty, | 664 shill::kSecurityProperty, |
| 657 base::StringValue(shill::kSecurityWep)); | 665 base::StringValue(shill::kSecurityWep)); |
| 658 profiles->AddService(shared_profile, "wifi1"); | 666 profiles->AddService(shared_profile, "/service/wifi1"); |
| 659 | 667 |
| 660 services->AddService("wifi2", | 668 services->AddService("/service/wifi2", |
| 661 "wifi2_PSK", | 669 "wifi2_PSK", |
| 662 shill::kTypeWifi, | 670 shill::kTypeWifi, |
| 663 shill::kStateIdle, | 671 shill::kStateIdle, |
| 664 add_to_visible, add_to_watchlist); | 672 add_to_visible, add_to_watchlist); |
| 665 services->SetServiceProperty("wifi2", | 673 services->SetServiceProperty("/service/wifi2", |
| 666 shill::kSecurityProperty, | 674 shill::kSecurityProperty, |
| 667 base::StringValue(shill::kSecurityPsk)); | 675 base::StringValue(shill::kSecurityPsk)); |
| 668 | 676 |
| 669 base::FundamentalValue strength_value(80); | 677 base::FundamentalValue strength_value(80); |
| 670 services->SetServiceProperty( | 678 services->SetServiceProperty( |
| 671 "wifi2", shill::kSignalStrengthProperty, strength_value); | 679 "/service/wifi2", shill::kSignalStrengthProperty, strength_value); |
| 672 profiles->AddService(shared_profile, "wifi2"); | 680 profiles->AddService(shared_profile, "/service/wifi2"); |
| 673 | 681 |
| 674 if (portaled) { | 682 if (portaled) { |
| 675 const std::string kPortaledWifiPath = "portaled_wifi"; | 683 const std::string kPortaledWifiPath = "/service/portaled_wifi"; |
| 676 services->AddService(kPortaledWifiPath, | 684 services->AddService(kPortaledWifiPath, |
| 677 "Portaled Wifi", | 685 "Portaled Wifi", |
| 678 shill::kTypeWifi, | 686 shill::kTypeWifi, |
| 679 shill::kStatePortal, | 687 shill::kStatePortal, |
| 680 add_to_visible, add_to_watchlist); | 688 add_to_visible, add_to_watchlist); |
| 681 services->SetServiceProperty(kPortaledWifiPath, | 689 services->SetServiceProperty(kPortaledWifiPath, |
| 682 shill::kSecurityProperty, | 690 shill::kSecurityProperty, |
| 683 base::StringValue(shill::kSecurityNone)); | 691 base::StringValue(shill::kSecurityNone)); |
| 684 services->SetConnectBehavior(kPortaledWifiPath, | 692 services->SetConnectBehavior(kPortaledWifiPath, |
| 685 base::Bind(&UpdatePortaledWifiState, | 693 base::Bind(&UpdatePortaledWifiState, |
| 686 "portaled_wifi")); | 694 "portaled_wifi")); |
| 687 services->SetServiceProperty(kPortaledWifiPath, | 695 services->SetServiceProperty(kPortaledWifiPath, |
| 688 shill::kConnectableProperty, | 696 shill::kConnectableProperty, |
| 689 base::FundamentalValue(true)); | 697 base::FundamentalValue(true)); |
| 690 profiles->AddService(shared_profile, kPortaledWifiPath); | 698 profiles->AddService(shared_profile, kPortaledWifiPath); |
| 691 } | 699 } |
| 692 } | 700 } |
| 693 | 701 |
| 694 // Wimax | 702 // Wimax |
| 695 state = GetInitialStateForType(shill::kTypeWimax, &enabled); | 703 state = GetInitialStateForType(shill::kTypeWimax, &enabled); |
| 696 if (state != kTechnologyUnavailable) { | 704 if (state != kTechnologyUnavailable) { |
| 697 AddTechnology(shill::kTypeWimax, enabled); | 705 AddTechnology(shill::kTypeWimax, enabled); |
| 698 devices->AddDevice( | 706 devices->AddDevice( |
| 699 "/device/wimax1", shill::kTypeWimax, "stub_wimax_device1"); | 707 "/device/wimax1", shill::kTypeWimax, "stub_wimax_device1"); |
| 700 | 708 |
| 701 services->AddService("wimax1", | 709 services->AddService("/service/wimax1", |
| 702 "wimax1", | 710 "wimax1", |
| 703 shill::kTypeWimax, | 711 shill::kTypeWimax, |
| 704 state, | 712 state, |
| 705 add_to_visible, add_to_watchlist); | 713 add_to_visible, add_to_watchlist); |
| 706 services->SetServiceProperty( | 714 services->SetServiceProperty("/service/wimax1", |
| 707 "wimax1", shill::kConnectableProperty, base::FundamentalValue(true)); | 715 shill::kConnectableProperty, |
| 716 base::FundamentalValue(true)); | |
| 708 } | 717 } |
| 709 | 718 |
| 710 // Cellular | 719 // Cellular |
| 711 state = GetInitialStateForType(shill::kTypeCellular, &enabled); | 720 state = GetInitialStateForType(shill::kTypeCellular, &enabled); |
| 712 if (state != kTechnologyUnavailable) { | 721 if (state != kTechnologyUnavailable) { |
| 713 bool activated = false; | 722 bool activated = false; |
| 714 if (state == kNetworkActivated) { | 723 if (state == kNetworkActivated) { |
| 715 activated = true; | 724 activated = true; |
| 716 state = shill::kStateIdle; | 725 state = shill::kStateIdle; |
| 717 } | 726 } |
| 718 AddTechnology(shill::kTypeCellular, enabled); | 727 AddTechnology(shill::kTypeCellular, enabled); |
| 719 devices->AddDevice( | 728 devices->AddDevice( |
| 720 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); | 729 "/device/cellular1", shill::kTypeCellular, "stub_cellular_device1"); |
| 721 devices->SetDeviceProperty("/device/cellular1", | 730 devices->SetDeviceProperty("/device/cellular1", |
| 722 shill::kCarrierProperty, | 731 shill::kCarrierProperty, |
| 723 base::StringValue(shill::kCarrierSprint)); | 732 base::StringValue(shill::kCarrierSprint)); |
| 724 | 733 |
| 725 services->AddService("cellular1", | 734 services->AddService("/service/cellular1", |
| 726 "cellular1", | 735 "cellular1", |
| 727 shill::kTypeCellular, | 736 shill::kTypeCellular, |
| 728 state, | 737 state, |
| 729 add_to_visible, add_to_watchlist); | 738 add_to_visible, add_to_watchlist); |
| 730 base::StringValue technology_value(shill::kNetworkTechnologyGsm); | 739 base::StringValue technology_value(shill::kNetworkTechnologyGsm); |
| 731 services->SetServiceProperty( | 740 services->SetServiceProperty("/service/cellular1", |
| 732 "cellular1", shill::kNetworkTechnologyProperty, technology_value); | 741 shill::kNetworkTechnologyProperty, |
| 742 technology_value); | |
| 733 | 743 |
| 734 if (activated) { | 744 if (activated) { |
| 735 services->SetServiceProperty( | 745 services->SetServiceProperty( |
| 736 "cellular1", | 746 "/service/cellular1", |
| 737 shill::kActivationStateProperty, | 747 shill::kActivationStateProperty, |
| 738 base::StringValue(shill::kActivationStateActivated)); | 748 base::StringValue(shill::kActivationStateActivated)); |
| 739 services->SetServiceProperty("cellular1", | 749 services->SetServiceProperty("/service/cellular1", |
| 740 shill::kConnectableProperty, | 750 shill::kConnectableProperty, |
| 741 base::FundamentalValue(true)); | 751 base::FundamentalValue(true)); |
| 742 } else { | 752 } else { |
| 743 services->SetServiceProperty( | 753 services->SetServiceProperty( |
| 744 "cellular1", | 754 "/service/cellular1", |
| 745 shill::kActivationStateProperty, | 755 shill::kActivationStateProperty, |
| 746 base::StringValue(shill::kActivationStateNotActivated)); | 756 base::StringValue(shill::kActivationStateNotActivated)); |
| 747 } | 757 } |
| 748 | 758 |
| 749 services->SetServiceProperty("cellular1", | 759 services->SetServiceProperty("/service/cellular1", |
| 750 shill::kRoamingStateProperty, | 760 shill::kRoamingStateProperty, |
| 751 base::StringValue(shill::kRoamingStateHome)); | 761 base::StringValue(shill::kRoamingStateHome)); |
| 752 } | 762 } |
| 753 | 763 |
| 754 // VPN | 764 // VPN |
| 755 state = GetInitialStateForType(shill::kTypeVPN, &enabled); | 765 state = GetInitialStateForType(shill::kTypeVPN, &enabled); |
| 756 if (state != kTechnologyUnavailable) { | 766 if (state != kTechnologyUnavailable) { |
| 757 // Set the "Provider" dictionary properties. Note: when setting these in | 767 // Set the "Provider" dictionary properties. Note: when setting these in |
| 758 // Shill, "Provider.Type", etc keys are used, but when reading the values | 768 // 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 | 769 // "Provider" . "Type", etc keys are used. Here we are setting the values |
| 760 // that will be read (by the UI, tests, etc). | 770 // that will be read (by the UI, tests, etc). |
| 761 base::DictionaryValue provider_properties; | 771 base::DictionaryValue provider_properties; |
| 762 provider_properties.SetString(shill::kTypeProperty, | 772 provider_properties.SetString(shill::kTypeProperty, |
| 763 shill::kProviderOpenVpn); | 773 shill::kProviderOpenVpn); |
| 764 provider_properties.SetString(shill::kHostProperty, "vpn_host"); | 774 provider_properties.SetString(shill::kHostProperty, "vpn_host"); |
| 765 | 775 |
| 766 services->AddService("vpn1", | 776 services->AddService("/service/vpn1", |
| 767 "vpn1", | 777 "vpn1", |
| 768 shill::kTypeVPN, | 778 shill::kTypeVPN, |
| 769 state, | 779 state, |
| 770 add_to_visible, add_to_watchlist); | 780 add_to_visible, add_to_watchlist); |
| 771 services->SetServiceProperty( | 781 services->SetServiceProperty( |
| 772 "vpn1", shill::kProviderProperty, provider_properties); | 782 "/service/vpn1", shill::kProviderProperty, provider_properties); |
| 773 profiles->AddService(shared_profile, "vpn1"); | 783 profiles->AddService(shared_profile, "/service/vpn1"); |
| 774 | 784 |
| 775 services->AddService("vpn2", | 785 services->AddService("/service/vpn2", |
| 776 "vpn2", | 786 "vpn2", |
| 777 shill::kTypeVPN, | 787 shill::kTypeVPN, |
| 778 shill::kStateIdle, | 788 shill::kStateIdle, |
| 779 add_to_visible, add_to_watchlist); | 789 add_to_visible, add_to_watchlist); |
| 780 services->SetServiceProperty( | 790 services->SetServiceProperty( |
| 781 "vpn2", shill::kProviderProperty, provider_properties); | 791 "/service/vpn2", shill::kProviderProperty, provider_properties); |
| 782 } | 792 } |
| 783 | 793 |
| 784 SortManagerServices(); | 794 SortManagerServices(); |
| 785 } | 795 } |
| 786 | 796 |
| 787 // Private methods | 797 // Private methods |
| 788 | 798 |
| 789 void FakeShillManagerClient::AddServiceToWatchList( | 799 void FakeShillManagerClient::AddServiceToWatchList( |
| 790 const std::string& service_path) { | 800 const std::string& service_path) { |
| 791 // Remove and insert the service, moving it to the front of the watch list. | 801 // 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; | 834 return; |
| 825 base::MessageLoop::current()->PostTask( | 835 base::MessageLoop::current()->PostTask( |
| 826 FROM_HERE, | 836 FROM_HERE, |
| 827 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, | 837 base::Bind(&FakeShillManagerClient::NotifyObserversPropertyChanged, |
| 828 weak_ptr_factory_.GetWeakPtr(), | 838 weak_ptr_factory_.GetWeakPtr(), |
| 829 property)); | 839 property)); |
| 830 } | 840 } |
| 831 | 841 |
| 832 void FakeShillManagerClient::NotifyObserversPropertyChanged( | 842 void FakeShillManagerClient::NotifyObserversPropertyChanged( |
| 833 const std::string& property) { | 843 const std::string& property) { |
| 844 VLOG(1) << "NotifyObserversPropertyChanged: " << property; | |
| 834 if (property == shill::kServicesProperty || | 845 if (property == shill::kServicesProperty || |
| 835 property == shill::kServiceWatchListProperty) { | 846 property == shill::kServiceWatchListProperty) { |
| 836 scoped_ptr<base::ListValue> services(GetEnabledServiceList(property)); | 847 scoped_ptr<base::ListValue> services(GetEnabledServiceList(property)); |
| 837 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, | 848 FOR_EACH_OBSERVER(ShillPropertyChangedObserver, |
| 838 observer_list_, | 849 observer_list_, |
| 839 OnPropertyChanged(property, *(services.get()))); | 850 OnPropertyChanged(property, *(services.get()))); |
| 840 return; | 851 return; |
| 841 } | 852 } |
| 842 if (property == shill::kDevicesProperty) { | 853 if (property == shill::kDevicesProperty) { |
| 843 base::ListValue* devices = NULL; | 854 base::ListValue* devices = NULL; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 } | 941 } |
| 931 | 942 |
| 932 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, | 943 void FakeShillManagerClient::ScanCompleted(const std::string& device_path, |
| 933 const base::Closure& callback) { | 944 const base::Closure& callback) { |
| 934 if (!device_path.empty()) { | 945 if (!device_path.empty()) { |
| 935 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> | 946 DBusThreadManager::Get()->GetShillDeviceClient()->GetTestInterface()-> |
| 936 SetDeviceProperty(device_path, | 947 SetDeviceProperty(device_path, |
| 937 shill::kScanningProperty, | 948 shill::kScanningProperty, |
| 938 base::FundamentalValue(false)); | 949 base::FundamentalValue(false)); |
| 939 } | 950 } |
| 951 VLOG(2) << "ScanCompleted"; | |
| 940 CallNotifyObserversPropertyChanged(shill::kServicesProperty); | 952 CallNotifyObserversPropertyChanged(shill::kServicesProperty); |
| 941 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); | 953 CallNotifyObserversPropertyChanged(shill::kServiceWatchListProperty); |
| 942 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 954 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
| 943 } | 955 } |
| 944 | 956 |
| 945 void FakeShillManagerClient::ParseCommandLineSwitch() { | 957 void FakeShillManagerClient::ParseCommandLineSwitch() { |
| 946 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 958 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 947 if (command_line->HasSwitch(switches::kShillStub)) { | 959 if (command_line->HasSwitch(switches::kShillStub)) { |
| 948 std::string option_str = | 960 std::string option_str = |
| 949 command_line->GetSwitchValueASCII(switches::kShillStub); | 961 command_line->GetSwitchValueASCII(switches::kShillStub); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 *enabled = true; | 1063 *enabled = true; |
| 1052 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || | 1064 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || |
| 1053 (state == kNetworkActivated && type != shill::kTypeCellular)) { | 1065 (state == kNetworkActivated && type != shill::kTypeCellular)) { |
| 1054 LOG(WARNING) << "Invalid state: " << state << " for " << type; | 1066 LOG(WARNING) << "Invalid state: " << state << " for " << type; |
| 1055 return shill::kStateIdle; | 1067 return shill::kStateIdle; |
| 1056 } | 1068 } |
| 1057 return state; | 1069 return state; |
| 1058 } | 1070 } |
| 1059 | 1071 |
| 1060 } // namespace chromeos | 1072 } // namespace chromeos |
| OLD | NEW |