| 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_refresh_scheduler.h" | 10 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 return store_->is_initialized(); | 44 return store_->is_initialized(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void CloudPolicyManager::RefreshPolicies() { | 47 void CloudPolicyManager::RefreshPolicies() { |
| 48 if (service_.get()) { | 48 if (service_.get()) { |
| 49 waiting_for_policy_refresh_ = true; | 49 waiting_for_policy_refresh_ = true; |
| 50 service_->RefreshPolicy( | 50 service_->RefreshPolicy( |
| 51 base::Bind(&CloudPolicyManager::OnRefreshComplete, | 51 base::Bind(&CloudPolicyManager::OnRefreshComplete, |
| 52 base::Unretained(this))); | 52 base::Unretained(this))); |
| 53 } else { | 53 } else { |
| 54 OnRefreshComplete(); | 54 OnRefreshComplete(false); |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CloudPolicyManager::OnStoreLoaded(CloudPolicyStore* store) { | 58 void CloudPolicyManager::OnStoreLoaded(CloudPolicyStore* store) { |
| 59 DCHECK_EQ(store_, store); | 59 DCHECK_EQ(store_, store); |
| 60 CheckAndPublishPolicy(); | 60 CheckAndPublishPolicy(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void CloudPolicyManager::OnStoreError(CloudPolicyStore* store) { | 63 void CloudPolicyManager::OnStoreError(CloudPolicyStore* store) { |
| 64 DCHECK_EQ(store_, store); | 64 DCHECK_EQ(store_, store); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 98 |
| 99 void CloudPolicyManager::CheckAndPublishPolicy() { | 99 void CloudPolicyManager::CheckAndPublishPolicy() { |
| 100 if (IsInitializationComplete() && !waiting_for_policy_refresh_) { | 100 if (IsInitializationComplete() && !waiting_for_policy_refresh_) { |
| 101 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); | 101 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); |
| 102 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).CopyFrom( | 102 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).CopyFrom( |
| 103 store_->policy_map()); | 103 store_->policy_map()); |
| 104 UpdatePolicy(bundle.Pass()); | 104 UpdatePolicy(bundle.Pass()); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 void CloudPolicyManager::OnRefreshComplete() { | 108 void CloudPolicyManager::OnRefreshComplete(bool success) { |
| 109 waiting_for_policy_refresh_ = false; | 109 waiting_for_policy_refresh_ = false; |
| 110 CheckAndPublishPolicy(); | 110 CheckAndPublishPolicy(); |
| 111 } | 111 } |
| 112 | 112 |
| 113 void CloudPolicyManager::UpdateRefreshDelay() { | 113 void CloudPolicyManager::UpdateRefreshDelay() { |
| 114 refresh_scheduler_->SetRefreshDelay(refresh_delay_->GetValue()); | 114 refresh_scheduler_->SetRefreshDelay(refresh_delay_->GetValue()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 } // namespace policy | 117 } // namespace policy |
| OLD | NEW |