| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_GOOGLE_APIS_AUTH_SERVICE_INTERFACE_H_ | |
| 6 #define CHROME_BROWSER_GOOGLE_APIS_AUTH_SERVICE_INTERFACE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "chrome/browser/google_apis/gdata_errorcode.h" | |
| 12 | |
| 13 namespace google_apis { | |
| 14 | |
| 15 class AuthServiceObserver; | |
| 16 | |
| 17 // Called when fetching of access token is complete. | |
| 18 typedef base::Callback<void(GDataErrorCode error, | |
| 19 const std::string& access_token)> | |
| 20 AuthStatusCallback; | |
| 21 | |
| 22 // This defines an interface for the authentication service which is required | |
| 23 // by authenticated requests (AuthenticatedRequestInterface). | |
| 24 // All functions must be called on UI thread. | |
| 25 class AuthServiceInterface { | |
| 26 public: | |
| 27 virtual ~AuthServiceInterface() {} | |
| 28 | |
| 29 // Adds and removes the observer. | |
| 30 virtual void AddObserver(AuthServiceObserver* observer) = 0; | |
| 31 virtual void RemoveObserver(AuthServiceObserver* observer) = 0; | |
| 32 | |
| 33 // Starts fetching OAuth2 access token from the refresh token. | |
| 34 // |callback| must not be null. | |
| 35 virtual void StartAuthentication(const AuthStatusCallback& callback) = 0; | |
| 36 | |
| 37 // True if an OAuth2 access token is retrieved and believed to be fresh. | |
| 38 // The access token is used to access the Drive server. | |
| 39 virtual bool HasAccessToken() const = 0; | |
| 40 | |
| 41 // True if an OAuth2 refresh token is present. Its absence means that user | |
| 42 // is not properly authenticated. | |
| 43 // The refresh token is used to get the access token. | |
| 44 virtual bool HasRefreshToken() const = 0; | |
| 45 | |
| 46 // Returns OAuth2 access token. | |
| 47 virtual const std::string& access_token() const = 0; | |
| 48 | |
| 49 // Clears OAuth2 access token. | |
| 50 virtual void ClearAccessToken() = 0; | |
| 51 | |
| 52 // Clears OAuth2 refresh token. | |
| 53 virtual void ClearRefreshToken() = 0; | |
| 54 }; | |
| 55 | |
| 56 } // namespace google_apis | |
| 57 | |
| 58 #endif // CHROME_BROWSER_GOOGLE_APIS_AUTH_SERVICE_INTERFACE_H_ | |
| OLD | NEW |