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

Unified Diff: chrome/browser/signin/easy_unlock_service_signin_chromeos.cc

Issue 576383002: easy-signin: Wire GetSignInChallenge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase, add fake key Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_signin_chromeos.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/signin/easy_unlock_service_signin_chromeos.cc
diff --git a/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc b/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc
index d0c036bf6580139c6242d159b86f987c7206e810..51ec80ffdd9e474f4b15a6eafdd9e2d447d4b087 100644
--- a/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc
+++ b/chrome/browser/signin/easy_unlock_service_signin_chromeos.cc
@@ -4,20 +4,37 @@
#include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h"
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
+#include "chrome/browser/chromeos/login/session/user_session_manager.h"
+#include "chromeos/chromeos_switches.h"
+#include "chromeos/login/auth/user_context.h"
+
EasyUnlockServiceSignin::EasyUnlockServiceSignin(Profile* profile)
- : EasyUnlockService(profile) {
+ : EasyUnlockService(profile),
+ weak_ptr_factory_(this) {
}
EasyUnlockServiceSignin::~EasyUnlockServiceSignin() {
}
+void EasyUnlockServiceSignin::SetAssociatedUser(const std::string& user_id) {
+ if (user_id_ == user_id)
+ return;
+
+ user_id_ = user_id;
+ FetchCryptohomeKeys();
+}
+
EasyUnlockService::Type EasyUnlockServiceSignin::GetType() const {
return EasyUnlockService::TYPE_SIGNIN;
}
std::string EasyUnlockServiceSignin::GetUserEmail() const {
- // TODO(tbarzic): Implement this (http://crbug.com/401634).
- return "";
+ return user_id_;
}
void EasyUnlockServiceSignin::LaunchSetup() {
@@ -39,8 +56,7 @@ void EasyUnlockServiceSignin::ClearPermitAccess() {
}
const base::ListValue* EasyUnlockServiceSignin::GetRemoteDevices() const {
- // TODO(tbarzic): Implement this (http://crbug.com/401634).
- return NULL;
+ return remote_devices_value_.get();
}
void EasyUnlockServiceSignin::SetRemoteDevices(
@@ -65,11 +81,53 @@ EasyUnlockService::TurnOffFlowStatus
return EasyUnlockService::IDLE;
}
+std::string EasyUnlockServiceSignin::GetChallenge() const {
+ // TODO(xiyuan): Use correct remote device instead of hard coded first one.
+ size_t device_index = 0;
+ return device_index < remote_devices_.size()
+ ? remote_devices_[device_index].challenge
+ : std::string();
+}
+
void EasyUnlockServiceSignin::InitializeInternal() {
}
bool EasyUnlockServiceSignin::IsAllowedInternal() {
- // TODO(tbarzic): Implement this (http://crbug.com/401634).
- return false;
+ return !user_id_.empty() && !remote_devices_.empty() &&
+ CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableEasySignin);
+}
+
+void EasyUnlockServiceSignin::FetchCryptohomeKeys() {
+ remote_devices_.clear();
+ remote_devices_value_.reset();
+ if (user_id_.empty()) {
+ UpdateAppState();
+ return;
+ }
+
+ chromeos::EasyUnlockKeyManager* key_manager =
+ chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager();
+ DCHECK(key_manager);
+ key_manager->GetDeviceDataList(
+ chromeos::UserContext(user_id_),
+ base::Bind(&EasyUnlockServiceSignin::OnCryptohomeKeysFetched,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void EasyUnlockServiceSignin::OnCryptohomeKeysFetched(
+ bool success,
+ const chromeos::EasyUnlockDeviceKeyDataList& devices) {
+ if (!success) {
+ LOG(WARNING) << "Easy unlock cryptohome keys not found for user "
+ << user_id_;
+ return;
+ }
+
+ remote_devices_ = devices;
+ remote_devices_value_.reset(new base::ListValue);
+ chromeos::EasyUnlockKeyManager::DeviceDataListToRemoteDeviceList(
+ remote_devices_, remote_devices_value_.get());
+
+ UpdateAppState();
}
-
« no previous file with comments | « chrome/browser/signin/easy_unlock_service_signin_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698