| 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/network_profile_handler.h" | 5 #include "chromeos/network/network_profile_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 const std::string& userhash) const { | 181 const std::string& userhash) const { |
| 182 for (NetworkProfileHandler::ProfileList::const_iterator it = | 182 for (NetworkProfileHandler::ProfileList::const_iterator it = |
| 183 profiles_.begin(); | 183 profiles_.begin(); |
| 184 it != profiles_.end(); ++it) { | 184 it != profiles_.end(); ++it) { |
| 185 if (it->userhash == userhash) | 185 if (it->userhash == userhash) |
| 186 return &*it; | 186 return &*it; |
| 187 } | 187 } |
| 188 return NULL; | 188 return NULL; |
| 189 } | 189 } |
| 190 | 190 |
| 191 const NetworkProfile* NetworkProfileHandler::GetDefaultUserProfile() const { |
| 192 for (NetworkProfileHandler::ProfileList::const_iterator it = |
| 193 profiles_.begin(); |
| 194 it != profiles_.end(); ++it) { |
| 195 if (!it->userhash.empty()) |
| 196 return &*it; |
| 197 } |
| 198 return NULL; |
| 199 } |
| 200 |
| 191 NetworkProfileHandler::NetworkProfileHandler() | 201 NetworkProfileHandler::NetworkProfileHandler() |
| 192 : network_state_handler_(NULL), | 202 : network_state_handler_(NULL), |
| 193 weak_ptr_factory_(this) { | 203 weak_ptr_factory_(this) { |
| 194 } | 204 } |
| 195 | 205 |
| 196 void NetworkProfileHandler::Init(NetworkStateHandler* network_state_handler) { | 206 void NetworkProfileHandler::Init(NetworkStateHandler* network_state_handler) { |
| 197 network_state_handler_ = network_state_handler; | 207 network_state_handler_ = network_state_handler; |
| 198 | 208 |
| 199 DBusThreadManager::Get()->GetShillManagerClient()-> | 209 DBusThreadManager::Get()->GetShillManagerClient()-> |
| 200 AddPropertyChangedObserver(this); | 210 AddPropertyChangedObserver(this); |
| 201 | 211 |
| 202 // Request the initial profile list. | 212 // Request the initial profile list. |
| 203 DBusThreadManager::Get()->GetShillManagerClient()->GetProperties( | 213 DBusThreadManager::Get()->GetShillManagerClient()->GetProperties( |
| 204 base::Bind(&NetworkProfileHandler::GetManagerPropertiesCallback, | 214 base::Bind(&NetworkProfileHandler::GetManagerPropertiesCallback, |
| 205 weak_ptr_factory_.GetWeakPtr())); | 215 weak_ptr_factory_.GetWeakPtr())); |
| 206 } | 216 } |
| 207 | 217 |
| 208 NetworkProfileHandler::~NetworkProfileHandler() { | 218 NetworkProfileHandler::~NetworkProfileHandler() { |
| 209 DBusThreadManager::Get()->GetShillManagerClient()-> | 219 DBusThreadManager::Get()->GetShillManagerClient()-> |
| 210 RemovePropertyChangedObserver(this); | 220 RemovePropertyChangedObserver(this); |
| 211 } | 221 } |
| 212 | 222 |
| 213 } // namespace chromeos | 223 } // namespace chromeos |
| OLD | NEW |