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

Side by Side Diff: chrome/browser/chromeos/login/easy_unlock/bootstrap_user_context_initializer.cc

Issue 1425093004: Revert of 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: 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/chromeos/login/easy_unlock/bootstrap_user_context_initi alizer.h" 5 #include "chrome/browser/chromeos/login/easy_unlock/bootstrap_user_context_initi alizer.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 client_info.client_id = gaia_urls->oauth2_chrome_client_id(); 61 client_info.client_id = gaia_urls->oauth2_chrome_client_id();
62 client_info.client_secret = gaia_urls->oauth2_chrome_client_secret(); 62 client_info.client_secret = gaia_urls->oauth2_chrome_client_secret();
63 63
64 token_fetcher_.reset( 64 token_fetcher_.reset(
65 new gaia::GaiaOAuthClient(g_browser_process->system_request_context())); 65 new gaia::GaiaOAuthClient(g_browser_process->system_request_context()));
66 token_fetcher_->GetTokensFromAuthCode(client_info, auth_code, kMaxGaiaRetries, 66 token_fetcher_->GetTokensFromAuthCode(client_info, auth_code, kMaxGaiaRetries,
67 this); 67 this);
68 } 68 }
69 69
70 void BootstrapUserContextInitializer::StartCheckExistingKeys() { 70 void BootstrapUserContextInitializer::StartCheckExistingKeys() {
71 const std::string& user_id = user_context_.GetUserID();
72
71 // Use random key for the first time user. 73 // Use random key for the first time user.
72 if (!user_manager::UserManager::Get()->IsKnownUser( 74 if (!user_manager::UserManager::Get()->IsKnownUser(user_id)) {
73 user_context_.GetAccountId())) {
74 CreateRandomKey(); 75 CreateRandomKey();
75 return; 76 return;
76 } 77 }
77 78
78 EasyUnlockKeyManager* key_manager = 79 EasyUnlockKeyManager* key_manager =
79 UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); 80 UserSessionManager::GetInstance()->GetEasyUnlockKeyManager();
80 key_manager->GetDeviceDataList( 81 key_manager->GetDeviceDataList(
81 UserContext(user_context_.GetAccountId()), 82 UserContext(user_id),
82 base::Bind(&BootstrapUserContextInitializer::OnGetEasyUnlockData, 83 base::Bind(&BootstrapUserContextInitializer::OnGetEasyUnlockData,
83 weak_ptr_factory_.GetWeakPtr())); 84 weak_ptr_factory_.GetWeakPtr()));
84 } 85 }
85 86
86 void BootstrapUserContextInitializer::OnGetEasyUnlockData( 87 void BootstrapUserContextInitializer::OnGetEasyUnlockData(
87 bool success, 88 bool success,
88 const EasyUnlockDeviceKeyDataList& data_list) { 89 const EasyUnlockDeviceKeyDataList& data_list) {
89 // Existing user must have Smart lock keys to use bootstrap flow. 90 // Existing user must have Smart lock keys to use bootstrap flow.
90 if (!success || data_list.empty()) { 91 if (!success || data_list.empty()) {
91 LOG(ERROR) << "Unable to get Easy unlock key data."; 92 LOG(ERROR) << "Unable to get Easy unlock key data.";
92 Notify(false); 93 Notify(false);
93 return; 94 return;
94 } 95 }
95 96
96 EasyUnlockService* service = 97 EasyUnlockService* service =
97 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); 98 EasyUnlockService::Get(ProfileHelper::GetSigninProfile());
98 service->AddObserver(this); 99 service->AddObserver(this);
99 100
100 static_cast<EasyUnlockServiceSignin*>(service) 101 static_cast<EasyUnlockServiceSignin*>(service)
101 ->SetCurrentUser(user_context_.GetAccountId().GetUserEmail()); 102 ->SetCurrentUser(user_context_.GetUserID());
102 OnScreenlockStateChanged(service->GetScreenlockState()); 103 OnScreenlockStateChanged(service->GetScreenlockState());
103 } 104 }
104 105
105 void BootstrapUserContextInitializer::OnEasyUnlockAuthenticated( 106 void BootstrapUserContextInitializer::OnEasyUnlockAuthenticated(
106 EasyUnlockAuthAttempt::Type auth_attempt_type, 107 EasyUnlockAuthAttempt::Type auth_attempt_type,
107 bool success, 108 bool success,
108 const std::string& user_id, 109 const std::string& user_id,
109 const std::string& key_secret, 110 const std::string& key_secret,
110 const std::string& key_label) { 111 const std::string& key_label) {
111 DCHECK_EQ(EasyUnlockAuthAttempt::TYPE_SIGNIN, auth_attempt_type); 112 DCHECK_EQ(EasyUnlockAuthAttempt::TYPE_SIGNIN, auth_attempt_type);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // TODO(xiyuan): Add timeout and hook up with error UI after 196 // TODO(xiyuan): Add timeout and hook up with error UI after
196 // http://crbug.com/471067. 197 // http://crbug.com/471067.
197 if (state != proximity_auth::ScreenlockState::AUTHENTICATED) 198 if (state != proximity_auth::ScreenlockState::AUTHENTICATED)
198 return; 199 return;
199 200
200 EasyUnlockService* service = 201 EasyUnlockService* service =
201 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); 202 EasyUnlockService::Get(ProfileHelper::GetSigninProfile());
202 service->RemoveObserver(this); 203 service->RemoveObserver(this);
203 204
204 service->AttemptAuth( 205 service->AttemptAuth(
205 user_context_.GetAccountId().GetUserEmail(), 206 user_context_.GetUserID(),
206 base::Bind(&BootstrapUserContextInitializer::OnEasyUnlockAuthenticated, 207 base::Bind(&BootstrapUserContextInitializer::OnEasyUnlockAuthenticated,
207 weak_ptr_factory_.GetWeakPtr())); 208 weak_ptr_factory_.GetWeakPtr()));
208 } 209 }
209 210
210 } // namespace chromeos 211 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698