| 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_policy_manager.h" | 5 #include "chrome/browser/policy/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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/policy/cloud_policy_service.h" | 10 #include "chrome/browser/policy/cloud_policy_service.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return store()->is_initialized(); | 39 return store()->is_initialized(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void CloudPolicyManager::RefreshPolicies() { | 42 void CloudPolicyManager::RefreshPolicies() { |
| 43 if (service()) { | 43 if (service()) { |
| 44 waiting_for_policy_refresh_ = true; | 44 waiting_for_policy_refresh_ = true; |
| 45 service()->RefreshPolicy( | 45 service()->RefreshPolicy( |
| 46 base::Bind(&CloudPolicyManager::OnRefreshComplete, | 46 base::Bind(&CloudPolicyManager::OnRefreshComplete, |
| 47 base::Unretained(this))); | 47 base::Unretained(this))); |
| 48 } else { | 48 } else { |
| 49 OnRefreshComplete(); | 49 OnRefreshComplete(false); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 void CloudPolicyManager::OnStoreLoaded(CloudPolicyStore* cloud_policy_store) { | 53 void CloudPolicyManager::OnStoreLoaded(CloudPolicyStore* cloud_policy_store) { |
| 54 DCHECK_EQ(store(), cloud_policy_store); | 54 DCHECK_EQ(store(), cloud_policy_store); |
| 55 CheckAndPublishPolicy(); | 55 CheckAndPublishPolicy(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CloudPolicyManager::OnStoreError(CloudPolicyStore* cloud_policy_store) { | 58 void CloudPolicyManager::OnStoreError(CloudPolicyStore* cloud_policy_store) { |
| 59 DCHECK_EQ(store(), cloud_policy_store); | 59 DCHECK_EQ(store(), cloud_policy_store); |
| 60 // No action required, the old policy is still valid. | 60 // No action required, the old policy is still valid. |
| 61 } | 61 } |
| 62 | 62 |
| 63 void CloudPolicyManager::CheckAndPublishPolicy() { | 63 void CloudPolicyManager::CheckAndPublishPolicy() { |
| 64 if (IsInitializationComplete() && !waiting_for_policy_refresh_) { | 64 if (IsInitializationComplete() && !waiting_for_policy_refresh_) { |
| 65 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); | 65 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); |
| 66 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).CopyFrom( | 66 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).CopyFrom( |
| 67 store()->policy_map()); | 67 store()->policy_map()); |
| 68 UpdatePolicy(bundle.Pass()); | 68 UpdatePolicy(bundle.Pass()); |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 void CloudPolicyManager::OnRefreshComplete() { | 72 void CloudPolicyManager::OnRefreshComplete(bool success) { |
| 73 waiting_for_policy_refresh_ = false; | 73 waiting_for_policy_refresh_ = false; |
| 74 CheckAndPublishPolicy(); | 74 CheckAndPublishPolicy(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 } // namespace policy | 77 } // namespace policy |
| OLD | NEW |