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 CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_ |
6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_ | 6 #define CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 | 12 |
13 class OAuth2TokenService; | 13 class OAuth2TokenService; |
14 | 14 |
15 namespace invalidation { | 15 namespace invalidation { |
16 | 16 |
17 // Encapsulates authentication-related dependencies of InvalidationService | 17 // Encapsulates authentication-related dependencies of InvalidationService |
18 // implementations so different implementations can be used for regular Profiles | 18 // implementations so different implementations can be used for regular Profiles |
19 // and Chrome OS Kiosk Apps. | 19 // and Chrome OS Kiosk Apps. |
20 class InvalidationAuthProvider { | 20 class InvalidationAuthProvider { |
21 public: | 21 public: |
22 class Observer { | 22 class Observer { |
23 public: | 23 public: |
24 virtual ~Observer(); | 24 virtual ~Observer(); |
25 | 25 |
| 26 // Calls when the user logs in. |
| 27 virtual void OnInvalidationAuthLogin() {} |
| 28 |
26 // Called when the user logs out. | 29 // Called when the user logs out. |
27 virtual void OnInvalidationAuthLogout() = 0; | 30 virtual void OnInvalidationAuthLogout() {} |
28 }; | 31 }; |
29 | 32 |
30 virtual ~InvalidationAuthProvider(); | 33 virtual ~InvalidationAuthProvider(); |
31 | 34 |
32 // Gets the token service vending tokens for authentication to the cloud. | 35 // Gets the token service vending tokens for authentication to the cloud. |
33 virtual OAuth2TokenService* GetTokenService() = 0; | 36 virtual OAuth2TokenService* GetTokenService() = 0; |
34 | 37 |
| 38 // Gets the username to use for authentication. |
| 39 virtual std::string GetUsername() = 0; |
| 40 |
35 // Gets the account ID to use for authentication. | 41 // Gets the account ID to use for authentication. |
36 virtual std::string GetAccountId() = 0; | 42 virtual std::string GetAccountId() = 0; |
37 | 43 |
38 // Shows the login popup, returns true if successful. | 44 // Shows the login popup, returns true if successful. |
39 virtual bool ShowLoginUI() = 0; | 45 virtual bool ShowLoginUI() = 0; |
40 | 46 |
41 void AddObserver(Observer* observer); | 47 void AddObserver(Observer* observer); |
42 void RemoveObserver(Observer* observer); | 48 void RemoveObserver(Observer* observer); |
43 | 49 |
44 protected: | 50 protected: |
45 InvalidationAuthProvider(); | 51 InvalidationAuthProvider(); |
46 | 52 |
| 53 // Fires an OnInvalidationAuthLogin notification. |
| 54 void FireInvalidationAuthLogin(); |
| 55 |
47 // Fires an OnInvalidationAuthLogout notification. | 56 // Fires an OnInvalidationAuthLogout notification. |
48 void FireInvalidationAuthLogout(); | 57 void FireInvalidationAuthLogout(); |
49 | 58 |
50 private: | 59 private: |
51 ObserverList<Observer, true> observers_; | 60 ObserverList<Observer, true> observers_; |
52 | 61 |
53 DISALLOW_COPY_AND_ASSIGN(InvalidationAuthProvider); | 62 DISALLOW_COPY_AND_ASSIGN(InvalidationAuthProvider); |
54 }; | 63 }; |
55 | 64 |
56 } // namespace invalidation | 65 } // namespace invalidation |
57 | 66 |
58 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_ | 67 #endif // CHROME_BROWSER_INVALIDATION_INVALIDATION_AUTH_PROVIDER_H_ |
OLD | NEW |