| 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 "chrome/browser/signin/chrome_signin_client.h" | 5 #include "chrome/browser/signin/chrome_signin_client.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #else | 57 #else |
| 58 // UserManager may not exist in unit_tests. | 58 // UserManager may not exist in unit_tests. |
| 59 if (!user_manager::UserManager::IsInitialized()) | 59 if (!user_manager::UserManager::IsInitialized()) |
| 60 return; | 60 return; |
| 61 | 61 |
| 62 const user_manager::User* user = | 62 const user_manager::User* user = |
| 63 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); | 63 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); |
| 64 if (!user) | 64 if (!user) |
| 65 return; | 65 return; |
| 66 auto* user_manager = user_manager::UserManager::Get(); | 66 auto* user_manager = user_manager::UserManager::Get(); |
| 67 const std::string& user_id = user->GetUserID(); | 67 const AccountId user_id = user->GetAccountId(); |
| 68 if (user_manager->GetKnownUserDeviceId(user_id).empty()) { | 68 if (user_manager->GetKnownUserDeviceId(user_id).empty()) { |
| 69 const std::string legacy_device_id = | 69 const std::string legacy_device_id = |
| 70 GetPrefs()->GetString(prefs::kGoogleServicesSigninScopedDeviceId); | 70 GetPrefs()->GetString(prefs::kGoogleServicesSigninScopedDeviceId); |
| 71 if (!legacy_device_id.empty()) { | 71 if (!legacy_device_id.empty()) { |
| 72 // Need to move device ID from the old location to the new one, if it has | 72 // Need to move device ID from the old location to the new one, if it has |
| 73 // not been done yet. | 73 // not been done yet. |
| 74 user_manager->SetKnownUserDeviceId(user_id, legacy_device_id); | 74 user_manager->SetKnownUserDeviceId(user_id, legacy_device_id); |
| 75 } else { | 75 } else { |
| 76 user_manager->SetKnownUserDeviceId( | 76 user_manager->SetKnownUserDeviceId( |
| 77 user_id, | 77 user_id, |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // UserManager may not exist in unit_tests. | 147 // UserManager may not exist in unit_tests. |
| 148 if (!user_manager::UserManager::IsInitialized()) | 148 if (!user_manager::UserManager::IsInitialized()) |
| 149 return std::string(); | 149 return std::string(); |
| 150 | 150 |
| 151 const user_manager::User* user = | 151 const user_manager::User* user = |
| 152 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); | 152 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); |
| 153 if (!user) | 153 if (!user) |
| 154 return std::string(); | 154 return std::string(); |
| 155 | 155 |
| 156 const std::string signin_scoped_device_id = | 156 const std::string signin_scoped_device_id = |
| 157 user_manager::UserManager::Get()->GetKnownUserDeviceId(user->GetUserID()); | 157 user_manager::UserManager::Get()->GetKnownUserDeviceId( |
| 158 user->GetAccountId()); |
| 158 LOG_IF(ERROR, signin_scoped_device_id.empty()) | 159 LOG_IF(ERROR, signin_scoped_device_id.empty()) |
| 159 << "Device ID is not set for user."; | 160 << "Device ID is not set for user."; |
| 160 return signin_scoped_device_id; | 161 return signin_scoped_device_id; |
| 161 #endif | 162 #endif |
| 162 } | 163 } |
| 163 | 164 |
| 164 void ChromeSigninClient::OnSignedOut() { | 165 void ChromeSigninClient::OnSignedOut() { |
| 165 ProfileInfoCache& cache = | 166 ProfileInfoCache& cache = |
| 166 g_browser_process->profile_manager()->GetProfileInfoCache(); | 167 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 167 size_t index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); | 168 size_t index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 ProfileOAuth2TokenService* token_service = | 371 ProfileOAuth2TokenService* token_service = |
| 371 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); | 372 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); |
| 372 OAuth2TokenService::ScopeSet scopes; | 373 OAuth2TokenService::ScopeSet scopes; |
| 373 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); | 374 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); |
| 374 oauth_request_ = token_service->StartRequest(account_id, scopes, this); | 375 oauth_request_ = token_service->StartRequest(account_id, scopes, this); |
| 375 } | 376 } |
| 376 } | 377 } |
| 377 } | 378 } |
| 378 #endif | 379 #endif |
| 379 } | 380 } |
| OLD | NEW |