| Index: chrome/browser/policy/user_cloud_policy_manager_chromeos.cc
|
| diff --git a/chrome/browser/policy/user_cloud_policy_manager.cc b/chrome/browser/policy/user_cloud_policy_manager_chromeos.cc
|
| similarity index 65%
|
| copy from chrome/browser/policy/user_cloud_policy_manager.cc
|
| copy to chrome/browser/policy/user_cloud_policy_manager_chromeos.cc
|
| index e1804ad72c2674c3b735df3212819cd4146411c4..5df3ea007c12199d368dcfba070c7ad77a222b15 100644
|
| --- a/chrome/browser/policy/user_cloud_policy_manager.cc
|
| +++ b/chrome/browser/policy/user_cloud_policy_manager_chromeos.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/policy/user_cloud_policy_manager.h"
|
| +#include "chrome/browser/policy/user_cloud_policy_manager_chromeos.h"
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| @@ -12,26 +12,16 @@
|
|
|
| namespace policy {
|
|
|
| -UserCloudPolicyManager::UserCloudPolicyManager(
|
| +UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS(
|
| scoped_ptr<CloudPolicyStore> store,
|
| bool wait_for_policy_fetch)
|
| - : CloudPolicyManager(store.Pass()),
|
| + : CloudPolicyManager(store.get()),
|
| + store_(store.Pass()),
|
| wait_for_policy_fetch_(wait_for_policy_fetch) {}
|
|
|
| -UserCloudPolicyManager::~UserCloudPolicyManager() {}
|
| -
|
| -// static
|
| -scoped_ptr<UserCloudPolicyManager> UserCloudPolicyManager::Create(
|
| - Profile* profile,
|
| - PolicyInit policy_init) {
|
| - scoped_ptr<CloudPolicyStore> store =
|
| - CloudPolicyStore::CreateUserPolicyStore(
|
| - profile, policy_init == POLICY_INIT_IMMEDIATELY);
|
| - return make_scoped_ptr(new UserCloudPolicyManager(
|
| - store.Pass(), policy_init == POLICY_INIT_REFRESH_FROM_SERVER));
|
| -}
|
| +UserCloudPolicyManagerChromeOS::~UserCloudPolicyManagerChromeOS() {}
|
|
|
| -void UserCloudPolicyManager::Initialize(
|
| +void UserCloudPolicyManagerChromeOS::Initialize(
|
| PrefService* local_state,
|
| DeviceManagementService* device_management_service,
|
| UserAffiliation user_affiliation) {
|
| @@ -53,23 +43,16 @@ void UserCloudPolicyManager::Initialize(
|
| // see OnRegistrationStateChanged() below.
|
| if (cloud_policy_client()->is_registered()) {
|
| cloud_policy_service()->RefreshPolicy(
|
| - base::Bind(&UserCloudPolicyManager::OnInitialPolicyFetchComplete,
|
| - base::Unretained(this)));
|
| + base::Bind(
|
| + &UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete,
|
| + base::Unretained(this)));
|
| }
|
| } else {
|
| CancelWaitForPolicyFetch();
|
| }
|
| }
|
|
|
| -void UserCloudPolicyManager::ShutdownAndRemovePolicy() {
|
| - if (cloud_policy_client())
|
| - cloud_policy_client()->RemoveObserver(this);
|
| - ShutdownService();
|
| - local_state_ = NULL;
|
| - cloud_policy_store()->Clear();
|
| -}
|
| -
|
| -void UserCloudPolicyManager::CancelWaitForPolicyFetch() {
|
| +void UserCloudPolicyManagerChromeOS::CancelWaitForPolicyFetch() {
|
| wait_for_policy_fetch_ = false;
|
| CheckAndPublishPolicy();
|
|
|
| @@ -79,11 +62,12 @@ void UserCloudPolicyManager::CancelWaitForPolicyFetch() {
|
| StartRefreshScheduler(local_state_, prefs::kUserPolicyRefreshRate);
|
| }
|
|
|
| -bool UserCloudPolicyManager::IsClientRegistered() const {
|
| +bool UserCloudPolicyManagerChromeOS::IsClientRegistered() const {
|
| return cloud_policy_client() && cloud_policy_client()->is_registered();
|
| }
|
|
|
| -void UserCloudPolicyManager::RegisterClient(const std::string& access_token) {
|
| +void UserCloudPolicyManagerChromeOS::RegisterClient(
|
| + const std::string& access_token) {
|
| DCHECK(cloud_policy_client()) << "Callers must invoke Initialize() first";
|
| if (!cloud_policy_client()->is_registered()) {
|
| DVLOG(1) << "Registering client with access token: " << access_token;
|
| @@ -91,31 +75,33 @@ void UserCloudPolicyManager::RegisterClient(const std::string& access_token) {
|
| }
|
| }
|
|
|
| -void UserCloudPolicyManager::Shutdown() {
|
| +void UserCloudPolicyManagerChromeOS::Shutdown() {
|
| if (cloud_policy_client())
|
| cloud_policy_client()->RemoveObserver(this);
|
| CloudPolicyManager::Shutdown();
|
| }
|
|
|
| -bool UserCloudPolicyManager::IsInitializationComplete() const {
|
| +bool UserCloudPolicyManagerChromeOS::IsInitializationComplete() const {
|
| return CloudPolicyManager::IsInitializationComplete() &&
|
| !wait_for_policy_fetch_;
|
| }
|
|
|
| -void UserCloudPolicyManager::OnPolicyFetched(CloudPolicyClient* client) {
|
| +void UserCloudPolicyManagerChromeOS::OnPolicyFetched(
|
| + CloudPolicyClient* client) {
|
| // No action required. If we're blocked on a policy fetch, we'll learn about
|
| // completion of it through OnInitialPolicyFetchComplete().
|
| }
|
|
|
| -void UserCloudPolicyManager::OnRegistrationStateChanged(
|
| +void UserCloudPolicyManagerChromeOS::OnRegistrationStateChanged(
|
| CloudPolicyClient* client) {
|
| DCHECK_EQ(cloud_policy_client(), client);
|
| if (wait_for_policy_fetch_) {
|
| // If we're blocked on the policy fetch, now is a good time to issue it.
|
| if (cloud_policy_client()->is_registered()) {
|
| cloud_policy_service()->RefreshPolicy(
|
| - base::Bind(&UserCloudPolicyManager::OnInitialPolicyFetchComplete,
|
| - base::Unretained(this)));
|
| + base::Bind(
|
| + &UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete,
|
| + base::Unretained(this)));
|
| } else {
|
| // If the client has switched to not registered, we bail out as this
|
| // indicates the cloud policy setup flow has been aborted.
|
| @@ -124,12 +110,12 @@ void UserCloudPolicyManager::OnRegistrationStateChanged(
|
| }
|
| }
|
|
|
| -void UserCloudPolicyManager::OnClientError(CloudPolicyClient* client) {
|
| +void UserCloudPolicyManagerChromeOS::OnClientError(CloudPolicyClient* client) {
|
| DCHECK_EQ(cloud_policy_client(), client);
|
| CancelWaitForPolicyFetch();
|
| }
|
|
|
| -void UserCloudPolicyManager::OnInitialPolicyFetchComplete() {
|
| +void UserCloudPolicyManagerChromeOS::OnInitialPolicyFetchComplete() {
|
| CancelWaitForPolicyFetch();
|
| }
|
|
|
|
|