OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ |
6 #define CHROME_BROWSER_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ | 6 #define CHROME_BROWSER_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/policy/cloud_policy_service.h" | 10 #include "chrome/browser/policy/cloud_policy_service.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // initializes/shuts down the UserCloudPolicyManager as required. This class is | 28 // initializes/shuts down the UserCloudPolicyManager as required. This class is |
29 // not used on ChromeOS because UserCloudPolicyManager initialization is handled | 29 // not used on ChromeOS because UserCloudPolicyManager initialization is handled |
30 // via LoginUtils, since it must happen before profile creation. | 30 // via LoginUtils, since it must happen before profile creation. |
31 class UserPolicySigninService | 31 class UserPolicySigninService |
32 : public ProfileKeyedService, | 32 : public ProfileKeyedService, |
33 public OAuth2AccessTokenConsumer, | 33 public OAuth2AccessTokenConsumer, |
34 public CloudPolicyService::Observer, | 34 public CloudPolicyService::Observer, |
35 public content::NotificationObserver { | 35 public content::NotificationObserver { |
36 public: | 36 public: |
37 // Creates a UserPolicySigninService associated with the passed |profile|. | 37 // Creates a UserPolicySigninService associated with the passed |profile|. |
38 UserPolicySigninService(Profile* profile, UserCloudPolicyManager* manager); | 38 explicit UserPolicySigninService(Profile* profile); |
39 virtual ~UserPolicySigninService(); | 39 virtual ~UserPolicySigninService(); |
40 | 40 |
41 // content::NotificationObserver implementation. | 41 // content::NotificationObserver implementation. |
42 virtual void Observe(int type, | 42 virtual void Observe(int type, |
43 const content::NotificationSource& source, | 43 const content::NotificationSource& source, |
44 const content::NotificationDetails& details) OVERRIDE; | 44 const content::NotificationDetails& details) OVERRIDE; |
45 | 45 |
46 // CloudPolicyService::Observer implementation. | 46 // CloudPolicyService::Observer implementation. |
47 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; | 47 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; |
48 | 48 |
49 // OAuth2AccessTokenConsumer implementation. | 49 // OAuth2AccessTokenConsumer implementation. |
50 virtual void OnGetTokenSuccess(const std::string& access_token, | 50 virtual void OnGetTokenSuccess(const std::string& access_token, |
51 const base::Time& expiration_time) OVERRIDE; | 51 const base::Time& expiration_time) OVERRIDE; |
52 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; | 52 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; |
53 | 53 |
| 54 // ProfileKeyedService implementation: |
| 55 virtual void Shutdown() OVERRIDE; |
| 56 |
54 private: | 57 private: |
55 // Initializes the UserCloudPolicyManager to reflect the currently-signed-in | 58 // Initializes the UserCloudPolicyManager to reflect the currently-signed-in |
56 // user. | 59 // user. |
57 void ConfigureUserCloudPolicyManager(); | 60 void ConfigureUserCloudPolicyManager(); |
58 | 61 |
59 // Fetches an OAuth token to allow the cloud policy service to register with | 62 // Fetches an OAuth token to allow the cloud policy service to register with |
60 // the cloud policy server. | 63 // the cloud policy server. |
61 void RegisterCloudPolicyService(); | 64 void RegisterCloudPolicyService(); |
62 | 65 |
63 // Helper routine to unregister for CloudPolicyService notifications. | 66 // Helper routine to unregister for CloudPolicyService notifications. |
64 void StopObserving(); | 67 void StopObserving(); |
65 | 68 |
| 69 // Convenience helper to get the UserCloudPolicyManager for |profile_|. |
| 70 UserCloudPolicyManager* GetManager(); |
| 71 |
66 // Weak pointer to the profile this service is associated with. | 72 // Weak pointer to the profile this service is associated with. |
67 Profile* profile_; | 73 Profile* profile_; |
68 | 74 |
69 content::NotificationRegistrar registrar_; | 75 content::NotificationRegistrar registrar_; |
70 scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_; | 76 scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_; |
71 | 77 |
72 // Weak pointer to the UserCloudPolicyManager (allows dependency injection | |
73 // for tests). | |
74 UserCloudPolicyManager* manager_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); | 78 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); |
77 }; | 79 }; |
78 | 80 |
79 } // namespace policy | 81 } // namespace policy |
80 | 82 |
81 #endif // CHROME_BROWSER_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ | 83 #endif // CHROME_BROWSER_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ |
OLD | NEW |