| 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/chromeos/policy/device_policy_decoder_chromeos.h" | 5 #include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/chromeos/policy/app_pack_updater.h" | |
| 12 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" | 11 #include "chrome/browser/chromeos/policy/enterprise_install_attributes.h" |
| 13 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 12 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
| 14 #include "chrome/browser/policy/policy_map.h" | 13 #include "chrome/browser/policy/policy_map.h" |
| 15 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" | 14 #include "chrome/browser/policy/proto/chromeos/chrome_device_policy.pb.h" |
| 16 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 17 #include "chromeos/dbus/update_engine_client.h" | 16 #include "chromeos/dbus/update_engine_client.h" |
| 18 #include "policy/policy_constants.h" | 17 #include "policy/policy_constants.h" |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 20 | 19 |
| 21 using google::protobuf::RepeatedField; | 20 using google::protobuf::RepeatedField; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 container.ephemeral_users_enabled())); | 114 container.ephemeral_users_enabled())); |
| 116 } | 115 } |
| 117 } | 116 } |
| 118 | 117 |
| 119 if (policy.has_device_local_accounts()) { | 118 if (policy.has_device_local_accounts()) { |
| 120 const em::DeviceLocalAccountsProto& container( | 119 const em::DeviceLocalAccountsProto& container( |
| 121 policy.device_local_accounts()); | 120 policy.device_local_accounts()); |
| 122 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = | 121 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = |
| 123 container.account(); | 122 container.account(); |
| 124 if (accounts.size() > 0) { | 123 if (accounts.size() > 0) { |
| 125 ListValue* account_list = new ListValue(); | 124 scoped_ptr<base::ListValue> account_list(new base::ListValue()); |
| 126 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; | 125 RepeatedPtrField<em::DeviceLocalAccountInfoProto>::const_iterator entry; |
| 127 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { | 126 for (entry = accounts.begin(); entry != accounts.end(); ++entry) { |
| 128 if (entry->has_id()) | 127 scoped_ptr<base::DictionaryValue> entry_dict( |
| 129 account_list->AppendString(entry->id()); | 128 new base::DictionaryValue()); |
| 129 if (entry->has_type()) { |
| 130 if (entry->has_account_id()) { |
| 131 entry_dict->SetStringWithoutPathExpansion( |
| 132 chromeos::kAccountsPrefDeviceLocalAccountsKeyId, |
| 133 entry->account_id()); |
| 134 } |
| 135 entry_dict->SetIntegerWithoutPathExpansion( |
| 136 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, entry->type()); |
| 137 if (entry->kiosk_app().has_app_id()) { |
| 138 entry_dict->SetStringWithoutPathExpansion( |
| 139 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| 140 entry->kiosk_app().app_id()); |
| 141 } |
| 142 if (entry->kiosk_app().has_update_url()) { |
| 143 entry_dict->SetStringWithoutPathExpansion( |
| 144 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppUpdateURL, |
| 145 entry->kiosk_app().update_url()); |
| 146 } |
| 147 } else if (entry->has_id()) { |
| 148 // Deprecated public session specification. |
| 149 entry_dict->SetStringWithoutPathExpansion( |
| 150 chromeos::kAccountsPrefDeviceLocalAccountsKeyId, entry->id()); |
| 151 entry_dict->SetIntegerWithoutPathExpansion( |
| 152 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, |
| 153 chromeos::DEVICE_LOCAL_ACCOUNT_TYPE_PUBLIC_SESSION); |
| 154 } |
| 155 account_list->Append(entry_dict.release()); |
| 130 } | 156 } |
| 131 policies->Set(key::kDeviceLocalAccounts, | 157 policies->Set(key::kDeviceLocalAccounts, |
| 132 POLICY_LEVEL_MANDATORY, | 158 POLICY_LEVEL_MANDATORY, |
| 133 POLICY_SCOPE_MACHINE, | 159 POLICY_SCOPE_MACHINE, |
| 134 account_list); | 160 account_list.release()); |
| 135 } | 161 } |
| 136 if (container.has_auto_login_id()) { | 162 if (container.has_auto_login_id()) { |
| 137 policies->Set(key::kDeviceLocalAccountAutoLoginId, | 163 policies->Set(key::kDeviceLocalAccountAutoLoginId, |
| 138 POLICY_LEVEL_MANDATORY, | 164 POLICY_LEVEL_MANDATORY, |
| 139 POLICY_SCOPE_MACHINE, | 165 POLICY_SCOPE_MACHINE, |
| 140 Value::CreateStringValue(container.auto_login_id())); | 166 Value::CreateStringValue(container.auto_login_id())); |
| 141 } | 167 } |
| 142 if (container.has_auto_login_delay()) { | 168 if (container.has_auto_login_delay()) { |
| 143 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, | 169 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, |
| 144 POLICY_LEVEL_MANDATORY, | 170 POLICY_LEVEL_MANDATORY, |
| 145 POLICY_SCOPE_MACHINE, | 171 POLICY_SCOPE_MACHINE, |
| 146 DecodeIntegerValue(container.auto_login_delay())); | 172 DecodeIntegerValue(container.auto_login_delay())); |
| 147 } | 173 } |
| 174 if (container.has_enable_auto_login_bailout()) { |
| 175 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled, |
| 176 POLICY_LEVEL_MANDATORY, |
| 177 POLICY_SCOPE_MACHINE, |
| 178 Value::CreateBooleanValue( |
| 179 container.enable_auto_login_bailout())); |
| 180 } |
| 148 } | 181 } |
| 149 } | 182 } |
| 150 | 183 |
| 151 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy, | 184 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy, |
| 152 PolicyMap* policies, | 185 PolicyMap* policies, |
| 153 EnterpriseInstallAttributes* install_attributes) { | 186 EnterpriseInstallAttributes* install_attributes) { |
| 154 // No policies if this is not KIOSK. | 187 // No policies if this is not KIOSK. |
| 155 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK) | 188 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK) |
| 156 return; | 189 return; |
| 157 | 190 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 224 } |
| 192 } | 225 } |
| 193 | 226 |
| 194 if (policy.has_app_pack()) { | 227 if (policy.has_app_pack()) { |
| 195 const em::AppPackProto& container(policy.app_pack()); | 228 const em::AppPackProto& container(policy.app_pack()); |
| 196 base::ListValue* app_pack_list = new base::ListValue(); | 229 base::ListValue* app_pack_list = new base::ListValue(); |
| 197 for (int i = 0; i < container.app_pack_size(); ++i) { | 230 for (int i = 0; i < container.app_pack_size(); ++i) { |
| 198 const em::AppPackEntryProto& entry(container.app_pack(i)); | 231 const em::AppPackEntryProto& entry(container.app_pack(i)); |
| 199 if (entry.has_extension_id() && entry.has_update_url()) { | 232 if (entry.has_extension_id() && entry.has_update_url()) { |
| 200 base::DictionaryValue* dict = new base::DictionaryValue(); | 233 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 201 dict->SetString(AppPackUpdater::kExtensionId, entry.extension_id()); | 234 dict->SetString(chromeos::kAppPackKeyExtensionId, entry.extension_id()); |
| 202 dict->SetString(AppPackUpdater::kUpdateUrl, entry.update_url()); | 235 dict->SetString(chromeos::kAppPackKeyUpdateUrl, entry.update_url()); |
| 203 app_pack_list->Append(dict); | 236 app_pack_list->Append(dict); |
| 204 } | 237 } |
| 205 } | 238 } |
| 206 policies->Set(key::kDeviceAppPack, | 239 policies->Set(key::kDeviceAppPack, |
| 207 POLICY_LEVEL_MANDATORY, | 240 POLICY_LEVEL_MANDATORY, |
| 208 POLICY_SCOPE_MACHINE, | 241 POLICY_SCOPE_MACHINE, |
| 209 app_pack_list); | 242 app_pack_list); |
| 210 } | 243 } |
| 211 | 244 |
| 212 if (policy.has_pinned_apps()) { | 245 if (policy.has_pinned_apps()) { |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 // Decode the various groups of policies. | 526 // Decode the various groups of policies. |
| 494 DecodeLoginPolicies(policy, policies); | 527 DecodeLoginPolicies(policy, policies); |
| 495 DecodeKioskPolicies(policy, policies, install_attributes); | 528 DecodeKioskPolicies(policy, policies, install_attributes); |
| 496 DecodeNetworkPolicies(policy, policies, install_attributes); | 529 DecodeNetworkPolicies(policy, policies, install_attributes); |
| 497 DecodeReportingPolicies(policy, policies); | 530 DecodeReportingPolicies(policy, policies); |
| 498 DecodeAutoUpdatePolicies(policy, policies); | 531 DecodeAutoUpdatePolicies(policy, policies); |
| 499 DecodeGenericPolicies(policy, policies); | 532 DecodeGenericPolicies(policy, policies); |
| 500 } | 533 } |
| 501 | 534 |
| 502 } // namespace policy | 535 } // namespace policy |
| OLD | NEW |