| 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/device_local_account_policy_provider.h" | 5 #include "chrome/browser/policy/device_local_account_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/policy/policy_bundle.h" | 8 #include "chrome/browser/policy/policy_bundle.h" |
| 9 #include "chrome/browser/policy/policy_service.h" | 9 #include "chrome/browser/policy/policy_service.h" |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 } | 50 } |
| 51 | 51 |
| 52 void DeviceLocalAccountPolicyProvider::OnDeviceLocalAccountsChanged() { | 52 void DeviceLocalAccountPolicyProvider::OnDeviceLocalAccountsChanged() { |
| 53 UpdateFromBroker(); | 53 UpdateFromBroker(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 DeviceLocalAccountPolicyBroker* DeviceLocalAccountPolicyProvider::GetBroker() { | 56 DeviceLocalAccountPolicyBroker* DeviceLocalAccountPolicyProvider::GetBroker() { |
| 57 return service_->GetBrokerForAccount(account_id_); | 57 return service_->GetBrokerForAccount(account_id_); |
| 58 } | 58 } |
| 59 | 59 |
| 60 void DeviceLocalAccountPolicyProvider::ReportPolicyRefresh() { | 60 void DeviceLocalAccountPolicyProvider::ReportPolicyRefresh(bool success) { |
| 61 waiting_for_policy_refresh_ = false; | 61 waiting_for_policy_refresh_ = false; |
| 62 UpdateFromBroker(); | 62 UpdateFromBroker(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void DeviceLocalAccountPolicyProvider::UpdateFromBroker() { | 65 void DeviceLocalAccountPolicyProvider::UpdateFromBroker() { |
| 66 DeviceLocalAccountPolicyBroker* broker = GetBroker(); | 66 DeviceLocalAccountPolicyBroker* broker = GetBroker(); |
| 67 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); | 67 scoped_ptr<PolicyBundle> bundle(new PolicyBundle()); |
| 68 if (broker) { | 68 if (broker) { |
| 69 store_initialized_ |= broker->store()->is_initialized(); | 69 store_initialized_ |= broker->store()->is_initialized(); |
| 70 if (!waiting_for_policy_refresh_) { | 70 if (!waiting_for_policy_refresh_) { |
| 71 // Copy policy from the broker. | 71 // Copy policy from the broker. |
| 72 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).CopyFrom( | 72 bundle->Get(POLICY_DOMAIN_CHROME, std::string()).CopyFrom( |
| 73 broker->store()->policy_map()); | 73 broker->store()->policy_map()); |
| 74 } else { | 74 } else { |
| 75 // Wait for the refresh to finish. | 75 // Wait for the refresh to finish. |
| 76 return; | 76 return; |
| 77 } | 77 } |
| 78 } else { | 78 } else { |
| 79 // Keep existing policy, but do send an update. | 79 // Keep existing policy, but do send an update. |
| 80 waiting_for_policy_refresh_ = false; | 80 waiting_for_policy_refresh_ = false; |
| 81 weak_factory_.InvalidateWeakPtrs(); | 81 weak_factory_.InvalidateWeakPtrs(); |
| 82 bundle->CopyFrom(policies()); | 82 bundle->CopyFrom(policies()); |
| 83 } | 83 } |
| 84 UpdatePolicy(bundle.Pass()); | 84 UpdatePolicy(bundle.Pass()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace policy | 87 } // namespace policy |
| OLD | NEW |