| 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/user_cloud_policy_manager.h" | 5 #include "chrome/browser/policy/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 "chrome/browser/policy/cloud_policy_constants.h" | 9 #include "chrome/browser/policy/cloud_policy_constants.h" |
| 10 #include "chrome/browser/policy/cloud_policy_service.h" | 10 #include "chrome/browser/policy/cloud_policy_service.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 profile_(profile), | 26 profile_(profile), |
| 27 store_(store.Pass()) { | 27 store_(store.Pass()) { |
| 28 UserCloudPolicyManagerFactory::GetInstance()->Register(profile_, this); | 28 UserCloudPolicyManagerFactory::GetInstance()->Register(profile_, this); |
| 29 } | 29 } |
| 30 | 30 |
| 31 UserCloudPolicyManager::~UserCloudPolicyManager() { | 31 UserCloudPolicyManager::~UserCloudPolicyManager() { |
| 32 UserCloudPolicyManagerFactory::GetInstance()->Unregister(profile_, this); | 32 UserCloudPolicyManagerFactory::GetInstance()->Unregister(profile_, this); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void UserCloudPolicyManager::Connect( | 35 void UserCloudPolicyManager::Connect( |
| 36 PrefService* local_state, | 36 PrefService* local_state, scoped_ptr<CloudPolicyClient> client) { |
| 37 DeviceManagementService* device_management_service) { | 37 core()->Connect(client.Pass()); |
| 38 core()->Connect( | |
| 39 make_scoped_ptr(new CloudPolicyClient(std::string(), std::string(), | |
| 40 USER_AFFILIATION_NONE, | |
| 41 NULL, device_management_service))); | |
| 42 core()->StartRefreshScheduler(); | 38 core()->StartRefreshScheduler(); |
| 43 core()->TrackRefreshDelayPref(local_state, prefs::kUserPolicyRefreshRate); | 39 core()->TrackRefreshDelayPref(local_state, prefs::kUserPolicyRefreshRate); |
| 44 } | 40 } |
| 45 | 41 |
| 42 // static |
| 43 scoped_ptr<CloudPolicyClient> |
| 44 UserCloudPolicyManager::CreateCloudPolicyClient( |
| 45 DeviceManagementService* device_management_service) { |
| 46 return make_scoped_ptr( |
| 47 new CloudPolicyClient(std::string(), std::string(), |
| 48 USER_AFFILIATION_NONE, |
| 49 NULL, device_management_service)).Pass(); |
| 50 } |
| 51 |
| 46 void UserCloudPolicyManager::DisconnectAndRemovePolicy() { | 52 void UserCloudPolicyManager::DisconnectAndRemovePolicy() { |
| 47 core()->Disconnect(); | 53 core()->Disconnect(); |
| 48 store_->Clear(); | 54 store_->Clear(); |
| 49 } | 55 } |
| 50 | 56 |
| 51 bool UserCloudPolicyManager::IsClientRegistered() const { | 57 bool UserCloudPolicyManager::IsClientRegistered() const { |
| 52 return client() && client()->is_registered(); | 58 return client() && client()->is_registered(); |
| 53 } | 59 } |
| 54 | 60 |
| 55 void UserCloudPolicyManager::RegisterClient(const std::string& access_token) { | 61 void UserCloudPolicyManager::RegisterClient(const std::string& access_token) { |
| 56 DCHECK(client()) << "Callers must invoke Initialize() first"; | 62 DCHECK(client()) << "Callers must invoke Initialize() first"; |
| 57 if (!client()->is_registered()) { | 63 if (!client()->is_registered()) { |
| 58 DVLOG(1) << "Registering client with access token: " << access_token; | 64 DVLOG(1) << "Registering client with access token: " << access_token; |
| 59 client()->Register(em::DeviceRegisterRequest::BROWSER, | 65 client()->Register(em::DeviceRegisterRequest::BROWSER, |
| 60 access_token, std::string(), false); | 66 access_token, std::string(), false); |
| 61 } | 67 } |
| 62 } | 68 } |
| 63 | 69 |
| 64 } // namespace policy | 70 } // namespace policy |
| OLD | NEW |