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_CLOUD_POLICY_MANAGER_H_ | |
6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "chrome/browser/policy/cloud_policy_manager.h" | |
14 | |
15 class PrefService; | |
16 class Profile; | |
17 | |
18 namespace policy { | |
19 | |
20 class DeviceManagementService; | |
21 class UserCloudPolicyStore; | |
22 | |
23 // UserCloudPolicyManager handles initialization of user policy for Chrome | |
24 // Profiles on the desktop platforms. | |
25 class UserCloudPolicyManager : public CloudPolicyManager { | |
26 public: | |
27 UserCloudPolicyManager(Profile* profile, | |
28 scoped_ptr<UserCloudPolicyStore> store); | |
29 virtual ~UserCloudPolicyManager(); | |
30 | |
31 // Initializes the cloud connection. |local_state| and | |
32 // |device_management_service| must stay valid until this object is deleted or | |
33 // DisconnectAndRemovePolicy() gets called. Virtual for mocking. | |
34 virtual void Connect(PrefService* local_state, | |
35 scoped_ptr<CloudPolicyClient> client); | |
36 | |
37 // Shuts down the UserCloudPolicyManager (removes and stops refreshing the | |
38 // cached cloud policy). This is typically called when a profile is being | |
39 // disassociated from a given user (e.g. during signout). No policy will be | |
40 // provided by this object until the next time Initialize() is invoked. | |
41 void DisconnectAndRemovePolicy(); | |
42 | |
43 // Returns true if the underlying CloudPolicyClient is already registered. | |
44 // Virtual for mocking. | |
45 virtual bool IsClientRegistered() const; | |
46 | |
47 // Register the CloudPolicyClient using the passed OAuth token. This contacts | |
48 // the DMServer to mint a new DMToken. | |
49 void RegisterClient(const std::string& access_token); | |
50 | |
51 // Creates a CloudPolicyClient for this client. Used in situations where | |
52 // callers want to create a DMToken without actually initializing the | |
53 // profile's policy infrastructure. | |
54 static scoped_ptr<CloudPolicyClient> CreateCloudPolicyClient( | |
55 DeviceManagementService* device_management_service); | |
56 | |
57 private: | |
58 // The profile this instance belongs to. | |
59 Profile* profile_; | |
60 | |
61 // Typed pointer to the store owned by UserCloudPolicyManager. Note that | |
62 // CloudPolicyManager only keeps a plain CloudPolicyStore pointer. | |
63 scoped_ptr<UserCloudPolicyStore> store_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); | |
66 }; | |
67 | |
68 } // namespace policy | |
69 | |
70 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | |
OLD | NEW |