Commit 55c68a9a authored by estade's avatar estade Committed by Commit bot

Revert of Move token handle obtaining to UserSessionManager (patchset #1 id:1...

Revert of Move token handle obtaining to UserSessionManager (patchset #1 id:1 of https://codereview.chromium.org/1129293004/)

Reason for revert:
most likely culprit for interactive ui test failures here: https://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%281%29/builds/2847

Original issue's description:
> Move token handle obtaining to UserSessionManager
>
> BUG=484690,484734
> R=nkostylev@chromium.org
>
> Committed: https://crrev.com/71ede7fdaf6404ec0f70a60d60f679fee07902a9
> Cr-Commit-Position: refs/heads/master@{#329868}

TBR=nkostylev@chromium.org,antrim@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=484690,484734

Review URL: https://codereview.chromium.org/1140823007

Cr-Commit-Position: refs/heads/master@{#329891}
parent b07c0553
...@@ -1236,8 +1236,38 @@ void ExistingUserController::OnOAuth2TokensFetched( ...@@ -1236,8 +1236,38 @@ void ExistingUserController::OnOAuth2TokensFetched(
OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN)); OnAuthFailure(AuthFailure(AuthFailure::FAILED_TO_INITIALIZE_TOKEN));
return; return;
} }
UserSessionManager::GetInstance()->OnOAuth2TokensFetched(user_context); if (StartupUtils::IsWebviewSigninEnabled() && TokenHandlesEnabled()) {
if (!token_handle_util_.get()) {
token_handle_util_.reset(
new TokenHandleUtil(user_manager::UserManager::Get()));
}
if (token_handle_util_->ShouldObtainHandle(user_context.GetUserID())) {
token_handle_util_->GetTokenHandle(
user_context.GetUserID(), user_context.GetAccessToken(),
base::Bind(&ExistingUserController::OnTokenHandleObtained,
weak_factory_.GetWeakPtr()));
}
}
PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION); PerformLogin(user_context, LoginPerformer::AUTH_MODE_EXTENSION);
} }
void ExistingUserController::OnTokenHandleObtained(
const user_manager::UserID& id,
TokenHandleUtil::TokenHandleStatus status) {
if (status != TokenHandleUtil::VALID) {
LOG(ERROR) << "OAuth2 token handle fetch failed.";
return;
}
}
bool ExistingUserController::TokenHandlesEnabled() {
bool ephemeral_users_enabled = false;
bool show_names_on_signin = true;
cros_settings_->GetBoolean(kAccountsPrefEphemeralUsersEnabled,
&ephemeral_users_enabled);
cros_settings_->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
&show_names_on_signin);
return show_names_on_signin && !ephemeral_users_enabled;
}
} // namespace chromeos } // namespace chromeos
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
#include "chrome/browser/chromeos/login/session/user_session_manager.h" #include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/login/signin/token_handle_util.h"
#include "chrome/browser/chromeos/login/ui/login_display.h" #include "chrome/browser/chromeos/login/ui/login_display.h"
#include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/device_settings_service.h" #include "chrome/browser/chromeos/settings/device_settings_service.h"
...@@ -242,6 +243,13 @@ class ExistingUserController : public LoginDisplay::Delegate, ...@@ -242,6 +243,13 @@ class ExistingUserController : public LoginDisplay::Delegate,
// Callback invoked when |oauth2_token_initializer_| has finished. // Callback invoked when |oauth2_token_initializer_| has finished.
void OnOAuth2TokensFetched(bool success, const UserContext& user_context); void OnOAuth2TokensFetched(bool success, const UserContext& user_context);
// Callback invoked when |token_handle_util_| has finished.
void OnTokenHandleObtained(const user_manager::UserID& id,
TokenHandleUtil::TokenHandleStatus status);
// Returns |true| if token handles should be used on this device.
bool TokenHandlesEnabled();
// Public session auto-login timer. // Public session auto-login timer.
scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_; scoped_ptr<base::OneShotTimer<ExistingUserController> > auto_login_timer_;
...@@ -330,6 +338,7 @@ class ExistingUserController : public LoginDisplay::Delegate, ...@@ -330,6 +338,7 @@ class ExistingUserController : public LoginDisplay::Delegate,
bootstrap_user_context_initializer_; bootstrap_user_context_initializer_;
scoped_ptr<OAuth2TokenInitializer> oauth2_token_initializer_; scoped_ptr<OAuth2TokenInitializer> oauth2_token_initializer_;
scoped_ptr<TokenHandleUtil> token_handle_util_;
FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin); FRIEND_TEST_ALL_PREFIXES(ExistingUserControllerTest, ExistingUserLogin);
......
...@@ -1672,39 +1672,4 @@ void UserSessionManager::SendUserPodsMetrics() { ...@@ -1672,39 +1672,4 @@ void UserSessionManager::SendUserPodsMetrics() {
NUM_USER_PODS_DISPLAY); NUM_USER_PODS_DISPLAY);
} }
void UserSessionManager::OnOAuth2TokensFetched(UserContext context) {
if (StartupUtils::IsWebviewSigninEnabled() && TokenHandlesEnabled()) {
if (!token_handle_util_.get()) {
token_handle_util_.reset(
new TokenHandleUtil(user_manager::UserManager::Get()));
}
if (token_handle_util_->ShouldObtainHandle(context.GetUserID())) {
token_handle_util_->GetTokenHandle(
context.GetUserID(), context.GetAccessToken(),
base::Bind(&UserSessionManager::OnTokenHandleObtained,
weak_factory_.GetWeakPtr()));
}
}
}
void UserSessionManager::OnTokenHandleObtained(
const user_manager::UserID& id,
TokenHandleUtil::TokenHandleStatus status) {
if (status != TokenHandleUtil::VALID) {
LOG(ERROR) << "OAuth2 token handle fetch failed.";
return;
}
}
bool UserSessionManager::TokenHandlesEnabled() {
bool ephemeral_users_enabled = false;
bool show_names_on_signin = true;
auto cros_settings = CrosSettings::Get();
cros_settings->GetBoolean(kAccountsPrefEphemeralUsersEnabled,
&ephemeral_users_enabled);
cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn,
&show_names_on_signin);
return show_names_on_signin && !ephemeral_users_enabled;
}
} // namespace chromeos } // namespace chromeos
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "chrome/browser/chromeos/base/locale_util.h" #include "chrome/browser/chromeos/base/locale_util.h"
#include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h"
#include "chrome/browser/chromeos/login/signin/token_handle_util.h"
#include "chromeos/dbus/session_manager_client.h" #include "chromeos/dbus/session_manager_client.h"
#include "chromeos/login/auth/authenticator.h" #include "chromeos/login/auth/authenticator.h"
#include "chromeos/login/auth/user_context.h" #include "chromeos/login/auth/user_context.h"
...@@ -219,9 +218,6 @@ class UserSessionManager ...@@ -219,9 +218,6 @@ class UserSessionManager
void ActiveUserChanged(const user_manager::User* active_user) override; void ActiveUserChanged(const user_manager::User* active_user) override;
// This method will be called when user have obtained oauth2 tokens.
void OnOAuth2TokensFetched(UserContext context);
// Returns default IME state for user session. // Returns default IME state for user session.
scoped_refptr<input_method::InputMethodManager::State> GetDefaultIMEState( scoped_refptr<input_method::InputMethodManager::State> GetDefaultIMEState(
Profile* profile); Profile* profile);
...@@ -364,13 +360,6 @@ class UserSessionManager ...@@ -364,13 +360,6 @@ class UserSessionManager
InputEventsBlocker* input_events_blocker, InputEventsBlocker* input_events_blocker,
const locale_util::LanguageSwitchResult& result); const locale_util::LanguageSwitchResult& result);
// Callback invoked when |token_handle_util_| has finished.
void OnTokenHandleObtained(const user_manager::UserID& id,
TokenHandleUtil::TokenHandleStatus status);
// Returns |true| if token handles should be used on this device.
bool TokenHandlesEnabled();
// Test API methods. // Test API methods.
// Injects |user_context| that will be used to create StubAuthenticator // Injects |user_context| that will be used to create StubAuthenticator
...@@ -455,8 +444,6 @@ class UserSessionManager ...@@ -455,8 +444,6 @@ class UserSessionManager
bool running_easy_unlock_key_ops_; bool running_easy_unlock_key_ops_;
base::Closure easy_unlock_key_ops_finished_callback_; base::Closure easy_unlock_key_ops_finished_callback_;
scoped_ptr<TokenHandleUtil> token_handle_util_;
// Whether should launch browser, tests may override this value. // Whether should launch browser, tests may override this value.
bool should_launch_browser_; bool should_launch_browser_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment