Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: chrome/browser/signin/chrome_signin_client.cc

Issue 1412813003: This CL replaces user_manager::UserID with AccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@468875--Chrome-OS-handles-deletion-of-Gmail-account-poorly--Create-AccountID-structure-part2--user_names
Patch Set: Fix Win GN build. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 account_id = user->GetAccountId();
68 if (user_manager->GetKnownUserDeviceId(user_id).empty()) { 68 if (user_manager->GetKnownUserDeviceId(account_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(account_id, legacy_device_id);
75 } else { 75 } else {
76 user_manager->SetKnownUserDeviceId( 76 user_manager->SetKnownUserDeviceId(
77 user_id, 77 account_id,
78 GenerateSigninScopedDeviceID( 78 GenerateSigninScopedDeviceID(
79 user_manager->IsUserNonCryptohomeDataEphemeral(user_id))); 79 user_manager->IsUserNonCryptohomeDataEphemeral(account_id)));
80 } 80 }
81 } 81 }
82 GetPrefs()->SetString(prefs::kGoogleServicesSigninScopedDeviceId, 82 GetPrefs()->SetString(prefs::kGoogleServicesSigninScopedDeviceId,
83 std::string()); 83 std::string());
84 #endif 84 #endif
85 } 85 }
86 86
87 ChromeSigninClient::~ChromeSigninClient() { 87 ChromeSigninClient::~ChromeSigninClient() {
88 signin_error_controller_->RemoveObserver(this); 88 signin_error_controller_->RemoveObserver(this);
89 } 89 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698