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_CLOUD_POLICY_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 class UserCloudPolicyManager : public CloudPolicyManager { | 25 class UserCloudPolicyManager : public CloudPolicyManager { |
26 public: | 26 public: |
27 UserCloudPolicyManager(Profile* profile, | 27 UserCloudPolicyManager(Profile* profile, |
28 scoped_ptr<UserCloudPolicyStore> store); | 28 scoped_ptr<UserCloudPolicyStore> store); |
29 virtual ~UserCloudPolicyManager(); | 29 virtual ~UserCloudPolicyManager(); |
30 | 30 |
31 // Initializes the cloud connection. |local_state| and | 31 // Initializes the cloud connection. |local_state| and |
32 // |device_management_service| must stay valid until this object is deleted or | 32 // |device_management_service| must stay valid until this object is deleted or |
33 // DisconnectAndRemovePolicy() gets called. Virtual for mocking. | 33 // DisconnectAndRemovePolicy() gets called. Virtual for mocking. |
34 virtual void Connect(PrefService* local_state, | 34 virtual void Connect(PrefService* local_state, |
35 DeviceManagementService* device_management_service); | 35 scoped_ptr<CloudPolicyClient> client); |
36 | 36 |
37 // Shuts down the UserCloudPolicyManager (removes and stops refreshing the | 37 // Shuts down the UserCloudPolicyManager (removes and stops refreshing the |
38 // cached cloud policy). This is typically called when a profile is being | 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 | 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. | 40 // provided by this object until the next time Initialize() is invoked. |
41 void DisconnectAndRemovePolicy(); | 41 void DisconnectAndRemovePolicy(); |
42 | 42 |
43 // Returns true if the underlying CloudPolicyClient is already registered. | 43 // Returns true if the underlying CloudPolicyClient is already registered. |
44 // Virtual for mocking. | 44 // Virtual for mocking. |
45 virtual bool IsClientRegistered() const; | 45 virtual bool IsClientRegistered() const; |
46 | 46 |
47 // Register the CloudPolicyClient using the passed OAuth token. | 47 // Register the CloudPolicyClient using the passed OAuth token. This contacts |
| 48 // the DMServer to mint a new DMToken. |
48 void RegisterClient(const std::string& access_token); | 49 void RegisterClient(const std::string& access_token); |
49 | 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 |
50 private: | 57 private: |
51 // The profile this instance belongs to. | 58 // The profile this instance belongs to. |
52 Profile* profile_; | 59 Profile* profile_; |
53 | 60 |
54 // Typed pointer to the store owned by UserCloudPolicyManager. Note that | 61 // Typed pointer to the store owned by UserCloudPolicyManager. Note that |
55 // CloudPolicyManager only keeps a plain CloudPolicyStore pointer. | 62 // CloudPolicyManager only keeps a plain CloudPolicyStore pointer. |
56 scoped_ptr<UserCloudPolicyStore> store_; | 63 scoped_ptr<UserCloudPolicyStore> store_; |
57 | 64 |
58 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); | 65 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); |
59 }; | 66 }; |
60 | 67 |
61 } // namespace policy | 68 } // namespace policy |
62 | 69 |
63 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ | 70 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
OLD | NEW |