| OLD | NEW |
| 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 "chrome/browser/extensions/api/identity/account_tracker.h" | 5 #include "chrome/browser/extensions/api/identity/account_tracker.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 StopTrackingAccount(key); | 199 StopTrackingAccount(key); |
| 200 } | 200 } |
| 201 | 201 |
| 202 std::string AccountTracker::GetAccountId() const { | 202 std::string AccountTracker::GetAccountId() const { |
| 203 if (account_errors_.size() == 0) | 203 if (account_errors_.size() == 0) |
| 204 return std::string(); | 204 return std::string(); |
| 205 else | 205 else |
| 206 return account_errors_.begin()->first; | 206 return account_errors_.begin()->first; |
| 207 } | 207 } |
| 208 | 208 |
| 209 std::string AccountTracker::GetUsername() const { |
| 210 if (account_errors_.size() > 0) { |
| 211 std::map<std::string, AccountState>::const_iterator it = |
| 212 accounts_.find(account_errors_.begin()->first); |
| 213 if (it != accounts_.end()) |
| 214 return it->second.ids.email; |
| 215 } |
| 216 return std::string(); |
| 217 } |
| 218 |
| 209 GoogleServiceAuthError AccountTracker::GetAuthStatus() const { | 219 GoogleServiceAuthError AccountTracker::GetAuthStatus() const { |
| 210 if (account_errors_.size() == 0) | 220 if (account_errors_.size() == 0) |
| 211 return GoogleServiceAuthError::AuthErrorNone(); | 221 return GoogleServiceAuthError::AuthErrorNone(); |
| 212 else | 222 else |
| 213 return account_errors_.begin()->second; | 223 return account_errors_.begin()->second; |
| 214 } | 224 } |
| 215 | 225 |
| 216 void AccountTracker::DeleteFetcher(AccountIdFetcher* fetcher) { | 226 void AccountTracker::DeleteFetcher(AccountIdFetcher* fetcher) { |
| 217 const std::string& account_key = fetcher->account_key(); | 227 const std::string& account_key = fetcher->account_key(); |
| 218 DCHECK(ContainsKey(user_info_requests_, account_key)); | 228 DCHECK(ContainsKey(user_info_requests_, account_key)); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 LOG(ERROR) << "OnOAuthError"; | 277 LOG(ERROR) << "OnOAuthError"; |
| 268 tracker_->OnUserInfoFetchFailure(this); | 278 tracker_->OnUserInfoFetchFailure(this); |
| 269 } | 279 } |
| 270 | 280 |
| 271 void AccountIdFetcher::OnNetworkError(int response_code) { | 281 void AccountIdFetcher::OnNetworkError(int response_code) { |
| 272 LOG(ERROR) << "OnNetworkError " << response_code; | 282 LOG(ERROR) << "OnNetworkError " << response_code; |
| 273 tracker_->OnUserInfoFetchFailure(this); | 283 tracker_->OnUserInfoFetchFailure(this); |
| 274 } | 284 } |
| 275 | 285 |
| 276 } // namespace extensions | 286 } // namespace extensions |
| OLD | NEW |