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/policy/proto/chrome_device_policy.pb.h" | 12 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" |
14 #include "chrome/browser/chromeos/settings/cros_settings_names.h" | 13 #include "chrome/browser/chromeos/settings/cros_settings_names.h" |
15 #include "chrome/browser/policy/policy_map.h" | 14 #include "chrome/browser/policy/policy_map.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_id()) { |
| 130 entry_dict->SetStringWithoutPathExpansion( |
| 131 chromeos::kAccountsPrefDeviceLocalAccountsKeyId, |
| 132 entry->kiosk_app_id()); |
| 133 } |
| 134 entry_dict->SetIntegerWithoutPathExpansion( |
| 135 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, entry->type()); |
| 136 if (entry->has_kiosk_app_id()) { |
| 137 entry_dict->SetStringWithoutPathExpansion( |
| 138 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppId, |
| 139 entry->kiosk_app_id()); |
| 140 } |
| 141 if (entry->has_kiosk_app_update_url()) { |
| 142 entry_dict->SetStringWithoutPathExpansion( |
| 143 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppUpdateURL, |
| 144 entry->kiosk_app_update_url()); |
| 145 } |
| 146 account_list->Append(entry_dict.release()); |
130 } | 147 } |
131 policies->Set(key::kDeviceLocalAccounts, | 148 policies->Set(key::kDeviceLocalAccounts, |
132 POLICY_LEVEL_MANDATORY, | 149 POLICY_LEVEL_MANDATORY, |
133 POLICY_SCOPE_MACHINE, | 150 POLICY_SCOPE_MACHINE, |
134 account_list); | 151 account_list.release()); |
135 } | 152 } |
136 if (container.has_auto_login_id()) { | 153 if (container.has_auto_login_id()) { |
137 policies->Set(key::kDeviceLocalAccountAutoLoginId, | 154 policies->Set(key::kDeviceLocalAccountAutoLoginId, |
138 POLICY_LEVEL_MANDATORY, | 155 POLICY_LEVEL_MANDATORY, |
139 POLICY_SCOPE_MACHINE, | 156 POLICY_SCOPE_MACHINE, |
140 Value::CreateStringValue(container.auto_login_id())); | 157 Value::CreateStringValue(container.auto_login_id())); |
141 } | 158 } |
142 if (container.has_auto_login_delay()) { | 159 if (container.has_auto_login_delay()) { |
143 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, | 160 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, |
144 POLICY_LEVEL_MANDATORY, | 161 POLICY_LEVEL_MANDATORY, |
145 POLICY_SCOPE_MACHINE, | 162 POLICY_SCOPE_MACHINE, |
146 DecodeIntegerValue(container.auto_login_delay())); | 163 DecodeIntegerValue(container.auto_login_delay())); |
147 } | 164 } |
| 165 if (container.has_enable_auto_login_bailout()) { |
| 166 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled, |
| 167 POLICY_LEVEL_MANDATORY, |
| 168 POLICY_SCOPE_MACHINE, |
| 169 Value::CreateBooleanValue( |
| 170 container.enable_auto_login_bailout())); |
| 171 } |
148 } | 172 } |
149 } | 173 } |
150 | 174 |
151 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy, | 175 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy, |
152 PolicyMap* policies, | 176 PolicyMap* policies, |
153 EnterpriseInstallAttributes* install_attributes) { | 177 EnterpriseInstallAttributes* install_attributes) { |
154 // No policies if this is not KIOSK. | 178 // No policies if this is not KIOSK. |
155 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK) | 179 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK) |
156 return; | 180 return; |
157 | 181 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 215 } |
192 } | 216 } |
193 | 217 |
194 if (policy.has_app_pack()) { | 218 if (policy.has_app_pack()) { |
195 const em::AppPackProto& container(policy.app_pack()); | 219 const em::AppPackProto& container(policy.app_pack()); |
196 base::ListValue* app_pack_list = new base::ListValue(); | 220 base::ListValue* app_pack_list = new base::ListValue(); |
197 for (int i = 0; i < container.app_pack_size(); ++i) { | 221 for (int i = 0; i < container.app_pack_size(); ++i) { |
198 const em::AppPackEntryProto& entry(container.app_pack(i)); | 222 const em::AppPackEntryProto& entry(container.app_pack(i)); |
199 if (entry.has_extension_id() && entry.has_update_url()) { | 223 if (entry.has_extension_id() && entry.has_update_url()) { |
200 base::DictionaryValue* dict = new base::DictionaryValue(); | 224 base::DictionaryValue* dict = new base::DictionaryValue(); |
201 dict->SetString(AppPackUpdater::kExtensionId, entry.extension_id()); | 225 dict->SetString(chromeos::kAppPackKeyExtensionId, entry.extension_id()); |
202 dict->SetString(AppPackUpdater::kUpdateUrl, entry.update_url()); | 226 dict->SetString(chromeos::kAppPackKeyUpdateUrl, entry.update_url()); |
203 app_pack_list->Append(dict); | 227 app_pack_list->Append(dict); |
204 } | 228 } |
205 } | 229 } |
206 policies->Set(key::kDeviceAppPack, | 230 policies->Set(key::kDeviceAppPack, |
207 POLICY_LEVEL_MANDATORY, | 231 POLICY_LEVEL_MANDATORY, |
208 POLICY_SCOPE_MACHINE, | 232 POLICY_SCOPE_MACHINE, |
209 app_pack_list); | 233 app_pack_list); |
210 } | 234 } |
211 | 235 |
212 if (policy.has_pinned_apps()) { | 236 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. | 517 // Decode the various groups of policies. |
494 DecodeLoginPolicies(policy, policies); | 518 DecodeLoginPolicies(policy, policies); |
495 DecodeKioskPolicies(policy, policies, install_attributes); | 519 DecodeKioskPolicies(policy, policies, install_attributes); |
496 DecodeNetworkPolicies(policy, policies, install_attributes); | 520 DecodeNetworkPolicies(policy, policies, install_attributes); |
497 DecodeReportingPolicies(policy, policies); | 521 DecodeReportingPolicies(policy, policies); |
498 DecodeAutoUpdatePolicies(policy, policies); | 522 DecodeAutoUpdatePolicies(policy, policies); |
499 DecodeGenericPolicies(policy, policies); | 523 DecodeGenericPolicies(policy, policies); |
500 } | 524 } |
501 | 525 |
502 } // namespace policy | 526 } // namespace policy |
OLD | NEW |