| 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_BASE_OAUTH_TOKEN_GETTER_H_ | 
| 6 #define REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ | 6 #define REMOTING_BASE_OAUTH_TOKEN_GETTER_H_ | 
| 7 | 7 | 
| 8 #include <string> | 8 #include <string> | 
| 9 | 9 | 
| 10 #include "base/callback.h" | 10 #include "base/callback.h" | 
| 11 #include "base/macros.h" | 11 #include "base/macros.h" | 
| 12 | 12 | 
| 13 namespace remoting { | 13 namespace remoting { | 
| 14 | 14 | 
| 15 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed. | 15 // OAuthTokenGetter caches OAuth access tokens and refreshes them as needed. | 
| 16 class OAuthTokenGetter { | 16 class OAuthTokenGetter { | 
| 17  public: | 17  public: | 
| 18   // Status of the refresh token attempt. | 18   // Status of the refresh token attempt. | 
| 19   enum Status { | 19   enum Status { | 
| 20     // Success, credentials in user_email/access_token. | 20     // Success, credentials in user_email/access_token. | 
| 21     SUCCESS, | 21     SUCCESS, | 
| 22     // Network failure (caller may retry). | 22     // Network failure (caller may retry). | 
| 23     NETWORK_ERROR, | 23     NETWORK_ERROR, | 
| 24     // Authentication failure (permanent). | 24     // Authentication failure (permanent). | 
| 25     AUTH_ERROR, | 25     AUTH_ERROR, | 
| 26   }; | 26   }; | 
| 27 | 27 | 
| 28   typedef base::Callback<void(Status status, | 28   typedef base::Callback<void(Status status, | 
| 29                               const std::string& user_email, | 29                               const std::string& user_email, | 
| 30                               const std::string& access_token)> TokenCallback; | 30                               const std::string& access_token)> | 
|  | 31       TokenCallback; | 
| 31 | 32 | 
| 32   // This structure contains information required to perform | 33   // This structure contains information required to perform | 
| 33   // authentication to OAuth2. | 34   // authentication to OAuth2. | 
| 34   struct OAuthCredentials { | 35   struct OAuthCredentials { | 
| 35     // |is_service_account| should be True if the OAuth refresh token is for a | 36     // |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     // service account, False for a user account, to allow the correct client-ID | 
| 37     // to be used. | 38     // to be used. | 
| 38     OAuthCredentials(const std::string& login, | 39     OAuthCredentials(const std::string& login, | 
| 39                      const std::string& refresh_token, | 40                      const std::string& refresh_token, | 
| 40                      bool is_service_account); | 41                      bool is_service_account); | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 58 | 59 | 
| 59   // Invalidates the cache, so the next CallWithToken() will get a fresh access | 60   // Invalidates the cache, so the next CallWithToken() will get a fresh access | 
| 60   // token. | 61   // token. | 
| 61   virtual void InvalidateCache() = 0; | 62   virtual void InvalidateCache() = 0; | 
| 62 | 63 | 
| 63   DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter); | 64   DISALLOW_COPY_AND_ASSIGN(OAuthTokenGetter); | 
| 64 }; | 65 }; | 
| 65 | 66 | 
| 66 }  // namespace remoting | 67 }  // namespace remoting | 
| 67 | 68 | 
| 68 #endif  // REMOTING_HOST_OAUTH_TOKEN_GETTER_H_ | 69 #endif  // REMOTING_BASE_OAUTH_TOKEN_GETTER_H_ | 
| OLD | NEW | 
|---|