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/network/geolocation_handler.h" | 5 #include "chromeos/network/geolocation_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 HandlePropertyChanged(key, value); | 57 HandlePropertyChanged(key, value); |
58 } | 58 } |
59 | 59 |
60 //------------------------------------------------------------------------------ | 60 //------------------------------------------------------------------------------ |
61 // Private methods | 61 // Private methods |
62 | 62 |
63 void GeolocationHandler::ManagerPropertiesCallback( | 63 void GeolocationHandler::ManagerPropertiesCallback( |
64 DBusMethodCallStatus call_status, | 64 DBusMethodCallStatus call_status, |
65 const base::DictionaryValue& properties) { | 65 const base::DictionaryValue& properties) { |
66 const base::Value* value = NULL; | 66 const base::Value* value = NULL; |
67 if (properties.Get(flimflam::kEnabledTechnologiesProperty, &value) && value) | 67 if (properties.Get(shill::kEnabledTechnologiesProperty, &value) && value) |
68 HandlePropertyChanged(flimflam::kEnabledTechnologiesProperty, *value); | 68 HandlePropertyChanged(shill::kEnabledTechnologiesProperty, *value); |
69 } | 69 } |
70 | 70 |
71 void GeolocationHandler::HandlePropertyChanged(const std::string& key, | 71 void GeolocationHandler::HandlePropertyChanged(const std::string& key, |
72 const base::Value& value) { | 72 const base::Value& value) { |
73 if (key != flimflam::kEnabledTechnologiesProperty) | 73 if (key != shill::kEnabledTechnologiesProperty) |
74 return; | 74 return; |
75 const base::ListValue* technologies = NULL; | 75 const base::ListValue* technologies = NULL; |
76 if (!value.GetAsList(&technologies) || !technologies) | 76 if (!value.GetAsList(&technologies) || !technologies) |
77 return; | 77 return; |
78 bool wifi_was_enabled = wifi_enabled_; | 78 bool wifi_was_enabled = wifi_enabled_; |
79 wifi_enabled_ = false; | 79 wifi_enabled_ = false; |
80 for (base::ListValue::const_iterator iter = technologies->begin(); | 80 for (base::ListValue::const_iterator iter = technologies->begin(); |
81 iter != technologies->end(); ++iter) { | 81 iter != technologies->end(); ++iter) { |
82 std::string technology; | 82 std::string technology; |
83 (*iter)->GetAsString(&technology); | 83 (*iter)->GetAsString(&technology); |
84 if (technology == flimflam::kTypeWifi) { | 84 if (technology == shill::kTypeWifi) { |
85 wifi_enabled_ = true; | 85 wifi_enabled_ = true; |
86 break; | 86 break; |
87 } | 87 } |
88 } | 88 } |
89 if (!wifi_was_enabled && wifi_enabled_) | 89 if (!wifi_was_enabled && wifi_enabled_) |
90 RequestWifiAccessPoints(); // Request initial location data. | 90 RequestWifiAccessPoints(); // Request initial location data. |
91 } | 91 } |
92 | 92 |
93 void GeolocationHandler::RequestWifiAccessPoints() { | 93 void GeolocationHandler::RequestWifiAccessPoints() { |
94 DBusThreadManager::Get()->GetShillManagerClient()->GetNetworksForGeolocation( | 94 DBusThreadManager::Get()->GetShillManagerClient()->GetNetworksForGeolocation( |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 std::string channel_str; | 142 std::string channel_str; |
143 if (entry->GetString(shill::kGeoChannelProperty, &channel_str)) | 143 if (entry->GetString(shill::kGeoChannelProperty, &channel_str)) |
144 base::StringToInt(channel_str, &wap.channel); | 144 base::StringToInt(channel_str, &wap.channel); |
145 wifi_access_points_.push_back(wap); | 145 wifi_access_points_.push_back(wap); |
146 } | 146 } |
147 } | 147 } |
148 geolocation_received_time_ = base::Time::Now(); | 148 geolocation_received_time_ = base::Time::Now(); |
149 } | 149 } |
150 | 150 |
151 } // namespace chromeos | 151 } // namespace chromeos |
OLD | NEW |