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

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: Merge with ToT 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/profile_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,
31 ProfileOAuth2TokenService* oauth2_token_service);
29 virtual ~UserPolicySigninService(); 32 virtual ~UserPolicySigninService();
30 33
31 // Registers a CloudPolicyClient for fetching policy for a user. The 34 // Registers a CloudPolicyClient for fetching policy for a user. The
32 // |oauth2_login_token| and |username| are explicitly passed because 35 // |oauth2_login_token| and |username| are explicitly passed because
33 // the user is not signed in yet (TokenService does not have any tokens yet 36 // the user is not signed in yet (ProfileOAuth2TokenService does not have
34 // to prevent services from using it until after we've fetched policy). 37 // any tokens yet to prevent services from using it until after we've fetched
38 // policy).
35 void RegisterPolicyClient(const std::string& username, 39 void RegisterPolicyClient(const std::string& username,
36 const std::string& oauth2_login_token, 40 const std::string& oauth2_login_token,
37 const PolicyRegistrationCallback& callback); 41 const PolicyRegistrationCallback& callback);
38 42
39 // content::NotificationObserver implementation: 43 // OAuth2TokenService::Observer implementation:
40 virtual void Observe(int type, 44 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE;
41 const content::NotificationSource& source,
42 const content::NotificationDetails& details) OVERRIDE;
43 45
44 // CloudPolicyService::Observer implementation: 46 // CloudPolicyService::Observer implementation:
45 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE; 47 virtual void OnInitializationCompleted(CloudPolicyService* service) OVERRIDE;
46 48
47 // BrowserContextKeyedService implementation: 49 // BrowserContextKeyedService implementation:
48 virtual void Shutdown() OVERRIDE; 50 virtual void Shutdown() OVERRIDE;
49 51
52 protected:
50 // UserPolicySigninServiceBase implementation: 53 // UserPolicySigninServiceBase implementation:
51 virtual void InitializeUserCloudPolicyManager( 54 virtual void InitializeUserCloudPolicyManager(
52 scoped_ptr<CloudPolicyClient> client) OVERRIDE; 55 scoped_ptr<CloudPolicyClient> client) OVERRIDE;
56
57 virtual void PrepareForUserCloudPolicyManagerShutdown() OVERRIDE;
53 virtual void ShutdownUserCloudPolicyManager() OVERRIDE; 58 virtual void ShutdownUserCloudPolicyManager() OVERRIDE;
54 59
55 private: 60 private:
56 // Fetches an OAuth token to allow the cloud policy service to register with 61 // 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 62 // 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 63 // refresh token that can be downscoped to get an access token for the
59 // device_management service. 64 // device_management service.
60 void RegisterCloudPolicyService(const std::string& oauth_login_token); 65 void RegisterCloudPolicyService();
61 66
62 // Callback invoked when policy registration has finished. 67 // Callback invoked when policy registration has finished.
63 void OnRegistrationComplete(); 68 void OnRegistrationComplete();
64 69
65 // Helper routine which prohibits user signout if the user is registered for 70 // Helper routine which prohibits user signout if the user is registered for
66 // cloud policy. 71 // cloud policy.
67 void ProhibitSignoutIfNeeded(); 72 void ProhibitSignoutIfNeeded();
68 73
69 // Invoked when a policy registration request is complete. 74 // Invoked when a policy registration request is complete.
70 void CallPolicyRegistrationCallback(scoped_ptr<CloudPolicyClient> client, 75 void CallPolicyRegistrationCallback(scoped_ptr<CloudPolicyClient> client,
71 PolicyRegistrationCallback callback); 76 PolicyRegistrationCallback callback);
72 77
73 scoped_ptr<CloudPolicyClientRegistrationHelper> registration_helper_; 78 scoped_ptr<CloudPolicyClientRegistrationHelper> registration_helper_;
74 79
80 // Weak pointer to the token service we use to authenticate during
81 // CloudPolicyClient registration.
82 ProfileOAuth2TokenService* oauth2_token_service_;
83
75 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService); 84 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninService);
76 }; 85 };
77 86
78 } // namespace policy 87 } // namespace policy
79 88
80 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_ 89 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698