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

Side by Side Diff: chromeos/dbus/fake_shill_manager_client.cc

Issue 267433005: Provide IPConfigs in networkingPrivate.GetProperties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + Elim DHCP ONC types Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
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"
11 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chromeos/chromeos_switches.h" 14 #include "chromeos/chromeos_switches.h"
15 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
16 #include "chromeos/dbus/shill_device_client.h" 16 #include "chromeos/dbus/shill_device_client.h"
17 #include "chromeos/dbus/shill_ipconfig_client.h"
17 #include "chromeos/dbus/shill_profile_client.h" 18 #include "chromeos/dbus/shill_profile_client.h"
18 #include "chromeos/dbus/shill_property_changed_observer.h" 19 #include "chromeos/dbus/shill_property_changed_observer.h"
19 #include "chromeos/dbus/shill_service_client.h" 20 #include "chromeos/dbus/shill_service_client.h"
20 #include "dbus/bus.h" 21 #include "dbus/bus.h"
21 #include "dbus/message.h" 22 #include "dbus/message.h"
22 #include "dbus/object_path.h" 23 #include "dbus/object_path.h"
23 #include "dbus/values_util.h" 24 #include "dbus/values_util.h"
24 #include "third_party/cros_system_api/dbus/service_constants.h" 25 #include "third_party/cros_system_api/dbus/service_constants.h"
25 26
26 namespace chromeos { 27 namespace chromeos {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 541
541 542
542 int FakeShillManagerClient::GetInteractiveDelay() const { 543 int FakeShillManagerClient::GetInteractiveDelay() const {
543 return interactive_delay_; 544 return interactive_delay_;
544 } 545 }
545 546
546 void FakeShillManagerClient::SetupDefaultEnvironment() { 547 void FakeShillManagerClient::SetupDefaultEnvironment() {
547 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); 548 DBusThreadManager* dbus_manager = DBusThreadManager::Get();
548 ShillServiceClient::TestInterface* services = 549 ShillServiceClient::TestInterface* services =
549 dbus_manager->GetShillServiceClient()->GetTestInterface(); 550 dbus_manager->GetShillServiceClient()->GetTestInterface();
551 DCHECK(services);
550 ShillProfileClient::TestInterface* profiles = 552 ShillProfileClient::TestInterface* profiles =
551 dbus_manager->GetShillProfileClient()->GetTestInterface(); 553 dbus_manager->GetShillProfileClient()->GetTestInterface();
554 DCHECK(profiles);
552 ShillDeviceClient::TestInterface* devices = 555 ShillDeviceClient::TestInterface* devices =
553 dbus_manager->GetShillDeviceClient()->GetTestInterface(); 556 dbus_manager->GetShillDeviceClient()->GetTestInterface();
554 if (!services || !profiles || !devices) 557 DCHECK(devices);
555 return; 558 ShillIPConfigClient::TestInterface* ip_configs =
559 dbus_manager->GetShillIPConfigClient()->GetTestInterface();
560 DCHECK(ip_configs);
556 561
557 const std::string shared_profile = ShillProfileClient::GetSharedProfilePath(); 562 const std::string shared_profile = ShillProfileClient::GetSharedProfilePath();
558 profiles->AddProfile(shared_profile, std::string()); 563 profiles->AddProfile(shared_profile, std::string());
559 564
560 const bool add_to_visible = true; 565 const bool add_to_visible = true;
561 const bool add_to_watchlist = true; 566 const bool add_to_watchlist = true;
562 567
563 bool enabled; 568 bool enabled;
564 std::string state; 569 std::string state;
565 570
571 // IPConfigs
572 base::DictionaryValue ipconfig_v4_dictionary;
573 ipconfig_v4_dictionary.SetStringWithoutPathExpansion(
574 shill::kAddressProperty, "0.0.0.0");
575 ipconfig_v4_dictionary.SetStringWithoutPathExpansion(
576 shill::kGatewayProperty, "0.0.0.1");
577 ipconfig_v4_dictionary.SetIntegerWithoutPathExpansion(
578 shill::kPrefixlenProperty, 0);
579 ipconfig_v4_dictionary.SetStringWithoutPathExpansion(
580 shill::kMethodProperty, shill::kTypeIPv4);
581 ip_configs->AddIPConfig("ipconfig_v4_path", ipconfig_v4_dictionary);
582 base::DictionaryValue ipconfig_v6_dictionary;
583 ipconfig_v6_dictionary.SetStringWithoutPathExpansion(
584 shill::kAddressProperty, "0:0:0:0:0:0:0:0");
585 ipconfig_v6_dictionary.SetStringWithoutPathExpansion(
586 shill::kMethodProperty, shill::kTypeIPv6);
587 ip_configs->AddIPConfig("ipconfig_v6_path", ipconfig_v6_dictionary);
588
566 // Ethernet 589 // Ethernet
567 state = GetInitialStateForType(shill::kTypeEthernet, &enabled); 590 state = GetInitialStateForType(shill::kTypeEthernet, &enabled);
568 if (state == shill::kStateOnline) { 591 if (state == shill::kStateOnline) {
569 AddTechnology(shill::kTypeEthernet, enabled); 592 AddTechnology(shill::kTypeEthernet, enabled);
570 devices->AddDevice( 593 devices->AddDevice(
571 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1"); 594 "/device/eth1", shill::kTypeEthernet, "stub_eth_device1");
595 base::ListValue eth_ip_configs;
596 eth_ip_configs.AppendString("ipconfig_v4_path");
597 eth_ip_configs.AppendString("ipconfig_v6_path");
598 devices->SetDeviceProperty("/device/eth1",
599 shill::kIPConfigsProperty,
600 eth_ip_configs);
572 services->AddService("eth1", "eth1", 601 services->AddService("eth1", "eth1",
573 shill::kTypeEthernet, 602 shill::kTypeEthernet,
574 state, 603 state,
575 add_to_visible, add_to_watchlist); 604 add_to_visible, add_to_watchlist);
576 profiles->AddService(shared_profile, "eth1"); 605 profiles->AddService(shared_profile, "eth1");
577 } 606 }
578 607
579 // Wifi 608 // Wifi
580 state = GetInitialStateForType(shill::kTypeWifi, &enabled); 609 state = GetInitialStateForType(shill::kTypeWifi, &enabled);
581 if (state != kTechnologyUnavailable) { 610 if (state != kTechnologyUnavailable) {
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 *enabled = true; 1022 *enabled = true;
994 if ((state == shill::kStatePortal && type != shill::kTypeWifi) || 1023 if ((state == shill::kStatePortal && type != shill::kTypeWifi) ||
995 (state == kNetworkActivated && type != shill::kTypeCellular)) { 1024 (state == kNetworkActivated && type != shill::kTypeCellular)) {
996 LOG(WARNING) << "Invalid state: " << state << " for " << type; 1025 LOG(WARNING) << "Invalid state: " << state << " for " << type;
997 return shill::kStateIdle; 1026 return shill::kStateIdle;
998 } 1027 }
999 return state; 1028 return state;
1000 } 1029 }
1001 1030
1002 } // namespace chromeos 1031 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698