OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_CHROMEOS_POLICY_USER_CLOUD_POLICY_TOKEN_FORWARDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_TOKEN_FORWARDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_TOKEN_FORWARDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_TOKEN_FORWARDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 11 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
12 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
13 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
14 | 14 |
15 class TokenService; | 15 class TokenService; |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 | 18 |
19 class UserCloudPolicyManagerChromeOS; | 19 class UserCloudPolicyManagerChromeOS; |
20 | 20 |
21 // A PKS that observes a TokenService and passes its refresh token to a | 21 // A PKS that observes a TokenService and passes its refresh token to a |
22 // UserCloudPolicyManagerChromeOS, when it becomes available. This service | 22 // UserCloudPolicyManagerChromeOS, when it becomes available. This service |
23 // decouples the UserCloudPolicyManagerChromeOS from depending directly on the | 23 // decouples the UserCloudPolicyManagerChromeOS from depending directly on the |
24 // TokenService, since it is initialized much earlier. | 24 // TokenService, since it is initialized much earlier. |
25 class UserCloudPolicyTokenForwarder : public ProfileKeyedService, | 25 class UserCloudPolicyTokenForwarder : public BrowserContextKeyedService, |
26 public content::NotificationObserver { | 26 public content::NotificationObserver { |
27 public: | 27 public: |
28 // The factory of this PKS depends on the factories of these two arguments, | 28 // The factory of this PKS depends on the factories of these two arguments, |
29 // so this object will be Shutdown() first and these pointers can be used | 29 // so this object will be Shutdown() first and these pointers can be used |
30 // until that point. | 30 // until that point. |
31 UserCloudPolicyTokenForwarder(UserCloudPolicyManagerChromeOS* manager, | 31 UserCloudPolicyTokenForwarder(UserCloudPolicyManagerChromeOS* manager, |
32 TokenService* token_service); | 32 TokenService* token_service); |
33 virtual ~UserCloudPolicyTokenForwarder(); | 33 virtual ~UserCloudPolicyTokenForwarder(); |
34 | 34 |
35 // ProfileKeyedService: | 35 // BrowserContextKeyedService: |
36 virtual void Shutdown() OVERRIDE; | 36 virtual void Shutdown() OVERRIDE; |
37 | 37 |
38 // NotificationObserver: | 38 // NotificationObserver: |
39 virtual void Observe(int type, | 39 virtual void Observe(int type, |
40 const content::NotificationSource& source, | 40 const content::NotificationSource& source, |
41 const content::NotificationDetails& details) OVERRIDE; | 41 const content::NotificationDetails& details) OVERRIDE; |
42 | 42 |
43 private: | 43 private: |
44 UserCloudPolicyManagerChromeOS* manager_; | 44 UserCloudPolicyManagerChromeOS* manager_; |
45 TokenService* token_service_; | 45 TokenService* token_service_; |
46 content::NotificationRegistrar registrar_; | 46 content::NotificationRegistrar registrar_; |
47 | 47 |
48 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyTokenForwarder); | 48 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyTokenForwarder); |
49 }; | 49 }; |
50 | 50 |
51 } // namespace policy | 51 } // namespace policy |
52 | 52 |
53 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_TOKEN_FORWARDER_H_ | 53 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_TOKEN_FORWARDER_H_ |
OLD | NEW |