| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ | 5 #ifndef REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ |
| 6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ | 6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ |
| 7 | 7 |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 AUTH_ERROR, | 35 AUTH_ERROR, |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 typedef base::Callback<void(Status status, | 38 typedef base::Callback<void(Status status, |
| 39 const std::string& user_email, | 39 const std::string& user_email, |
| 40 const std::string& access_token)> TokenCallback; | 40 const std::string& access_token)> TokenCallback; |
| 41 | 41 |
| 42 // This structure contains information required to perform | 42 // This structure contains information required to perform |
| 43 // authentication to OAuth2. | 43 // authentication to OAuth2. |
| 44 struct OAuthCredentials { | 44 struct OAuthCredentials { |
| 45 // |is_service_account| should be True if the OAuth refresh token is for a |
| 46 // service account, False for a user account, to allow the correct client-ID |
| 47 // to be used. |
| 45 OAuthCredentials(const std::string& login, | 48 OAuthCredentials(const std::string& login, |
| 46 const std::string& refresh_token, | 49 const std::string& refresh_token, |
| 47 bool is_service_account); | 50 bool is_service_account); |
| 48 | 51 |
| 49 // The user's account name (i.e. their email address). | 52 // The user's account name (i.e. their email address). |
| 50 std::string login; | 53 std::string login; |
| 51 | 54 |
| 52 // Token delegating authority to us to act as the user. | 55 // Token delegating authority to us to act as the user. |
| 53 std::string refresh_token; | 56 std::string refresh_token; |
| 54 | 57 |
| 55 // Whether these credentials belong to a service account. | 58 // Whether these credentials belong to a service account. |
| 56 bool is_service_account; | 59 bool is_service_account; |
| 57 }; | 60 }; |
| 58 | 61 |
| 59 OAuthTokenGetter( | 62 OAuthTokenGetter(scoped_ptr<OAuthCredentials> oauth_credentials, |
| 60 scoped_ptr<OAuthCredentials> oauth_credentials, | 63 const scoped_refptr<net::URLRequestContextGetter>& |
| 61 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter, | 64 url_request_context_getter, |
| 62 bool auto_refresh); | 65 bool auto_refresh); |
| 63 ~OAuthTokenGetter() override; | 66 ~OAuthTokenGetter() override; |
| 64 | 67 |
| 65 // Call |on_access_token| with an access token, or the failure status. | 68 // Call |on_access_token| with an access token, or the failure status. |
| 66 void CallWithToken(const OAuthTokenGetter::TokenCallback& on_access_token); | 69 void CallWithToken(const OAuthTokenGetter::TokenCallback& on_access_token); |
| 67 | 70 |
| 68 // gaia::GaiaOAuthClient::Delegate interface. | 71 // gaia::GaiaOAuthClient::Delegate interface. |
| 69 void OnGetTokensResponse(const std::string& user_email, | 72 void OnGetTokensResponse(const std::string& user_email, |
| 70 const std::string& access_token, | 73 const std::string& access_token, |
| 71 int expires_seconds) override; | 74 int expires_seconds) override; |
| 72 void OnRefreshTokenResponse(const std::string& access_token, | 75 void OnRefreshTokenResponse(const std::string& access_token, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 91 base::Time auth_token_expiry_time_; | 94 base::Time auth_token_expiry_time_; |
| 92 std::queue<OAuthTokenGetter::TokenCallback> pending_callbacks_; | 95 std::queue<OAuthTokenGetter::TokenCallback> pending_callbacks_; |
| 93 scoped_ptr<base::OneShotTimer<OAuthTokenGetter> > refresh_timer_; | 96 scoped_ptr<base::OneShotTimer<OAuthTokenGetter> > refresh_timer_; |
| 94 | 97 |
| 95 DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter); | 98 DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter); |
| 96 }; | 99 }; |
| 97 | 100 |
| 98 } // namespace remoting | 101 } // namespace remoting |
| 99 | 102 |
| 100 #endif // REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ | 103 #endif // REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ |
| OLD | NEW |