OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ | 5 #ifndef CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ |
6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ | 6 #define CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/scoped_callback_factory.h" | 11 #include "base/memory/scoped_callback_factory.h" |
12 #include "chrome/browser/chromeos/login/signed_settings.h" | 12 #include "chrome/browser/chromeos/login/signed_settings.h" |
13 #include "chrome/browser/chromeos/login/signed_settings_helper.h" | 13 #include "chrome/browser/chromeos/login/signed_settings_helper.h" |
14 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 14 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
15 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" | 15 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" |
16 | 16 |
17 namespace policy { | 17 namespace policy { |
18 | 18 |
19 class DevicePolicyIdentityStrategy; | 19 class DevicePolicyIdentityStrategy; |
| 20 class EnterpriseInstallAttributes; |
20 class PolicyMap; | 21 class PolicyMap; |
21 | 22 |
22 namespace em = enterprise_management; | 23 namespace em = enterprise_management; |
23 | 24 |
24 // CloudPolicyCacheBase implementation that persists policy information | 25 // CloudPolicyCacheBase implementation that persists policy information |
25 // to ChromeOS' session manager (via SignedSettingsHelper). | 26 // to ChromeOS' session manager (via SignedSettingsHelper). |
26 class DevicePolicyCache : public CloudPolicyCacheBase, | 27 class DevicePolicyCache : public CloudPolicyCacheBase, |
27 public chromeos::SignedSettingsHelper::Callback { | 28 public chromeos::SignedSettingsHelper::Callback { |
28 public: | 29 public: |
29 explicit DevicePolicyCache(DevicePolicyIdentityStrategy* identity_strategy); | 30 explicit DevicePolicyCache(DevicePolicyIdentityStrategy* identity_strategy, |
| 31 EnterpriseInstallAttributes* install_attributes); |
30 virtual ~DevicePolicyCache(); | 32 virtual ~DevicePolicyCache(); |
31 | 33 |
32 // CloudPolicyCacheBase implementation: | 34 // CloudPolicyCacheBase implementation: |
33 virtual void Load() OVERRIDE; | 35 virtual void Load() OVERRIDE; |
34 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; | 36 virtual void SetPolicy(const em::PolicyFetchResponse& policy) OVERRIDE; |
35 virtual void SetUnmanaged() OVERRIDE; | 37 virtual void SetUnmanaged() OVERRIDE; |
36 | 38 |
37 // SignedSettingsHelper::Callback implementation: | 39 // SignedSettingsHelper::Callback implementation: |
38 virtual void OnRetrievePolicyCompleted( | 40 virtual void OnRetrievePolicyCompleted( |
39 chromeos::SignedSettings::ReturnCode code, | 41 chromeos::SignedSettings::ReturnCode code, |
40 const em::PolicyFetchResponse& policy) OVERRIDE; | 42 const em::PolicyFetchResponse& policy) OVERRIDE; |
41 | 43 |
42 private: | 44 private: |
43 friend class DevicePolicyCacheTest; | 45 friend class DevicePolicyCacheTest; |
44 | 46 |
45 // Alternate c'tor allowing tests to mock out the SignedSettingsHelper | 47 // Alternate c'tor allowing tests to mock out the SignedSettingsHelper |
46 // singleton. | 48 // singleton. |
47 DevicePolicyCache( | 49 DevicePolicyCache( |
48 DevicePolicyIdentityStrategy* identity_strategy, | 50 DevicePolicyIdentityStrategy* identity_strategy, |
| 51 EnterpriseInstallAttributes* install_attributes, |
49 chromeos::SignedSettingsHelper* signed_settings_helper); | 52 chromeos::SignedSettingsHelper* signed_settings_helper); |
50 | 53 |
51 // CloudPolicyCacheBase implementation: | 54 // CloudPolicyCacheBase implementation: |
52 virtual bool DecodePolicyData(const em::PolicyData& policy_data, | 55 virtual bool DecodePolicyData(const em::PolicyData& policy_data, |
53 PolicyMap* mandatory, | 56 PolicyMap* mandatory, |
54 PolicyMap* recommended) OVERRIDE; | 57 PolicyMap* recommended) OVERRIDE; |
55 | 58 |
56 void PolicyStoreOpCompleted(chromeos::SignedSettings::ReturnCode code); | 59 void PolicyStoreOpCompleted(chromeos::SignedSettings::ReturnCode code); |
57 | 60 |
| 61 // Checks with immutable attributes whether this is an enterprise device and |
| 62 // read the registration user if this is the case. |
| 63 void CheckImmutableAttributes(); |
| 64 |
58 static void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, | 65 static void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, |
59 PolicyMap* mandatory, | 66 PolicyMap* mandatory, |
60 PolicyMap* recommended); | 67 PolicyMap* recommended); |
61 | 68 |
62 DevicePolicyIdentityStrategy* identity_strategy_; | 69 DevicePolicyIdentityStrategy* identity_strategy_; |
| 70 EnterpriseInstallAttributes* install_attributes_; |
63 | 71 |
64 chromeos::SignedSettingsHelper* signed_settings_helper_; | 72 chromeos::SignedSettingsHelper* signed_settings_helper_; |
65 | 73 |
66 bool starting_up_; | 74 bool starting_up_; |
67 | 75 |
68 base::ScopedCallbackFactory<DevicePolicyCache> callback_factory_; | 76 base::ScopedCallbackFactory<DevicePolicyCache> callback_factory_; |
69 | 77 |
70 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCache); | 78 DISALLOW_COPY_AND_ASSIGN(DevicePolicyCache); |
71 }; | 79 }; |
72 | 80 |
73 } // namespace policy | 81 } // namespace policy |
74 | 82 |
75 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ | 83 #endif // CHROME_BROWSER_POLICY_DEVICE_POLICY_CACHE_H_ |
OLD | NEW |