Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: chrome/browser/policy/cloud/user_policy_signin_service.h

Issue 23068005: Convert UserPolicySigninService to use OAuth2TokenService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android fixes. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_ 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h" 13 #include "chrome/browser/policy/cloud/user_policy_signin_service_base.h"
14 #include "chrome/browser/signin/oauth2_token_service.h"
14 15
15 class Profile; 16 class Profile;
16 17
17 namespace policy { 18 namespace policy {
18 19
19 class CloudPolicyClientRegistrationHelper; 20 class CloudPolicyClientRegistrationHelper;
20 21
21 // A specialization of the UserPolicySigninServiceBase for the desktop 22 // A specialization of the UserPolicySigninServiceBase for the desktop
22 // platforms (Windows, Mac and Linux). 23 // platforms (Windows, Mac and Linux).
23 class UserPolicySigninService : public UserPolicySigninServiceBase { 24 class UserPolicySigninService : public UserPolicySigninServiceBase,
25 public OAuth2TokenService::Observer {
24 public: 26 public:
25 // Creates a UserPolicySigninService associated with the passed |profile|. 27 // Creates a UserPolicySigninService associated with the passed |profile|.
26 UserPolicySigninService(Profile* profile, 28 UserPolicySigninService(Profile* profile,
27 PrefService* local_state, 29 PrefService* local_state,
28 DeviceManagementService* device_management_service); 30 DeviceManagementService* device_management_service);
29 virtual ~UserPolicySigninService(); 31 virtual ~UserPolicySigninService();
30 32
31 // Registers a CloudPolicyClient for fetching policy for a user. The 33 // Registers a CloudPolicyClient for fetching policy for a user. The
32 // |oauth2_login_token| and |username| are explicitly passed because 34 // |oauth2_login_token| and |username| are explicitly passed because
33 // the user is not signed in yet (TokenService does not have any tokens yet 35 // the user is not signed in yet (ProfileOAuth2TokenService does not have
34 // to prevent services from using it until after we've fetched policy). 36 // any tokens yet to prevent services from using it until after we've fetched
37 // policy).
35 void RegisterPolicyClient(const std::string& username, 38 void RegisterPolicyClient(const std::string& username,
36 const std::string& oauth2_login_token, 39 const std::string& oauth2_login_token,
37 const PolicyRegistrationCallback& callback); 40 const PolicyRegistrationCallback& callback);
38 41
39 // content::NotificationObserver implementation: 42 // OAuth2TokenService::Observer implementation:
40 virtual void Observe(int type, 43 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
41 const content::NotificationSource& source,
42 const content::NotificationDetails& details) OVERRIDE;
43 44
44 // CloudPolicyService::Observer implementation: 45 // CloudPolicyService::Observer implementation:
45 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; 46 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE;
46 47
47 // BrowserContextKeyedService implementation: 48 // BrowserContextKeyedService implementation:
48 virtual void Shutdown() OVERRIDE; 49 virtual void Shutdown() OVERRIDE;
49 50
51 protected:
50 // UserPolicySigninServiceBase implementation: 52 // UserPolicySigninServiceBase implementation:
51 virtual void InitializeUserCloudPolicyManager( 53 virtual void InitializeUserCloudPolicyManager(
52 scoped_ptr<CloudPolicyClient> client) OVERRIDE; 54 scoped_ptr<CloudPolicyClient> client) OVERRIDE;
55
56 virtual void PrepareForUserCloudPolicyManagerShutdown() OVERRIDE;
53 virtual void ShutdownUserCloudPolicyManager() OVERRIDE; 57 virtual void ShutdownUserCloudPolicyManager() OVERRIDE;
54 58
55 private: 59 private:
56 // Fetches an OAuth token to allow the cloud policy service to register with 60 // Fetches an OAuth token to allow the cloud policy service to register with
57 // the cloud policy server. |oauth_login_token| should contain an OAuth login 61 // the cloud policy server. |oauth_login_token| should contain an OAuth login
58 // refresh token that can be downscoped to get an access token for the 62 // refresh token that can be downscoped to get an access token for the
59 // device_management service. 63 // device_management service.
60 void RegisterCloudPolicyService(const std::string& oauth_login_token); 64 void RegisterCloudPolicyService();
61 65
62 // Callback invoked when policy registration has finished. 66 // Callback invoked when policy registration has finished.
63 void OnRegistrationComplete(); 67 void OnRegistrationComplete();
64 68
65 // Helper routine which prohibits user signout if the user is registered for 69 // Helper routine which prohibits user signout if the user is registered for
66 // cloud policy. 70 // cloud policy.
67 void ProhibitSignoutIfNeeded(); 71 void ProhibitSignoutIfNeeded();
68 72
69 // Invoked when a policy registration request is complete. 73 // Invoked when a policy registration request is complete.
70 void CallPolicyRegistrationCallback(scoped_ptr<CloudPolicyClient> client, 74 void CallPolicyRegistrationCallback(scoped_ptr<CloudPolicyClient> client,
71 PolicyRegistrationCallback callback); 75 PolicyRegistrationCallback callback);
72 76
73 scoped_ptr<CloudPolicyClientRegistrationHelper> registration_helper_; 77 scoped_ptr<CloudPolicyClientRegistrationHelper> registration_helper_;
74 78
75 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); 79 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService);
76 }; 80 };
77 81
78 } // namespace policy 82 } // namespace policy
79 83
80 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_ 84 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698