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

Unified Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 599263002: easy-signin: Defer chrome restart until key ops finish. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: only defer restart 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/chromeos/login/session/user_session_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/session/user_session_manager.cc
diff --git a/chrome/browser/chromeos/login/session/user_session_manager.cc b/chrome/browser/chromeos/login/session/user_session_manager.cc
index bd6bfa911d1ae6f8d6ed823ad18abc310e139370..326918f48e439500dd0dbf619540d7108a336076 100644
--- a/chrome/browser/chromeos/login/session/user_session_manager.cc
+++ b/chrome/browser/chromeos/login/session/user_session_manager.cc
@@ -222,7 +222,8 @@ UserSessionManager::UserSessionManager()
user_sessions_restored_(false),
exit_after_session_restore_(false),
session_restore_strategy_(
- OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN) {
+ OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN),
+ running_easy_unlock_key_ops_(false) {
net::NetworkChangeNotifier::AddConnectionTypeObserver(this);
user_manager::UserManager::Get()->AddSessionStateObserver(this);
}
@@ -442,6 +443,25 @@ bool UserSessionManager::RespectLocalePreference(
return true;
}
+bool UserSessionManager::NeedsToUpdateEasyUnlockKeys() const {
+ return CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableEasySignin) &&
+ !user_context_.GetUserID().empty() &&
+ user_context_.GetUserType() == user_manager::USER_TYPE_REGULAR &&
+ user_context_.GetKey() && !user_context_.GetKey()->GetSecret().empty();
+}
+
+bool UserSessionManager::CheckEasyUnlockKeyOps(const base::Closure& callback) {
+ if (!running_easy_unlock_key_ops_)
+ return false;
+
+ // Assumes only one deferred callback is needed.
+ DCHECK(easy_unlock_key_ops_finished_callback_.is_null());
+
+ easy_unlock_key_ops_finished_callback_ = callback;
+ return true;
+}
+
void UserSessionManager::AddSessionStateObserver(
chromeos::UserSessionStateObserver* observer) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
@@ -786,6 +806,9 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) {
InitializeCRLSetFetcher(user);
}
+ UpdateEasyUnlockKeys(profile);
+ user_context_.ClearSecrets();
+
// TODO(nkostylev): This pointer should probably never be NULL, but it looks
// like LoginUtilsImpl::OnProfileCreated() may be getting called before
// UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is
@@ -794,9 +817,6 @@ void UserSessionManager::FinalizePrepareProfile(Profile* profile) {
// resolved.
if (delegate_)
delegate_->OnProfilePrepared(profile);
-
- UpdateEasyUnlockKeys(profile);
- user_context_.ClearSecrets();
}
void UserSessionManager::InitSessionRestoreStrategy() {
@@ -1020,17 +1040,28 @@ void UserSessionManager::UpdateEasyUnlockKeys(Profile* user_profile) {
if (EasyUnlockService::Get(user_profile))
device_list = EasyUnlockService::Get(user_profile)->GetRemoteDevices();
+ running_easy_unlock_key_ops_ = true;
if (device_list) {
easy_unlock_key_manager_->RefreshKeys(
user_context_,
*device_list,
- EasyUnlockKeyManager::RefreshKeysCallback());
+ base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished,
+ AsWeakPtr()));
} else {
easy_unlock_key_manager_->RemoveKeys(
- user_context_, 0, EasyUnlockKeyManager::RemoveKeysCallback());
+ user_context_,
+ 0,
+ base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished,
+ AsWeakPtr()));
}
}
+void UserSessionManager::OnEasyUnlockKeyOpsFinished(bool success) {
+ running_easy_unlock_key_ops_ = false;
+ if (!easy_unlock_key_ops_finished_callback_.is_null())
+ easy_unlock_key_ops_finished_callback_.Run();
+}
+
void UserSessionManager::ActiveUserChanged(
const user_manager::User* active_user) {
Profile* profile = ProfileHelper::Get()->GetProfileByUser(active_user);
« no previous file with comments | « chrome/browser/chromeos/login/session/user_session_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698