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 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" | 5 #include "chrome/browser/policy/cloud/user_cloud_policy_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/sequenced_task_runner.h" | 9 #include "base/sequenced_task_runner.h" |
10 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" | 10 #include "chrome/browser/policy/cloud/cloud_external_data_manager.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 void UserCloudPolicyManager::Connect( | 59 void UserCloudPolicyManager::Connect( |
60 PrefService* local_state, | 60 PrefService* local_state, |
61 scoped_refptr<net::URLRequestContextGetter> request_context, | 61 scoped_refptr<net::URLRequestContextGetter> request_context, |
62 scoped_ptr<CloudPolicyClient> client) { | 62 scoped_ptr<CloudPolicyClient> client) { |
63 core()->Connect(client.Pass()); | 63 core()->Connect(client.Pass()); |
64 core()->StartRefreshScheduler(); | 64 core()->StartRefreshScheduler(); |
65 core()->TrackRefreshDelayPref(local_state, | 65 core()->TrackRefreshDelayPref(local_state, |
66 policy_prefs::kUserPolicyRefreshRate); | 66 policy_prefs::kUserPolicyRefreshRate); |
67 if (external_data_manager_) | 67 if (external_data_manager_) |
68 external_data_manager_->Connect(request_context); | 68 external_data_manager_->Connect(request_context); |
| 69 |
69 CreateComponentCloudPolicyService(component_policy_cache_path_, | 70 CreateComponentCloudPolicyService(component_policy_cache_path_, |
70 request_context); | 71 request_context); |
71 } | 72 } |
72 | 73 |
73 // static | 74 // static |
74 scoped_ptr<CloudPolicyClient> | 75 scoped_ptr<CloudPolicyClient> |
75 UserCloudPolicyManager::CreateCloudPolicyClient( | 76 UserCloudPolicyManager::CreateCloudPolicyClient( |
76 DeviceManagementService* device_management_service, | 77 DeviceManagementService* device_management_service, |
77 scoped_refptr<net::URLRequestContextGetter> request_context) { | 78 scoped_refptr<net::URLRequestContextGetter> request_context) { |
78 return make_scoped_ptr( | 79 return make_scoped_ptr( |
79 new CloudPolicyClient( | 80 new CloudPolicyClient( |
80 std::string(), | 81 std::string(), |
81 std::string(), | 82 std::string(), |
82 USER_AFFILIATION_NONE, | 83 USER_AFFILIATION_NONE, |
83 NULL, | 84 NULL, |
84 device_management_service, | 85 device_management_service, |
85 request_context)).Pass(); | 86 request_context)).Pass(); |
86 } | 87 } |
87 | 88 |
88 void UserCloudPolicyManager::DisconnectAndRemovePolicy() { | 89 void UserCloudPolicyManager::DisconnectAndRemovePolicy() { |
89 if (external_data_manager_) | 90 if (external_data_manager_) |
90 external_data_manager_->Disconnect(); | 91 external_data_manager_->Disconnect(); |
91 core()->Disconnect(); | 92 core()->Disconnect(); |
| 93 |
| 94 // store_->Clear() will publish the updated, empty policy. The component |
| 95 // policy service must be cleared before OnStoreLoaded() is issued, so that |
| 96 // component policies are also empty at CheckAndPublishPolicy(). |
| 97 ClearAndDestroyComponentCloudPolicyService(); |
| 98 |
92 // When the |store_| is cleared, it informs the |external_data_manager_| that | 99 // When the |store_| is cleared, it informs the |external_data_manager_| that |
93 // all external data references have been removed, causing the | 100 // all external data references have been removed, causing the |
94 // |external_data_manager_| to clear its cache as well. | 101 // |external_data_manager_| to clear its cache as well. |
95 store_->Clear(); | 102 store_->Clear(); |
96 } | 103 } |
97 | 104 |
98 bool UserCloudPolicyManager::IsClientRegistered() const { | 105 bool UserCloudPolicyManager::IsClientRegistered() const { |
99 return client() && client()->is_registered(); | 106 return client() && client()->is_registered(); |
100 } | 107 } |
101 | 108 |
102 } // namespace policy | 109 } // namespace policy |
OLD | NEW |