| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/signin/core/browser/account_tracker_service.h" | 5 #include "components/signin/core/browser/account_tracker_service.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "components/signin/core/browser/signin_manager.h" | 11 #include "components/signin/core/browser/signin_manager.h" |
| 12 #include "components/signin/core/common/signin_pref_names.h" |
| 12 #include "google_apis/gaia/gaia_auth_util.h" | 13 #include "google_apis/gaia/gaia_auth_util.h" |
| 13 #include "google_apis/gaia/gaia_constants.h" | 14 #include "google_apis/gaia/gaia_constants.h" |
| 14 #include "google_apis/gaia/gaia_oauth_client.h" | 15 #include "google_apis/gaia/gaia_oauth_client.h" |
| 15 #include "google_apis/gaia/oauth2_token_service.h" | 16 #include "google_apis/gaia/oauth2_token_service.h" |
| 16 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 const char kAccountKeyPath[] = "account_id"; | 21 const char kAccountKeyPath[] = "account_id"; |
| 21 const char kAccountEmailPath[] = "email"; | 22 const char kAccountEmailPath[] = "email"; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 it != accounts_.end(); | 236 it != accounts_.end(); |
| 236 ++it) { | 237 ++it) { |
| 237 const AccountState& state = it->second; | 238 const AccountState& state = it->second; |
| 238 if (gaia::AreEmailsSame(state.info.email, email)) | 239 if (gaia::AreEmailsSame(state.info.email, email)) |
| 239 return state.info; | 240 return state.info; |
| 240 } | 241 } |
| 241 | 242 |
| 242 return AccountInfo(); | 243 return AccountInfo(); |
| 243 } | 244 } |
| 244 | 245 |
| 246 AccountTrackerService::AccountIdMigrationState |
| 247 AccountTrackerService::GetMigrationState() { |
| 248 return GetMigrationState(pref_service_); |
| 249 } |
| 250 |
| 251 // static |
| 252 AccountTrackerService::AccountIdMigrationState |
| 253 AccountTrackerService::GetMigrationState(PrefService* pref_service) { |
| 254 return static_cast<AccountTrackerService::AccountIdMigrationState>( |
| 255 pref_service->GetInteger(prefs::kAccountIdMigrationState)); |
| 256 } |
| 257 |
| 245 void AccountTrackerService::OnRefreshTokenAvailable( | 258 void AccountTrackerService::OnRefreshTokenAvailable( |
| 246 const std::string& account_id) { | 259 const std::string& account_id) { |
| 247 TRACE_EVENT1("AccountTrackerService", | 260 TRACE_EVENT1("AccountTrackerService", |
| 248 "AccountTracker::OnRefreshTokenAvailable", | 261 "AccountTracker::OnRefreshTokenAvailable", |
| 249 "account_id", | 262 "account_id", |
| 250 account_id); | 263 account_id); |
| 251 DVLOG(1) << "AVAILABLE " << account_id; | 264 DVLOG(1) << "AVAILABLE " << account_id; |
| 252 | 265 |
| 253 StartTrackingAccount(account_id); | 266 StartTrackingAccount(account_id); |
| 254 AccountState& state = accounts_[account_id]; | 267 AccountState& state = accounts_[account_id]; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 435 } |
| 423 } | 436 } |
| 424 | 437 |
| 425 void AccountTrackerService::LoadFromTokenService() { | 438 void AccountTrackerService::LoadFromTokenService() { |
| 426 std::vector<std::string> accounts = token_service_->GetAccounts(); | 439 std::vector<std::string> accounts = token_service_->GetAccounts(); |
| 427 for (std::vector<std::string>::const_iterator it = accounts.begin(); | 440 for (std::vector<std::string>::const_iterator it = accounts.begin(); |
| 428 it != accounts.end(); ++it) { | 441 it != accounts.end(); ++it) { |
| 429 OnRefreshTokenAvailable(*it); | 442 OnRefreshTokenAvailable(*it); |
| 430 } | 443 } |
| 431 } | 444 } |
| OLD | NEW |