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" |
11 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" | 11 #include "chrome/browser/policy/cloud/cloud_policy_constants.h" |
12 #include "chrome/browser/policy/cloud/cloud_policy_service.h" | 12 #include "chrome/browser/policy/cloud/cloud_policy_service.h" |
13 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 13 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
14 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" | 14 #include "chrome/browser/policy/cloud/user_cloud_policy_store.h" |
15 #include "chrome/browser/policy/policy_types.h" | 15 #include "chrome/browser/policy/policy_types.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "components/policy/core/common/policy_pref_names.h" |
17 #include "net/url_request/url_request_context_getter.h" | 17 #include "net/url_request/url_request_context_getter.h" |
18 | 18 |
19 namespace em = enterprise_management; | 19 namespace em = enterprise_management; |
20 | 20 |
21 namespace policy { | 21 namespace policy { |
22 | 22 |
23 UserCloudPolicyManager::UserCloudPolicyManager( | 23 UserCloudPolicyManager::UserCloudPolicyManager( |
24 Profile* profile, | 24 Profile* profile, |
25 scoped_ptr<UserCloudPolicyStore> store, | 25 scoped_ptr<UserCloudPolicyStore> store, |
26 scoped_ptr<CloudExternalDataManager> external_data_manager, | 26 scoped_ptr<CloudExternalDataManager> external_data_manager, |
(...skipping 18 matching lines...) Expand all Loading... |
45 CloudPolicyManager::Shutdown(); | 45 CloudPolicyManager::Shutdown(); |
46 BrowserContextKeyedService::Shutdown(); | 46 BrowserContextKeyedService::Shutdown(); |
47 } | 47 } |
48 | 48 |
49 void UserCloudPolicyManager::Connect( | 49 void UserCloudPolicyManager::Connect( |
50 PrefService* local_state, | 50 PrefService* local_state, |
51 scoped_refptr<net::URLRequestContextGetter> request_context, | 51 scoped_refptr<net::URLRequestContextGetter> request_context, |
52 scoped_ptr<CloudPolicyClient> client) { | 52 scoped_ptr<CloudPolicyClient> client) { |
53 core()->Connect(client.Pass()); | 53 core()->Connect(client.Pass()); |
54 core()->StartRefreshScheduler(); | 54 core()->StartRefreshScheduler(); |
55 core()->TrackRefreshDelayPref(local_state, prefs::kUserPolicyRefreshRate); | 55 core()->TrackRefreshDelayPref(local_state, |
| 56 policy_prefs::kUserPolicyRefreshRate); |
56 if (external_data_manager_) | 57 if (external_data_manager_) |
57 external_data_manager_->Connect(request_context); | 58 external_data_manager_->Connect(request_context); |
58 } | 59 } |
59 | 60 |
60 // static | 61 // static |
61 scoped_ptr<CloudPolicyClient> | 62 scoped_ptr<CloudPolicyClient> |
62 UserCloudPolicyManager::CreateCloudPolicyClient( | 63 UserCloudPolicyManager::CreateCloudPolicyClient( |
63 DeviceManagementService* device_management_service) { | 64 DeviceManagementService* device_management_service) { |
64 return make_scoped_ptr( | 65 return make_scoped_ptr( |
65 new CloudPolicyClient(std::string(), std::string(), | 66 new CloudPolicyClient(std::string(), std::string(), |
66 USER_AFFILIATION_NONE, | 67 USER_AFFILIATION_NONE, |
67 NULL, device_management_service)).Pass(); | 68 NULL, device_management_service)).Pass(); |
68 } | 69 } |
69 | 70 |
70 void UserCloudPolicyManager::DisconnectAndRemovePolicy() { | 71 void UserCloudPolicyManager::DisconnectAndRemovePolicy() { |
71 if (external_data_manager_) | 72 if (external_data_manager_) |
72 external_data_manager_->Disconnect(); | 73 external_data_manager_->Disconnect(); |
73 core()->Disconnect(); | 74 core()->Disconnect(); |
74 // When the |store_| is cleared, it informs the |external_data_manager_| that | 75 // When the |store_| is cleared, it informs the |external_data_manager_| that |
75 // all external data references have been removed, causing the | 76 // all external data references have been removed, causing the |
76 // |external_data_manager_| to clear its cache as well. | 77 // |external_data_manager_| to clear its cache as well. |
77 store_->Clear(); | 78 store_->Clear(); |
78 } | 79 } |
79 | 80 |
80 bool UserCloudPolicyManager::IsClientRegistered() const { | 81 bool UserCloudPolicyManager::IsClientRegistered() const { |
81 return client() && client()->is_registered(); | 82 return client() && client()->is_registered(); |
82 } | 83 } |
83 | 84 |
84 } // namespace policy | 85 } // namespace policy |
OLD | NEW |