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

Unified Diff: chromeos/dbus/fake_shill_manager_client.cc

Issue 175243004: Chrome OS: Use Manager.DefaultService for Default Network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Set default path of '/' to empty Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/fake_shill_manager_client.cc
diff --git a/chromeos/dbus/fake_shill_manager_client.cc b/chromeos/dbus/fake_shill_manager_client.cc
index d3ad56641aa07e74879092b1a6ad95559420655a..2e306125f1632722ff483af14213b2c06602d7be 100644
--- a/chromeos/dbus/fake_shill_manager_client.cc
+++ b/chromeos/dbus/fake_shill_manager_client.cc
@@ -73,6 +73,11 @@ void AppendServicesForType(
}
}
+void LogErrorCallback(const std::string& error_name,
+ const std::string& error_message) {
+ LOG(ERROR) << error_name << ": " << error_message;
+}
+
} // namespace
FakeShillManagerClient::FakeShillManagerClient()
@@ -391,6 +396,12 @@ void FakeShillManagerClient::ClearProperties() {
stub_properties_.Clear();
}
+void FakeShillManagerClient::SetManagerProperty(const std::string& key,
+ const base::Value& value) {
+ SetProperty(key, value,
+ base::Bind(&base::DoNothing), base::Bind(&LogErrorCallback));
+}
+
void FakeShillManagerClient::AddManagerService(const std::string& service_path,
bool add_to_visible_list,
bool add_to_watch_list) {
@@ -440,8 +451,14 @@ void FakeShillManagerClient::SortManagerServices() {
shill::kTypeVPN
};
base::ListValue* service_list = GetListProperty(shill::kServicesProperty);
- if (!service_list || service_list->empty())
+ if (!service_list || service_list->empty()) {
+ if (!default_service_.empty()) {
+ default_service_.clear();
+ base::StringValue empty_value("");
+ SetManagerProperty(shill::kDefaultServiceProperty, empty_value);
+ }
return;
+ }
std::vector<std::string> active_services;
std::vector<std::string> inactive_services;
for (size_t i = 0; i < arraysize(ordered_types); ++i) {
@@ -455,6 +472,32 @@ void FakeShillManagerClient::SortManagerServices() {
service_list->AppendString(inactive_services[i]);
CallNotifyObserversPropertyChanged(shill::kServicesProperty, 0);
+
+ // Set the first active service as the Default service.
+ std::string new_default_service;
+ if (!active_services.empty()) {
+ ShillServiceClient::TestInterface* service_client =
+ DBusThreadManager::Get()->GetShillServiceClient()->GetTestInterface();
+ std::string service_path = active_services[0];
+ const base::DictionaryValue* properties =
+ service_client->GetServiceProperties(service_path);
+ if (!properties) {
+ LOG(ERROR) << "Properties not found for service: " << service_path;
+ } else {
+ std::string state;
+ properties->GetString(shill::kStateProperty, &state);
+ if (state == shill::kStateOnline ||
+ state == shill::kStatePortal ||
+ state == shill::kStateReady) {
+ new_default_service = service_path;
+ }
+ }
+ }
+ if (default_service_ != new_default_service) {
+ default_service_ = new_default_service;
+ base::StringValue default_service_value(default_service_);
+ SetManagerProperty(shill::kDefaultServiceProperty, default_service_value);
+ }
}
void FakeShillManagerClient::AddGeoNetwork(

Powered by Google App Engine
This is Rietveld 408576698