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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h" | 15 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana ger.h" |
16 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" | 16 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
17 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" | |
18 #include "components/policy/core/common/cloud/resource_cache.h" | |
bartfab (slow)
2014/06/20 09:17:25
Nit: Move this to the implementation file. It is n
Joao da Silva
2014/06/20 11:48:45
Obsolete in the next CL.
| |
17 #include "components/policy/core/common/configuration_policy_provider.h" | 19 #include "components/policy/core/common/configuration_policy_provider.h" |
18 | 20 |
19 namespace policy { | 21 namespace policy { |
20 | 22 |
21 class PolicyMap; | 23 class PolicyMap; |
22 | 24 |
23 // Policy provider for a device-local account. Pulls policy from | 25 // Policy provider for a device-local account. Pulls policy from |
24 // DeviceLocalAccountPolicyService. Note that this implementation keeps | 26 // DeviceLocalAccountPolicyService. Note that this implementation keeps |
25 // functioning when the device-local account disappears from | 27 // functioning when the device-local account disappears from |
26 // DeviceLocalAccountPolicyService. The current policy will be kept in that case | 28 // DeviceLocalAccountPolicyService. The current policy will be kept in that case |
27 // and RefreshPolicies becomes a no-op. | 29 // and RefreshPolicies becomes a no-op. |
bartfab (slow)
2014/06/20 09:17:25
Document what happens to component policy in that
Joao da Silva
2014/06/20 11:48:45
Done.
| |
28 class DeviceLocalAccountPolicyProvider | 30 class DeviceLocalAccountPolicyProvider |
29 : public ConfigurationPolicyProvider, | 31 : public ConfigurationPolicyProvider, |
30 public DeviceLocalAccountPolicyService::Observer { | 32 public DeviceLocalAccountPolicyService::Observer, |
33 public ComponentCloudPolicyService::Delegate { | |
31 public: | 34 public: |
32 DeviceLocalAccountPolicyProvider( | 35 DeviceLocalAccountPolicyProvider( |
33 const std::string& user_id, | 36 const std::string& user_id, |
34 DeviceLocalAccountPolicyService* service, | 37 DeviceLocalAccountPolicyService* service, |
35 scoped_ptr<PolicyMap> chrome_policy_overrides); | 38 scoped_ptr<PolicyMap> chrome_policy_overrides); |
36 virtual ~DeviceLocalAccountPolicyProvider(); | 39 virtual ~DeviceLocalAccountPolicyProvider(); |
37 | 40 |
38 // Factory function to create and initialize a provider for |user_id|. Returns | 41 // Factory function to create and initialize a provider for |user_id|. Returns |
39 // NULL if |user_id| is not a device-local account or user policy isn't | 42 // NULL if |user_id| is not a device-local account or user policy isn't |
40 // applicable for user_id's user type. | 43 // applicable for user_id's user type. |
41 static scoped_ptr<DeviceLocalAccountPolicyProvider> Create( | 44 static scoped_ptr<DeviceLocalAccountPolicyProvider> Create( |
42 const std::string& user_id, | 45 const std::string& user_id, |
43 DeviceLocalAccountPolicyService* service); | 46 DeviceLocalAccountPolicyService* service); |
44 | 47 |
45 // ConfigurationPolicyProvider: | 48 // ConfigurationPolicyProvider: |
49 virtual void Init(SchemaRegistry* registry) OVERRIDE; | |
46 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; | 50 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; |
47 virtual void RefreshPolicies() OVERRIDE; | 51 virtual void RefreshPolicies() OVERRIDE; |
52 virtual void Shutdown() OVERRIDE; | |
48 | 53 |
49 // DeviceLocalAccountPolicyService::Observer: | 54 // DeviceLocalAccountPolicyService::Observer: |
50 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; | 55 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; |
51 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; | 56 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; |
57 virtual void OnBrokerShutdown( | |
58 DeviceLocalAccountPolicyBroker* broker) OVERRIDE; | |
59 | |
60 // ComponentCloudPolicyService::Delegate: | |
61 virtual void OnComponentCloudPolicyUpdated() OVERRIDE; | |
52 | 62 |
53 private: | 63 private: |
54 // Returns the broker for |user_id_| or NULL if not available. | 64 // Returns the broker for |user_id_| or NULL if not available. |
55 DeviceLocalAccountPolicyBroker* GetBroker(); | 65 DeviceLocalAccountPolicyBroker* GetBroker(); |
56 | 66 |
57 // Handles completion of policy refreshes and triggers the update callback. | 67 // Handles completion of policy refreshes and triggers the update callback. |
58 // |success| is true if the policy refresh was successful. | 68 // |success| is true if the policy refresh was successful. |
59 void ReportPolicyRefresh(bool success); | 69 void ReportPolicyRefresh(bool success); |
60 | 70 |
61 // Unless |waiting_for_policy_refresh_|, calls UpdatePolicy(), using the | 71 // Unless |waiting_for_policy_refresh_|, calls UpdatePolicy(), using the |
62 // policy from the broker if available or keeping the current policy. | 72 // policy from the broker if available or keeping the current policy. |
63 void UpdateFromBroker(); | 73 void UpdateFromBroker(); |
64 | 74 |
75 // Creates the |component_policy_service_| if it hasn't been created yet | |
76 // and all the dependencies are in place. | |
77 void MaybeCreateComponentPolicyService(); | |
78 | |
65 const std::string user_id_; | 79 const std::string user_id_; |
66 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; | 80 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; |
67 | 81 |
68 DeviceLocalAccountPolicyService* service_; | 82 DeviceLocalAccountPolicyService* service_; |
69 | 83 |
70 // A policy map providing overrides to apply on top of the Chrome policy | 84 // A policy map providing overrides to apply on top of the Chrome policy |
71 // received from |service_|. This is used to fix certain policies for public | 85 // received from |service_|. This is used to fix certain policies for public |
72 // sessions regardless of what's actually specified in policy. | 86 // sessions regardless of what's actually specified in policy. |
73 scoped_ptr<PolicyMap> chrome_policy_overrides_; | 87 scoped_ptr<PolicyMap> chrome_policy_overrides_; |
74 | 88 |
75 bool store_initialized_; | 89 bool store_initialized_; |
76 bool waiting_for_policy_refresh_; | 90 bool waiting_for_policy_refresh_; |
77 | 91 |
92 scoped_ptr<ComponentCloudPolicyService> component_policy_service_; | |
93 | |
78 base::WeakPtrFactory<DeviceLocalAccountPolicyProvider> weak_factory_; | 94 base::WeakPtrFactory<DeviceLocalAccountPolicyProvider> weak_factory_; |
79 | 95 |
80 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyProvider); | 96 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyProvider); |
81 }; | 97 }; |
82 | 98 |
83 } // namespace policy | 99 } // namespace policy |
84 | 100 |
85 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H _ | 101 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H _ |
OLD | NEW |