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 CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_TOKEN_INITIALIZER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_TOKEN_INITIALIZER_H_
10 #include "base/callback.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/chromeos/login/signin/oauth2_token_fetcher.h"
14 #include "chromeos/login/auth/user_context.h"
18 // Performs initial fetch of OAuth2 Tokens.
19 class OAuth2TokenInitializer final
: public OAuth2TokenFetcher::Delegate
{
21 // Callback to be invoked after initialization is done.
22 using FetchOAuth2TokensCallback
=
23 base::Callback
<void(bool success
, const UserContext
& user_context
)>;
25 OAuth2TokenInitializer();
26 ~OAuth2TokenInitializer() override
;
28 // Fetch OAuth2 tokens.
29 void Start(const UserContext
& context
,
30 const FetchOAuth2TokensCallback
& callback
);
33 // OAuth2TokenFetcher::Delegate overrides.
34 void OnOAuth2TokensAvailable(
35 const GaiaAuthConsumer::ClientOAuthResult
& oauth2_tokens
) override
;
36 void OnOAuth2TokensFetchFailed() override
;
38 UserContext user_context_
;
39 FetchOAuth2TokensCallback callback_
;
40 scoped_ptr
<OAuth2TokenFetcher
> oauth2_token_fetcher_
;
42 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenInitializer
);
45 } // namespace chromeos
47 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SIGNIN_OAUTH2_TOKEN_INITIALIZER_H_