MD Downloads: prevent search text from overlapping with the cancel search (X)
[chromium-blink-merge.git] / remoting / host / oauth_token_getter.h
blobfd483ff5079b1302eb65353593294b456c55b8e1
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 REMOTING_HOST_OAUTH_TOKEN_GETTER_H_
6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_H_
8 #include <string>
10 #include "base/callback.h"
13 namespace remoting {
15 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed.
16 class OAuthTokenGetter {
17 public:
18 // Status of the refresh token attempt.
19 enum Status {
20 // Success, credentials in user_email/access_token.
21 SUCCESS,
22 // Network failure (caller may retry).
23 NETWORK_ERROR,
24 // Authentication failure (permanent).
25 AUTH_ERROR,
28 typedef base::Callback<void(Status status,
29 const std::string& user_email,
30 const std::string& access_token)> TokenCallback;
32 // This structure contains information required to perform
33 // authentication to OAuth2.
34 struct OAuthCredentials {
35 // |is_service_account| should be True if the OAuth refresh token is for a
36 // service account, False for a user account, to allow the correct client-ID
37 // to be used.
38 OAuthCredentials(const std::string& login,
39 const std::string& refresh_token,
40 bool is_service_account);
42 // The user's account name (i.e. their email address).
43 std::string login;
45 // Token delegating authority to us to act as the user.
46 std::string refresh_token;
48 // Whether these credentials belong to a service account.
49 bool is_service_account;
52 OAuthTokenGetter() {}
53 virtual ~OAuthTokenGetter() {}
55 // Call |on_access_token| with an access token, or the failure status.
56 virtual void CallWithToken(
57 const OAuthTokenGetter::TokenCallback& on_access_token) = 0;
59 DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter);
62 } // namespace remoting
64 #endif // REMOTING_HOST_OAUTH_TOKEN_GETTER_H_