Chromium Code Reviews| 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_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ | |
| 6 #define CHROME_BROWSER_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "chrome/browser/profiles/profile_keyed_service.h" | |
| 11 #include "chrome/common/net/gaia/oauth2_access_token_consumer.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 | |
| 15 class OAuth2AccessTokenFetcher; | |
| 16 class Profile; | |
| 17 | |
| 18 namespace base { | |
| 19 class Time; | |
| 20 } | |
| 21 | |
| 22 namespace policy { | |
| 23 | |
| 24 class UserCloudPolicyManager; | |
| 25 | |
| 26 // The UserPolicySigninService tracks when user signin/signout actions occur and | |
| 27 // initializes/shuts down the UserCloudPolicyManager as required. This class is | |
| 28 // not used on ChromeOS because UserCloudPolicyManager initialization is handled | |
| 29 // via LoginUtils, since it must happen before profile creation. | |
| 30 #if !defined(OS_CHROMEOS) | |
|
Mattias Nissler (ping if slow)
2012/08/03 12:19:08
Seems like this should rather use an exclude rule
Andrew T Wilson (Slow)
2012/08/04 00:54:41
I do exclude this via chrome_browser.gypi, but all
Mattias Nissler (ping if slow)
2012/08/06 08:33:52
Ah, that's definitely an interesting idea. Then ag
Andrew T Wilson (Slow)
2012/08/06 20:30:23
OK, removed.
| |
| 31 class UserPolicySigninService | |
| 32 : public ProfileKeyedService, | |
| 33 public OAuth2AccessTokenConsumer, | |
| 34 public content::NotificationObserver { | |
| 35 public: | |
| 36 // Creates a UserPolicySigninService associated with the passed |profile|. | |
| 37 UserPolicySigninService(Profile* profile, UserCloudPolicyManager* manager); | |
| 38 virtual ~UserPolicySigninService(); | |
| 39 | |
| 40 // content::NotificationObserver implementation. | |
| 41 virtual void Observe(int type, | |
| 42 const content::NotificationSource& source, | |
| 43 const content::NotificationDetails& details) OVERRIDE; | |
| 44 | |
| 45 // OAuth2AccessTokenConsumer implementation. | |
| 46 virtual void OnGetTokenSuccess(const std::string& access_token, | |
| 47 const base::Time& expiration_time) OVERRIDE; | |
| 48 virtual void OnGetTokenFailure(const GoogleServiceAuthError& error) OVERRIDE; | |
| 49 | |
| 50 private: | |
| 51 // Initializes the UserCloudPolicyManager to reflect the currently-signed-in | |
| 52 // user. | |
| 53 void ConfigureUserCloudPolicyManager(); | |
| 54 | |
| 55 // Fetches an OAuth token to allow the cloud policy service to register with | |
| 56 // the cloud policy server. | |
| 57 void RegisterCloudPolicyService(); | |
| 58 | |
| 59 // Weak pointer to the profile this service is associated with. | |
| 60 Profile* profile_; | |
| 61 | |
| 62 content::NotificationRegistrar registrar_; | |
| 63 scoped_ptr<OAuth2AccessTokenFetcher> oauth2_access_token_fetcher_; | |
| 64 | |
| 65 // Weak pointer to the UserCloudPolicyManager (allows dependency injection | |
| 66 // for tests). | |
| 67 UserCloudPolicyManager* manager_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); | |
| 70 }; | |
| 71 #endif // !defined(OS_CHROMEOS) | |
| 72 | |
| 73 } // namespace policy | |
| 74 | |
| 75 #endif // CHROME_BROWSER_POLICY_USER_POLICY_SIGNIN_SERVICE_H_ | |
| OLD | NEW |