Fix build break
[chromium-blink-merge.git] / chrome / browser / google_apis / auth_service_interface.h
bloba5db30c91e8ae2e87425fd23cd6d6ae725da11f6
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.
5 #ifndef CHROME_BROWSER_GOOGLE_APIS_AUTH_SERVICE_INTERFACE_H_
6 #define CHROME_BROWSER_GOOGLE_APIS_AUTH_SERVICE_INTERFACE_H_
8 #include <string>
10 #include "base/callback_forward.h"
11 #include "chrome/browser/google_apis/gdata_errorcode.h"
13 class Profile;
15 namespace google_apis {
17 class AuthServiceObserver;
18 class OperationRegistry;
20 // Called when fetching of access token is complete.
21 typedef base::Callback<void(GDataErrorCode error,
22 const std::string& access_token)>
23 AuthStatusCallback;
25 // This defines an interface for the authentication service which is required
26 // by authenticated operations (AuthenticatedOperationInterface).
27 // All functions must be called on UI thread.
28 class AuthServiceInterface {
29 public:
30 // Adds and removes the observer. AddObserver() should be called before
31 // Initialize() as it can change the refresh token.
32 virtual void AddObserver(AuthServiceObserver* observer) = 0;
33 virtual void RemoveObserver(AuthServiceObserver* observer) = 0;
35 // Initializes the auth service. Starts TokenService to retrieve the
36 // refresh token.
37 virtual void Initialize(Profile* profile) = 0;
39 // Starts fetching OAuth2 access token from the refresh token.
40 // |callback| must not be null.
41 virtual void StartAuthentication(OperationRegistry* registry,
42 const AuthStatusCallback& callback) = 0;
44 // True if an OAuth2 access token is retrieved and believed to be fresh.
45 // The access token is used to access the Drive server.
46 virtual bool HasAccessToken() const = 0;
48 // True if an OAuth2 refresh token is present. Its absence means that user
49 // is not properly authenticated.
50 // The refresh token is used to get the access token.
51 virtual bool HasRefreshToken() const = 0;
53 // Returns OAuth2 access token.
54 virtual const std::string& access_token() const = 0;
56 // Clears OAuth2 access token.
57 virtual void ClearAccessToken() = 0;
59 // Clears OAuth2 refresh token.
60 virtual void ClearRefreshToken() = 0;
63 } // namespace google_apis
65 #endif // CHROME_BROWSER_GOOGLE_APIS_AUTH_SERVICE_INTERFACE_H_