1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_VERIFIER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_VERIFIER_H_
12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "components/signin/core/browser/gaia_cookie_manager_service.h"
19 // Given GCMS and primary account id, this class verifies GAIA credentials
20 // (APISID) and rebuild current session's cookie jar for the primary account.
21 class OAuth2LoginVerifier
: public GaiaCookieManagerService::Observer
{
25 virtual ~Delegate() {}
26 // Invoked when cookie session is successfully merged.
27 virtual void OnSessionMergeSuccess() = 0;
29 // Invoked when cookie session can not be merged.
30 virtual void OnSessionMergeFailure(bool connection_error
) = 0;
32 // Invoked when account list is retrieved during post-merge session
34 virtual void OnListAccountsSuccess(
35 const std::vector
<gaia::ListedAccount
>& accounts
) = 0;
37 // Invoked when post-merge session verification fails.
38 virtual void OnListAccountsFailure(bool connection_error
) = 0;
41 OAuth2LoginVerifier(OAuth2LoginVerifier::Delegate
* delegate
,
42 GaiaCookieManagerService
* cookie_manager_service
,
43 const std::string
& primary_account_id
,
44 const std::string
& oauthlogin_access_token
);
45 ~OAuth2LoginVerifier() override
;
47 // Initiates verification of GAIA cookies in the cookie jar.
48 void VerifyUserCookies();
50 // Attempts to restore session from OAuth2 refresh token minting all necessary
51 // tokens along the way (OAuth2 access token, SID/LSID, GAIA service token).
52 void VerifyProfileTokens();
55 // GaiaCookieManagerService::Observer
56 void OnAddAccountToCookieCompleted(
57 const std::string
& account_id
,
58 const GoogleServiceAuthError
& error
) override
;
59 void OnGaiaAccountsInCookieUpdated(
60 const std::vector
<gaia::ListedAccount
>& accounts
,
61 const GoogleServiceAuthError
& error
) override
;
63 OAuth2LoginVerifier::Delegate
* delegate_
;
64 GaiaCookieManagerService
* cookie_manager_service_
;
65 const std::string
& primary_account_id_
;
66 const std::string access_token_
;
68 DISALLOW_COPY_AND_ASSIGN(OAuth2LoginVerifier
);
71 } // namespace chromeos
73 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_LOGIN_VERIFIER_H_