Commit 0d14f168 authored by xiyuan@chromium.org's avatar xiyuan@chromium.org

[ChromeOS] Always fetch oauth cooken when signing in via extension.

BUG=chromium-os:18701,chromium-os:18994
TEST=Verify fix for chromium-os:18701 and chromium-os:18994.


Review URL: http://codereview.chromium.org/7639004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96525 0039d316-1c4b-4281-b951-d872f2087c98
parent 74f31070
...@@ -682,6 +682,7 @@ class StubLogin : public chromeos::LoginStatusConsumer, ...@@ -682,6 +682,7 @@ class StubLogin : public chromeos::LoginStatusConsumer,
credentials, credentials,
pending_requests, pending_requests,
using_oauth, using_oauth,
false,
this); this);
} }
......
...@@ -344,6 +344,9 @@ void ExistingUserController::OnLoginSuccess( ...@@ -344,6 +344,9 @@ void ExistingUserController::OnLoginSuccess(
two_factor_credentials_ = credentials.two_factor; two_factor_credentials_ = credentials.two_factor;
bool has_cookies =
login_performer_->auth_mode() == LoginPerformer::AUTH_MODE_EXTENSION;
// LoginPerformer instance will delete itself once online auth result is OK. // LoginPerformer instance will delete itself once online auth result is OK.
// In case of failure it'll bring up ScreenLock and ask for // In case of failure it'll bring up ScreenLock and ask for
// correct password/display error message. // correct password/display error message.
...@@ -359,6 +362,7 @@ void ExistingUserController::OnLoginSuccess( ...@@ -359,6 +362,7 @@ void ExistingUserController::OnLoginSuccess(
credentials, credentials,
pending_requests, pending_requests,
using_oauth, using_oauth,
has_cookies,
this); this);
......
...@@ -114,15 +114,15 @@ class LoginPerformer : public LoginStatusConsumer, ...@@ -114,15 +114,15 @@ class LoginPerformer : public LoginStatusConsumer,
void set_captcha(const std::string& captcha) { captcha_ = captcha; } void set_captcha(const std::string& captcha) { captcha_ = captcha; }
void set_delegate(Delegate* delegate) { delegate_ = delegate; } void set_delegate(Delegate* delegate) { delegate_ = delegate; }
private:
typedef enum AuthorizationMode { typedef enum AuthorizationMode {
// Authorization performed internally by Chrome. // Authorization performed internally by Chrome.
AUTH_MODE_INTERNAL, AUTH_MODE_INTERNAL,
// Authorization performed by an extension. // Authorization performed by an extension.
AUTH_MODE_EXTENSION AUTH_MODE_EXTENSION
} AuthorizationMode; } AuthorizationMode;
AuthorizationMode auth_mode() const { return auth_mode_; }
private:
// NotificationObserver implementation: // NotificationObserver implementation:
virtual void Observe(int type, virtual void Observe(int type,
const NotificationSource& source, const NotificationSource& source,
......
...@@ -247,6 +247,7 @@ class LoginUtilsImpl : public LoginUtils, ...@@ -247,6 +247,7 @@ class LoginUtilsImpl : public LoginUtils,
: background_view_(NULL), : background_view_(NULL),
pending_requests_(false), pending_requests_(false),
using_oauth_(false), using_oauth_(false),
has_cookies_(false),
delegate_(NULL) { delegate_(NULL) {
} }
...@@ -256,6 +257,7 @@ class LoginUtilsImpl : public LoginUtils, ...@@ -256,6 +257,7 @@ class LoginUtilsImpl : public LoginUtils,
const GaiaAuthConsumer::ClientLoginResult& credentials, const GaiaAuthConsumer::ClientLoginResult& credentials,
bool pending_requests, bool pending_requests,
bool using_oauth, bool using_oauth,
bool has_cookies,
LoginUtils::Delegate* delegate) OVERRIDE; LoginUtils::Delegate* delegate) OVERRIDE;
// Invoked after the tmpfs is successfully mounted. // Invoked after the tmpfs is successfully mounted.
...@@ -363,6 +365,7 @@ class LoginUtilsImpl : public LoginUtils, ...@@ -363,6 +365,7 @@ class LoginUtilsImpl : public LoginUtils,
GaiaAuthConsumer::ClientLoginResult credentials_; GaiaAuthConsumer::ClientLoginResult credentials_;
bool pending_requests_; bool pending_requests_;
bool using_oauth_; bool using_oauth_;
bool has_cookies_;
// Has to be scoped_refptr, see comment for CreateAuthenticator(...). // Has to be scoped_refptr, see comment for CreateAuthenticator(...).
scoped_refptr<Authenticator> authenticator_; scoped_refptr<Authenticator> authenticator_;
scoped_ptr<GaiaOAuthFetcher> oauth_fetcher_; scoped_ptr<GaiaOAuthFetcher> oauth_fetcher_;
...@@ -409,6 +412,7 @@ void LoginUtilsImpl::PrepareProfile( ...@@ -409,6 +412,7 @@ void LoginUtilsImpl::PrepareProfile(
const GaiaAuthConsumer::ClientLoginResult& credentials, const GaiaAuthConsumer::ClientLoginResult& credentials,
bool pending_requests, bool pending_requests,
bool using_oauth, bool using_oauth,
bool has_cookies,
LoginUtils::Delegate* delegate) { LoginUtils::Delegate* delegate) {
BootTimesLoader* btl = BootTimesLoader::Get(); BootTimesLoader* btl = BootTimesLoader::Get();
...@@ -433,6 +437,7 @@ void LoginUtilsImpl::PrepareProfile( ...@@ -433,6 +437,7 @@ void LoginUtilsImpl::PrepareProfile(
credentials_ = credentials; credentials_ = credentials;
pending_requests_ = pending_requests; pending_requests_ = pending_requests;
using_oauth_ = using_oauth; using_oauth_ = using_oauth;
has_cookies_ = has_cookies;
delegate_ = delegate; delegate_ = delegate;
// The default profile will have been changed because the ProfileManager // The default profile will have been changed because the ProfileManager
...@@ -471,8 +476,8 @@ void LoginUtilsImpl::OnProfileCreated(Profile* user_profile, Status status) { ...@@ -471,8 +476,8 @@ void LoginUtilsImpl::OnProfileCreated(Profile* user_profile, Status status) {
btl->AddLoginTimeMarker("UserProfileGotten", false); btl->AddLoginTimeMarker("UserProfileGotten", false);
if (using_oauth_) { if (using_oauth_) {
// Transfer cookies for the new user login. // Transfer cookies when user signs in using extension.
if (!pending_requests_) { if (has_cookies_) {
// Transfer cookies from the profile that was used for authentication. // Transfer cookies from the profile that was used for authentication.
// This profile contains cookies that auth extension should have already // This profile contains cookies that auth extension should have already
// put in place that will ensure that the newly created session is // put in place that will ensure that the newly created session is
...@@ -485,10 +490,10 @@ void LoginUtilsImpl::OnProfileCreated(Profile* user_profile, Status status) { ...@@ -485,10 +490,10 @@ void LoginUtilsImpl::OnProfileCreated(Profile* user_profile, Status status) {
} }
std::string oauth1_token; std::string oauth1_token;
std::string oauth1_secret; std::string oauth1_secret;
if (ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret) || if (!has_cookies_ &&
pending_requests_) { ReadOAuth1AccessToken(user_profile, &oauth1_token, &oauth1_secret)) {
// Verify OAuth access token when we find it in the profile and always if // Verify OAuth access token when we find it in the profile and no cookies
// we are performing parallel authentication. // available because user is not signing in using extension.
authenticator_->VerifyOAuth1AccessToken(oauth1_token, oauth1_secret); authenticator_->VerifyOAuth1AccessToken(oauth1_token, oauth1_secret);
} else { } else {
// If we don't have it, fetch OAuth1 access token. // If we don't have it, fetch OAuth1 access token.
......
...@@ -57,6 +57,7 @@ class LoginUtils { ...@@ -57,6 +57,7 @@ class LoginUtils {
const GaiaAuthConsumer::ClientLoginResult& credentials, const GaiaAuthConsumer::ClientLoginResult& credentials,
bool pending_requests, bool pending_requests,
bool using_oauth, bool using_oauth,
bool has_cookies,
Delegate* delegate) = 0; Delegate* delegate) = 0;
// Invoked after the tmpfs is successfully mounted. // Invoked after the tmpfs is successfully mounted.
......
...@@ -90,6 +90,7 @@ void MockLoginUtils::PrepareProfile( ...@@ -90,6 +90,7 @@ void MockLoginUtils::PrepareProfile(
const GaiaAuthConsumer::ClientLoginResult& res, const GaiaAuthConsumer::ClientLoginResult& res,
bool pending_requests, bool pending_requests,
bool using_oauth, bool using_oauth,
bool has_cookies,
Delegate* delegate) { Delegate* delegate) {
DCHECK_EQ(expected_username_, username); DCHECK_EQ(expected_username_, username);
DCHECK_EQ(expected_password_, password); DCHECK_EQ(expected_password_, password);
......
...@@ -94,6 +94,7 @@ class MockLoginUtils : public LoginUtils { ...@@ -94,6 +94,7 @@ class MockLoginUtils : public LoginUtils {
const GaiaAuthConsumer::ClientLoginResult& res, const GaiaAuthConsumer::ClientLoginResult& res,
bool pending_requests, bool pending_requests,
bool using_oauth, bool using_oauth,
bool has_cookies,
Delegate* delegate); Delegate* delegate);
virtual void CompleteOffTheRecordLogin(const GURL& start_url) {} virtual void CompleteOffTheRecordLogin(const GURL& start_url) {}
......
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