OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_STORE_CHROMEOS_H_ | |
6 #define CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_STORE_CHROMEOS_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/weak_ptr.h" | |
12 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
13 #include "chrome/browser/policy/cloud_policy_store.h" | |
14 #include "chrome/browser/policy/cloud_policy_validator.h" | |
15 | |
16 namespace enterprise_management { | |
17 class PolicyFetchResponse; | |
18 } | |
19 | |
20 namespace policy { | |
21 | |
22 class EnterpriseInstallAttributes; | |
23 | |
24 // CloudPolicyStore implementation for device policy on Chrome OS. Policy is | |
25 // stored/loaded via DBus to/from session_manager. | |
26 class DeviceCloudPolicyStoreChromeOS | |
27 : public CloudPolicyStore, | |
28 public chromeos::DeviceSettingsService::Observer { | |
29 public: | |
30 DeviceCloudPolicyStoreChromeOS( | |
31 chromeos::DeviceSettingsService* device_settings_service, | |
32 EnterpriseInstallAttributes* install_attributes); | |
33 virtual ~DeviceCloudPolicyStoreChromeOS(); | |
34 | |
35 // CloudPolicyStore: | |
36 virtual void Store( | |
37 const enterprise_management::PolicyFetchResponse& policy) OVERRIDE; | |
38 virtual void Load() OVERRIDE; | |
39 | |
40 // Installs initial policy. This is different from Store() in that it skips | |
41 // the signature validation step against already-installed policy. The checks | |
42 // against installation-time attributes are performed nevertheless. The result | |
43 // of the operation is reported through the OnStoreLoaded() or OnStoreError() | |
44 // observer callbacks. | |
45 void InstallInitialPolicy( | |
46 const enterprise_management::PolicyFetchResponse& policy); | |
47 | |
48 // chromeos::DeviceSettingsService::Observer: | |
49 virtual void OwnershipStatusChanged() OVERRIDE; | |
50 virtual void DeviceSettingsUpdated() OVERRIDE; | |
51 | |
52 private: | |
53 // Create a validator for |policy| with basic device policy configuration and | |
54 // OnPolicyStored() as the completion callback. | |
55 scoped_ptr<DeviceCloudPolicyValidator> CreateValidator( | |
56 const enterprise_management::PolicyFetchResponse& policy); | |
57 | |
58 // Called on completion on the policy validation prior to storing policy. | |
59 // Starts the actual store operation. | |
60 void OnPolicyToStoreValidated(DeviceCloudPolicyValidator* validator); | |
61 | |
62 // Handles store completion operations updates status. | |
63 void OnPolicyStored(); | |
64 | |
65 // Re-syncs policy and status from |device_settings_service_|. | |
66 void UpdateFromService(); | |
67 | |
68 chromeos::DeviceSettingsService* device_settings_service_; | |
69 EnterpriseInstallAttributes* install_attributes_; | |
70 | |
71 base::WeakPtrFactory<DeviceCloudPolicyStoreChromeOS> weak_factory_; | |
72 | |
73 DISALLOW_COPY_AND_ASSIGN(DeviceCloudPolicyStoreChromeOS); | |
74 }; | |
75 | |
76 } // namespace policy | |
77 | |
78 #endif // CHROME_BROWSER_POLICY_DEVICE_CLOUD_POLICY_STORE_CHROMEOS_H_ | |
OLD | NEW |