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/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" |
11 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" | 11 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
12 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 12 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
13 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 13 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
14 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" | 14 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" |
15 #include "chromeos/login/user_names.h" | |
16 #include "components/user_manager/known_user.h" | 15 #include "components/user_manager/known_user.h" |
17 #include "components/user_manager/user_manager.h" | 16 #include "components/user_manager/user_manager.h" |
| 17 #include "components/user_manager/user_names.h" |
18 #include "crypto/random.h" | 18 #include "crypto/random.h" |
19 #include "google_apis/gaia/gaia_constants.h" | 19 #include "google_apis/gaia/gaia_constants.h" |
20 #include "google_apis/gaia/gaia_urls.h" | 20 #include "google_apis/gaia/gaia_urls.h" |
21 | 21 |
22 namespace chromeos { | 22 namespace chromeos { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 const int kMaxGaiaRetries = 5; | 26 const int kMaxGaiaRetries = 5; |
27 const int kUserKeyByteSize = 16; | 27 const int kUserKeyByteSize = 16; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 std::string email; | 171 std::string email; |
172 std::string gaia_id; | 172 std::string gaia_id; |
173 if (!user_info->GetString("email", &email) || | 173 if (!user_info->GetString("email", &email) || |
174 !user_info->GetString("id", &gaia_id)) { | 174 !user_info->GetString("id", &gaia_id)) { |
175 LOG(ERROR) << "Bad user info."; | 175 LOG(ERROR) << "Bad user info."; |
176 Notify(false); | 176 Notify(false); |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 user_context_.SetAccountId(user_manager::known_user::GetAccountId( | 180 user_context_.SetAccountId(user_manager::known_user::GetAccountId( |
181 login::CanonicalizeUserID(email), gaia_id)); | 181 user_manager::CanonicalizeUserID(email), gaia_id)); |
182 StartCheckExistingKeys(); | 182 StartCheckExistingKeys(); |
183 } | 183 } |
184 | 184 |
185 void BootstrapUserContextInitializer::OnOAuthError() { | 185 void BootstrapUserContextInitializer::OnOAuthError() { |
186 LOG(ERROR) << "Auth error."; | 186 LOG(ERROR) << "Auth error."; |
187 Notify(false); | 187 Notify(false); |
188 } | 188 } |
189 | 189 |
190 void BootstrapUserContextInitializer::OnNetworkError(int response_code) { | 190 void BootstrapUserContextInitializer::OnNetworkError(int response_code) { |
191 LOG(ERROR) << "Network error."; | 191 LOG(ERROR) << "Network error."; |
(...skipping 11 matching lines...) Expand all Loading... |
203 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); | 203 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); |
204 service->RemoveObserver(this); | 204 service->RemoveObserver(this); |
205 | 205 |
206 service->AttemptAuth( | 206 service->AttemptAuth( |
207 user_context_.GetAccountId(), | 207 user_context_.GetAccountId(), |
208 base::Bind(&BootstrapUserContextInitializer::OnEasyUnlockAuthenticated, | 208 base::Bind(&BootstrapUserContextInitializer::OnEasyUnlockAuthenticated, |
209 weak_ptr_factory_.GetWeakPtr())); | 209 weak_ptr_factory_.GetWeakPtr())); |
210 } | 210 } |
211 | 211 |
212 } // namespace chromeos | 212 } // namespace chromeos |
OLD | NEW |