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_local_account_policy_provider.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/policy/device_local_account.h" | 9 #include "chrome/browser/chromeos/policy/device_local_account.h" |
10 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana
ger.h" | 10 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana
ger.h" |
11 #include "chromeos/dbus/power_policy_controller.h" | 11 #include "chromeos/dbus/power_policy_controller.h" |
12 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 12 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
13 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 13 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
14 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" | 14 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" |
15 #include "components/policy/core/common/policy_bundle.h" | 15 #include "components/policy/core/common/policy_bundle.h" |
16 #include "components/policy/core/common/policy_map.h" | 16 #include "components/policy/core/common/policy_map.h" |
17 #include "components/policy/core/common/policy_namespace.h" | 17 #include "components/policy/core/common/policy_namespace.h" |
18 #include "components/policy/core/common/policy_types.h" | |
19 #include "policy/policy_constants.h" | 18 #include "policy/policy_constants.h" |
20 | 19 |
21 namespace policy { | 20 namespace policy { |
22 | 21 |
23 DeviceLocalAccountPolicyProvider::DeviceLocalAccountPolicyProvider( | 22 DeviceLocalAccountPolicyProvider::DeviceLocalAccountPolicyProvider( |
24 const std::string& user_id, | 23 const std::string& user_id, |
25 DeviceLocalAccountPolicyService* service, | 24 DeviceLocalAccountPolicyService* service, |
26 scoped_ptr<PolicyMap> chrome_policy_overrides) | 25 scoped_ptr<PolicyMap> chrome_policy_overrides) |
27 : user_id_(user_id), | 26 : user_id_(user_id), |
28 service_(service), | 27 service_(service), |
(...skipping 24 matching lines...) Expand all Loading... |
53 if (type == DeviceLocalAccount::TYPE_PUBLIC_SESSION) { | 52 if (type == DeviceLocalAccount::TYPE_PUBLIC_SESSION) { |
54 chrome_policy_overrides.reset(new PolicyMap()); | 53 chrome_policy_overrides.reset(new PolicyMap()); |
55 | 54 |
56 // Exit the session when the lid is closed. The default behavior is to | 55 // Exit the session when the lid is closed. The default behavior is to |
57 // suspend while leaving the session running, which is not desirable for | 56 // suspend while leaving the session running, which is not desirable for |
58 // public sessions. | 57 // public sessions. |
59 chrome_policy_overrides->Set( | 58 chrome_policy_overrides->Set( |
60 key::kLidCloseAction, | 59 key::kLidCloseAction, |
61 POLICY_LEVEL_MANDATORY, | 60 POLICY_LEVEL_MANDATORY, |
62 POLICY_SCOPE_MACHINE, | 61 POLICY_SCOPE_MACHINE, |
63 POLICY_SOURCE_ENTERPRISE_OVERRIDE, | |
64 new base::FundamentalValue( | 62 new base::FundamentalValue( |
65 chromeos::PowerPolicyController::ACTION_STOP_SESSION), | 63 chromeos::PowerPolicyController::ACTION_STOP_SESSION), |
66 NULL); | 64 NULL); |
67 // Force the |ShelfAutoHideBehavior| policy to |Never|, ensuring that the | 65 // Force the |ShelfAutoHideBehavior| policy to |Never|, ensuring that the |
68 // ash shelf does not auto-hide. | 66 // ash shelf does not auto-hide. |
69 chrome_policy_overrides->Set( | 67 chrome_policy_overrides->Set( |
70 key::kShelfAutoHideBehavior, | 68 key::kShelfAutoHideBehavior, |
71 POLICY_LEVEL_MANDATORY, | 69 POLICY_LEVEL_MANDATORY, |
72 POLICY_SCOPE_MACHINE, | 70 POLICY_SCOPE_MACHINE, |
73 POLICY_SOURCE_ENTERPRISE_OVERRIDE, | |
74 new base::StringValue("Never"), | 71 new base::StringValue("Never"), |
75 NULL); | 72 NULL); |
76 // Force the |ShowLogoutButtonInTray| policy to |true|, ensuring that a big, | 73 // Force the |ShowLogoutButtonInTray| policy to |true|, ensuring that a big, |
77 // red logout button is shown in the ash system tray. | 74 // red logout button is shown in the ash system tray. |
78 chrome_policy_overrides->Set( | 75 chrome_policy_overrides->Set( |
79 key::kShowLogoutButtonInTray, | 76 key::kShowLogoutButtonInTray, |
80 POLICY_LEVEL_MANDATORY, | 77 POLICY_LEVEL_MANDATORY, |
81 POLICY_SCOPE_MACHINE, | 78 POLICY_SCOPE_MACHINE, |
82 POLICY_SOURCE_ENTERPRISE_OVERRIDE, | |
83 new base::FundamentalValue(true), | 79 new base::FundamentalValue(true), |
84 NULL); | 80 NULL); |
85 // Force the |FullscreenAllowed| policy to |false|, ensuring that the ash | 81 // Force the |FullscreenAllowed| policy to |false|, ensuring that the ash |
86 // shelf cannot be hidden by entering fullscreen mode. | 82 // shelf cannot be hidden by entering fullscreen mode. |
87 chrome_policy_overrides->Set( | 83 chrome_policy_overrides->Set( |
88 key::kFullscreenAllowed, | 84 key::kFullscreenAllowed, |
89 POLICY_LEVEL_MANDATORY, | 85 POLICY_LEVEL_MANDATORY, |
90 POLICY_SCOPE_MACHINE, | 86 POLICY_SCOPE_MACHINE, |
91 POLICY_SOURCE_ENTERPRISE_OVERRIDE, | |
92 new base::FundamentalValue(false), | 87 new base::FundamentalValue(false), |
93 NULL); | 88 NULL); |
94 } | 89 } |
95 | 90 |
96 scoped_ptr<DeviceLocalAccountPolicyProvider> provider( | 91 scoped_ptr<DeviceLocalAccountPolicyProvider> provider( |
97 new DeviceLocalAccountPolicyProvider(user_id, | 92 new DeviceLocalAccountPolicyProvider(user_id, |
98 device_local_account_policy_service, | 93 device_local_account_policy_service, |
99 chrome_policy_overrides.Pass())); | 94 chrome_policy_overrides.Pass())); |
100 return provider.Pass(); | 95 return provider.Pass(); |
101 } | 96 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 163 } |
169 | 164 |
170 // Apply overrides. | 165 // Apply overrides. |
171 if (chrome_policy_overrides_) { | 166 if (chrome_policy_overrides_) { |
172 PolicyMap& chrome_policy = | 167 PolicyMap& chrome_policy = |
173 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); | 168 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())); |
174 for (PolicyMap::const_iterator it(chrome_policy_overrides_->begin()); | 169 for (PolicyMap::const_iterator it(chrome_policy_overrides_->begin()); |
175 it != chrome_policy_overrides_->end(); | 170 it != chrome_policy_overrides_->end(); |
176 ++it) { | 171 ++it) { |
177 const PolicyMap::Entry& entry = it->second; | 172 const PolicyMap::Entry& entry = it->second; |
178 chrome_policy.Set(it->first, | 173 chrome_policy.Set( |
179 entry.level, | 174 it->first, entry.level, entry.scope, entry.value->DeepCopy(), NULL); |
180 entry.scope, | |
181 entry.source, | |
182 entry.value->DeepCopy(), | |
183 nullptr); | |
184 } | 175 } |
185 } | 176 } |
186 | 177 |
187 UpdatePolicy(bundle.Pass()); | 178 UpdatePolicy(bundle.Pass()); |
188 } | 179 } |
189 | 180 |
190 } // namespace policy | 181 } // namespace policy |
OLD | NEW |