| 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" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 LOG(ERROR) << "Unable to get Easy unlock key data."; | 91 LOG(ERROR) << "Unable to get Easy unlock key data."; |
| 92 Notify(false); | 92 Notify(false); |
| 93 return; | 93 return; |
| 94 } | 94 } |
| 95 | 95 |
| 96 EasyUnlockService* service = | 96 EasyUnlockService* service = |
| 97 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); | 97 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); |
| 98 service->AddObserver(this); | 98 service->AddObserver(this); |
| 99 | 99 |
| 100 static_cast<EasyUnlockServiceSignin*>(service) | 100 static_cast<EasyUnlockServiceSignin*>(service) |
| 101 ->SetCurrentUser(user_context_.GetAccountId().GetUserEmail()); | 101 ->SetCurrentUser(user_context_.GetAccountId()); |
| 102 OnScreenlockStateChanged(service->GetScreenlockState()); | 102 OnScreenlockStateChanged(service->GetScreenlockState()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void BootstrapUserContextInitializer::OnEasyUnlockAuthenticated( | 105 void BootstrapUserContextInitializer::OnEasyUnlockAuthenticated( |
| 106 EasyUnlockAuthAttempt::Type auth_attempt_type, | 106 EasyUnlockAuthAttempt::Type auth_attempt_type, |
| 107 bool success, | 107 bool success, |
| 108 const std::string& user_id, | 108 const AccountId& account_id, |
| 109 const std::string& key_secret, | 109 const std::string& key_secret, |
| 110 const std::string& key_label) { | 110 const std::string& key_label) { |
| 111 DCHECK_EQ(EasyUnlockAuthAttempt::TYPE_SIGNIN, auth_attempt_type); | 111 DCHECK_EQ(EasyUnlockAuthAttempt::TYPE_SIGNIN, auth_attempt_type); |
| 112 if (!success || key_secret.empty()) { | 112 if (!success || key_secret.empty()) { |
| 113 LOG(ERROR) << "Failed to sign-in using existing Smart lock key."; | 113 LOG(ERROR) << "Failed to sign-in using existing Smart lock key."; |
| 114 Notify(false); | 114 Notify(false); |
| 115 return; | 115 return; |
| 116 } | 116 } |
| 117 | 117 |
| 118 user_context_.SetKey(Key(key_secret)); | 118 user_context_.SetKey(Key(key_secret)); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // TODO(xiyuan): Add timeout and hook up with error UI after | 195 // TODO(xiyuan): Add timeout and hook up with error UI after |
| 196 // http://crbug.com/471067. | 196 // http://crbug.com/471067. |
| 197 if (state != proximity_auth::ScreenlockState::AUTHENTICATED) | 197 if (state != proximity_auth::ScreenlockState::AUTHENTICATED) |
| 198 return; | 198 return; |
| 199 | 199 |
| 200 EasyUnlockService* service = | 200 EasyUnlockService* service = |
| 201 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); | 201 EasyUnlockService::Get(ProfileHelper::GetSigninProfile()); |
| 202 service->RemoveObserver(this); | 202 service->RemoveObserver(this); |
| 203 | 203 |
| 204 service->AttemptAuth( | 204 service->AttemptAuth( |
| 205 user_context_.GetAccountId().GetUserEmail(), | 205 user_context_.GetAccountId(), |
| 206 base::Bind(&BootstrapUserContextInitializer::OnEasyUnlockAuthenticated, | 206 base::Bind(&BootstrapUserContextInitializer::OnEasyUnlockAuthenticated, |
| 207 weak_ptr_factory_.GetWeakPtr())); | 207 weak_ptr_factory_.GetWeakPtr())); |
| 208 } | 208 } |
| 209 | 209 |
| 210 } // namespace chromeos | 210 } // namespace chromeos |
| OLD | NEW |