OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/shill_manager_client_stub.h" | 5 #include "chromeos/dbus/shill_manager_client_stub.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/values.h" | 10 #include "base/values.h" |
11 #include "chromeos/chromeos_switches.h" | 11 #include "chromeos/chromeos_switches.h" |
12 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
13 #include "chromeos/dbus/shill_device_client.h" | 13 #include "chromeos/dbus/shill_device_client.h" |
14 #include "chromeos/dbus/shill_profile_client.h" | 14 #include "chromeos/dbus/shill_profile_client.h" |
15 #include "chromeos/dbus/shill_property_changed_observer.h" | 15 #include "chromeos/dbus/shill_property_changed_observer.h" |
16 #include "chromeos/dbus/shill_service_client.h" | 16 #include "chromeos/dbus/shill_service_client.h" |
17 #include "dbus/bus.h" | 17 #include "dbus/bus.h" |
18 #include "dbus/message.h" | 18 #include "dbus/message.h" |
19 #include "dbus/object_path.h" | 19 #include "dbus/object_path.h" |
20 #include "dbus/object_proxy.h" | |
21 #include "dbus/values_util.h" | 20 #include "dbus/values_util.h" |
22 #include "third_party/cros_system_api/dbus/service_constants.h" | 21 #include "third_party/cros_system_api/dbus/service_constants.h" |
23 | 22 |
24 namespace chromeos { | 23 namespace chromeos { |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 // Used to compare values for finding entries to erase in a ListValue. | 27 // Used to compare values for finding entries to erase in a ListValue. |
29 // (ListValue only implements a const_iterator version of Find). | 28 // (ListValue only implements a const_iterator version of Find). |
30 struct ValueEquals { | 29 struct ValueEquals { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } // namespace | 76 } // namespace |
78 | 77 |
79 ShillManagerClientStub::ShillManagerClientStub() | 78 ShillManagerClientStub::ShillManagerClientStub() |
80 : weak_ptr_factory_(this) { | 79 : weak_ptr_factory_(this) { |
81 } | 80 } |
82 | 81 |
83 ShillManagerClientStub::~ShillManagerClientStub() {} | 82 ShillManagerClientStub::~ShillManagerClientStub() {} |
84 | 83 |
85 // ShillManagerClient overrides. | 84 // ShillManagerClient overrides. |
86 | 85 |
87 void ShillManagerClientStub::Init(dbus::Bus* bus) { | 86 void ShillManagerClientStub::Init(dbus::Bus* bus) {} |
88 SetDefaultProperties(); | |
89 } | |
90 | 87 |
91 void ShillManagerClientStub::AddPropertyChangedObserver( | 88 void ShillManagerClientStub::AddPropertyChangedObserver( |
92 ShillPropertyChangedObserver* observer) { | 89 ShillPropertyChangedObserver* observer) { |
93 observer_list_.AddObserver(observer); | 90 observer_list_.AddObserver(observer); |
94 } | 91 } |
95 | 92 |
96 void ShillManagerClientStub::RemovePropertyChangedObserver( | 93 void ShillManagerClientStub::RemovePropertyChangedObserver( |
97 ShillPropertyChangedObserver* observer) { | 94 ShillPropertyChangedObserver* observer) { |
98 observer_list_.RemoveObserver(observer); | 95 observer_list_.RemoveObserver(observer); |
99 } | 96 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 const std::string& service_path) { | 481 const std::string& service_path) { |
485 // Remove and insert the service, moving it to the front of the watch list. | 482 // Remove and insert the service, moving it to the front of the watch list. |
486 GetListProperty(flimflam::kServiceWatchListProperty)->Remove( | 483 GetListProperty(flimflam::kServiceWatchListProperty)->Remove( |
487 base::StringValue(service_path), NULL); | 484 base::StringValue(service_path), NULL); |
488 GetListProperty(flimflam::kServiceWatchListProperty)->Insert( | 485 GetListProperty(flimflam::kServiceWatchListProperty)->Insert( |
489 0, base::Value::CreateStringValue(service_path)); | 486 0, base::Value::CreateStringValue(service_path)); |
490 CallNotifyObserversPropertyChanged( | 487 CallNotifyObserversPropertyChanged( |
491 flimflam::kServiceWatchListProperty, 0); | 488 flimflam::kServiceWatchListProperty, 0); |
492 } | 489 } |
493 | 490 |
494 void ShillManagerClientStub::SetDefaultProperties() { | |
495 // Stub Technologies. | |
496 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
497 chromeos::switches::kDisableStubEthernet)) { | |
498 AddTechnology(flimflam::kTypeEthernet, true); | |
499 } | |
500 AddTechnology(flimflam::kTypeWifi, true); | |
501 AddTechnology(flimflam::kTypeCellular, true); | |
502 AddTechnology(flimflam::kTypeWimax, true); | |
503 } | |
504 | |
505 void ShillManagerClientStub::PassStubProperties( | 491 void ShillManagerClientStub::PassStubProperties( |
506 const DictionaryValueCallback& callback) const { | 492 const DictionaryValueCallback& callback) const { |
507 scoped_ptr<base::DictionaryValue> stub_properties( | 493 scoped_ptr<base::DictionaryValue> stub_properties( |
508 stub_properties_.DeepCopy()); | 494 stub_properties_.DeepCopy()); |
509 // Remove disabled services from the list. | 495 // Remove disabled services from the list. |
510 stub_properties->SetWithoutPathExpansion( | 496 stub_properties->SetWithoutPathExpansion( |
511 flimflam::kServicesProperty, | 497 flimflam::kServicesProperty, |
512 GetEnabledServiceList(flimflam::kServicesProperty)); | 498 GetEnabledServiceList(flimflam::kServicesProperty)); |
513 stub_properties->SetWithoutPathExpansion( | 499 stub_properties->SetWithoutPathExpansion( |
514 flimflam::kServiceWatchListProperty, | 500 flimflam::kServiceWatchListProperty, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 flimflam::kScanningProperty, | 628 flimflam::kScanningProperty, |
643 base::FundamentalValue(false)); | 629 base::FundamentalValue(false)); |
644 } | 630 } |
645 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); | 631 CallNotifyObserversPropertyChanged(flimflam::kServicesProperty, 0); |
646 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, | 632 CallNotifyObserversPropertyChanged(flimflam::kServiceWatchListProperty, |
647 0); | 633 0); |
648 base::MessageLoop::current()->PostTask(FROM_HERE, callback); | 634 base::MessageLoop::current()->PostTask(FROM_HERE, callback); |
649 } | 635 } |
650 | 636 |
651 } // namespace chromeos | 637 } // namespace chromeos |
OLD | NEW |