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 COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_OAUTH_HELPER_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_OAUTH_HELPER_H_
10 #include "base/memory/scoped_ptr.h"
11 #include "google_apis/gaia/gaia_auth_consumer.h"
12 #include "google_apis/gaia/gaia_auth_fetcher.h"
14 // Retrieves the OAuth2 information from an already signed in cookie jar.
15 // The information retrieved is: username, refresh token.
16 class SigninOAuthHelper
: public GaiaAuthConsumer
{
18 // Implemented by users of SigninOAuthHelper to know then helper is finished.
21 virtual ~Consumer() {}
23 // Called when all the information is retrieved successfully. |email|
24 // and |display_email| correspond to the gaia properties called "email"
25 // and "displayEmail" associated with the signed in account. |refresh_token|
26 // is the account's login-scoped oauth2 refresh token.
27 virtual void OnSigninOAuthInformationAvailable(
28 const std::string
& email
,
29 const std::string
& display_email
,
30 const std::string
& refresh_token
) {}
32 // Called when an error occurs while getting the information.
33 virtual void OnSigninOAuthInformationFailure(
34 const GoogleServiceAuthError
& error
) {}
37 explicit SigninOAuthHelper(net::URLRequestContextGetter
* getter
,
38 const std::string
& session_index
,
39 const std::string
& signin_scoped_device_id
,
41 ~SigninOAuthHelper() override
;
44 // Overridden from GaiaAuthConsumer.
45 void OnClientOAuthSuccess(const ClientOAuthResult
& result
) override
;
46 void OnClientOAuthFailure(const GoogleServiceAuthError
& error
) override
;
47 void OnClientLoginSuccess(const ClientLoginResult
& result
) override
;
48 void OnClientLoginFailure(const GoogleServiceAuthError
& error
) override
;
49 void OnGetUserInfoSuccess(const UserInfoMap
& data
) override
;
50 void OnGetUserInfoFailure(const GoogleServiceAuthError
& error
) override
;
52 GaiaAuthFetcher gaia_auth_fetcher_
;
53 std::string refresh_token_
;
56 DISALLOW_COPY_AND_ASSIGN(SigninOAuthHelper
);
59 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_OAUTH_HELPER_H_