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

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

Issue 1534173003: ChromeOS user_manager: move all KnownUser code to separate file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/FindUsingSAML/IsUsingSAML/ Created 5 years 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 21 matching lines...) Expand all
32 #include "net/url_request/url_request_context_getter.h" 32 #include "net/url_request/url_request_context_getter.h"
33 #include "url/gurl.h" 33 #include "url/gurl.h"
34 34
35 #if defined(ENABLE_SUPERVISED_USERS) 35 #if defined(ENABLE_SUPERVISED_USERS)
36 #include "chrome/browser/supervised_user/supervised_user_constants.h" 36 #include "chrome/browser/supervised_user/supervised_user_constants.h"
37 #endif 37 #endif
38 38
39 #if defined(OS_CHROMEOS) 39 #if defined(OS_CHROMEOS)
40 #include "chrome/browser/chromeos/net/delay_network_call.h" 40 #include "chrome/browser/chromeos/net/delay_network_call.h"
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" 41 #include "chrome/browser/chromeos/profiles/profile_helper.h"
42 #include "components/user_manager/known_user.h"
42 #include "components/user_manager/user_manager.h" 43 #include "components/user_manager/user_manager.h"
43 #endif 44 #endif
44 45
45 #if !defined(OS_ANDROID) 46 #if !defined(OS_ANDROID)
46 #include "chrome/browser/first_run/first_run.h" 47 #include "chrome/browser/first_run/first_run.h"
47 #endif 48 #endif
48 49
49 ChromeSigninClient::ChromeSigninClient( 50 ChromeSigninClient::ChromeSigninClient(
50 Profile* profile, SigninErrorController* signin_error_controller) 51 Profile* profile, SigninErrorController* signin_error_controller)
51 : OAuth2TokenService::Consumer("chrome_signin_client"), 52 : OAuth2TokenService::Consumer("chrome_signin_client"),
52 profile_(profile), 53 profile_(profile),
53 signin_error_controller_(signin_error_controller) { 54 signin_error_controller_(signin_error_controller) {
54 signin_error_controller_->AddObserver(this); 55 signin_error_controller_->AddObserver(this);
55 #if !defined(OS_CHROMEOS) 56 #if !defined(OS_CHROMEOS)
56 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); 57 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
57 #else 58 #else
58 // UserManager may not exist in unit_tests. 59 // UserManager may not exist in unit_tests.
59 if (!user_manager::UserManager::IsInitialized()) 60 if (!user_manager::UserManager::IsInitialized())
60 return; 61 return;
61 62
62 const user_manager::User* user = 63 const user_manager::User* user =
63 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_); 64 chromeos::ProfileHelper::Get()->GetUserByProfile(profile_);
64 if (!user) 65 if (!user)
65 return; 66 return;
66 auto* user_manager = user_manager::UserManager::Get();
67 const AccountId account_id = user->GetAccountId(); 67 const AccountId account_id = user->GetAccountId();
68 if (user_manager->GetKnownUserDeviceId(account_id).empty()) { 68 if (user_manager::known_user::GetDeviceId(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(account_id, legacy_device_id); 74 user_manager::known_user::SetDeviceId(account_id, legacy_device_id);
75 } else { 75 } else {
76 user_manager->SetKnownUserDeviceId( 76 user_manager::known_user::SetDeviceId(
77 account_id, 77 account_id, GenerateSigninScopedDeviceID(
78 GenerateSigninScopedDeviceID( 78 user_manager::UserManager::Get()
79 user_manager->IsUserNonCryptohomeDataEphemeral(account_id))); 79 ->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( 157 user_manager::known_user::GetDeviceId(user->GetAccountId());
158 user->GetAccountId());
159 LOG_IF(ERROR, signin_scoped_device_id.empty()) 158 LOG_IF(ERROR, signin_scoped_device_id.empty())
160 << "Device ID is not set for user."; 159 << "Device ID is not set for user.";
161 return signin_scoped_device_id; 160 return signin_scoped_device_id;
162 #endif 161 #endif
163 } 162 }
164 163
165 void ChromeSigninClient::OnSignedOut() { 164 void ChromeSigninClient::OnSignedOut() {
166 ProfileInfoCache& cache = 165 ProfileInfoCache& cache =
167 g_browser_process->profile_manager()->GetProfileInfoCache(); 166 g_browser_process->profile_manager()->GetProfileInfoCache();
168 size_t index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); 167 size_t index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 ProfileOAuth2TokenService* token_service = 370 ProfileOAuth2TokenService* token_service =
372 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 371 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
373 OAuth2TokenService::ScopeSet scopes; 372 OAuth2TokenService::ScopeSet scopes;
374 scopes.insert(GaiaConstants::kGoogleUserInfoEmail); 373 scopes.insert(GaiaConstants::kGoogleUserInfoEmail);
375 oauth_request_ = token_service->StartRequest(account_id, scopes, this); 374 oauth_request_ = token_service->StartRequest(account_id, scopes, this);
376 } 375 }
377 } 376 }
378 } 377 }
379 #endif 378 #endif
380 } 379 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/preferences.cc ('k') | chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698