| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/policy/device_local_account_extension_tracker.
h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_extension_tracker.
h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_value_map.h" | 8 #include "base/prefs/pref_value_map.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/policy/device_local_account.h" | 10 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 UpdateFromStore(); | 48 UpdateFromStore(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void DeviceLocalAccountExtensionTracker::OnStoreError(CloudPolicyStore* store) { | 51 void DeviceLocalAccountExtensionTracker::OnStoreError(CloudPolicyStore* store) { |
| 52 UpdateFromStore(); | 52 UpdateFromStore(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void DeviceLocalAccountExtensionTracker::UpdateFromStore() { | 55 void DeviceLocalAccountExtensionTracker::UpdateFromStore() { |
| 56 const policy::PolicyMap& policy_map = store_->policy_map(); | 56 const policy::PolicyMap& policy_map = store_->policy_map(); |
| 57 | 57 |
| 58 // TODO(binjin): Use two policy handlers here after |
| 59 // ExtensionManagementPolicyHandler is introduced. |
| 58 extensions::ExtensionInstallForcelistPolicyHandler policy_handler; | 60 extensions::ExtensionInstallForcelistPolicyHandler policy_handler; |
| 59 if (!policy_handler.CheckPolicySettings(policy_map, NULL)) | 61 if (!policy_handler.CheckPolicySettings(policy_map, NULL)) |
| 60 return; | 62 return; |
| 61 | 63 |
| 62 PrefValueMap pref_value_map; | 64 PrefValueMap pref_value_map; |
| 63 policy_handler.ApplyPolicySettings(policy_map, &pref_value_map); | 65 policy_handler.ApplyPolicySettings(policy_map, &pref_value_map); |
| 64 | 66 |
| 65 const base::Value* value = NULL; | 67 const base::Value* value = NULL; |
| 66 const base::DictionaryValue* dict = NULL; | 68 const base::DictionaryValue* dict = NULL; |
| 67 if (!pref_value_map.GetValue(extensions::pref_names::kInstallForceList, | 69 if (!pref_value_map.GetValue(extensions::pref_names::kInstallForceList, |
| 68 &value) || | 70 &value) || |
| 69 !value->GetAsDictionary(&dict)) { | 71 !value->GetAsDictionary(&dict)) { |
| 70 return; | 72 return; |
| 71 } | 73 } |
| 72 | 74 |
| 73 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 75 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
| 74 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, it.key()); | 76 PolicyNamespace ns(POLICY_DOMAIN_EXTENSIONS, it.key()); |
| 75 schema_registry_->RegisterComponent(ns, Schema()); | 77 schema_registry_->RegisterComponent(ns, Schema()); |
| 76 } | 78 } |
| 77 | 79 |
| 78 // Removing an extension from a public session at runtime can happen but is | 80 // Removing an extension from a public session at runtime can happen but is |
| 79 // a rare event. In that case we leave the extension ID in the SchemaRegistry, | 81 // a rare event. In that case we leave the extension ID in the SchemaRegistry, |
| 80 // and it will be purged on the next restart. | 82 // and it will be purged on the next restart. |
| 81 } | 83 } |
| 82 | 84 |
| 83 } // namespace policy | 85 } // namespace policy |
| OLD | NEW |