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