Roll src/third_party/WebKit 9f7fb92:f103b33 (svn 202621:202622)
[chromium-blink-merge.git] / components / signin / core / browser / account_info_fetcher.h
blob3248aab22049d670d87dcd3516ebd1a0ee38c04a
1 // Copyright 2015 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_ACCOUNT_INFO_FETCHER_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_INFO_FETCHER_H_
8 #include "google_apis/gaia/gaia_auth_consumer.h"
9 #include "google_apis/gaia/gaia_oauth_client.h"
10 #include "google_apis/gaia/oauth2_token_service.h"
12 namespace net {
13 class URLRequestContextGetter;
16 class AccountFetcherService;
18 // An account information fetcher that gets an OAuth token of appropriate
19 // scope and uses it to fetch account infromation. This does not handle
20 // refreshing the information and is meant to be used in a one shot fashion.
21 class AccountInfoFetcher : public OAuth2TokenService::Consumer,
22 public gaia::GaiaOAuthClient::Delegate {
23 public:
24 AccountInfoFetcher(OAuth2TokenService* token_service,
25 net::URLRequestContextGetter* request_context_getter,
26 AccountFetcherService* service,
27 const std::string& account_id);
28 ~AccountInfoFetcher() override;
30 const std::string& account_id() { return account_id_; }
32 // Start fetching the account information.
33 void Start();
35 // OAuth2TokenService::Consumer implementation.
36 void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
37 const std::string& access_token,
38 const base::Time& expiration_time) override;
39 void OnGetTokenFailure(const OAuth2TokenService::Request* request,
40 const GoogleServiceAuthError& error) override;
42 // gaia::GaiaOAuthClient::Delegate implementation.
43 void OnGetUserInfoResponse(
44 scoped_ptr<base::DictionaryValue> user_info) override;
45 void OnOAuthError() override;
46 void OnNetworkError(int response_code) override;
48 private:
49 OAuth2TokenService* token_service_;
50 net::URLRequestContextGetter* request_context_getter_;
51 AccountFetcherService* service_;
52 const std::string account_id_;
54 scoped_ptr<OAuth2TokenService::Request> login_token_request_;
55 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_;
57 DISALLOW_COPY_AND_ASSIGN(AccountInfoFetcher);
60 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_ACCOUNT_INFO_FETCHER_H_