Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / components / signin / core / browser / signin_oauth_helper.h
blob12de65bd9caae1fa06df5176f984f1d789ec84ae
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_
8 #include <string>
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 {
17 public:
18 // Implemented by users of SigninOAuthHelper to know then helper is finished.
19 class Consumer {
20 public:
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,
40 Consumer* consumer);
41 ~SigninOAuthHelper() override;
43 private:
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_;
54 Consumer* consumer_;
56 DISALLOW_COPY_AND_ASSIGN(SigninOAuthHelper);
59 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_OAUTH_HELPER_H_