Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account_policy_provider.h

Issue 342233005: Move ownership of the ComponentCloudPolicyService to the broker. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
19 #include "components/policy/core/common/configuration_policy_provider.h" 17 #include "components/policy/core/common/configuration_policy_provider.h"
20 18
21 namespace policy { 19 namespace policy {
22 20
23 class PolicyMap; 21 class PolicyMap;
24 22
25 // Policy provider for a device-local account. Pulls policy from 23 // Policy provider for a device-local account. Pulls policy from
26 // DeviceLocalAccountPolicyService. Note that this implementation keeps 24 // DeviceLocalAccountPolicyService. Note that this implementation keeps
27 // functioning when the device-local account disappears from 25 // functioning when the device-local account disappears from
28 // DeviceLocalAccountPolicyService. The current policy will be kept in that case 26 // DeviceLocalAccountPolicyService. The current policy will be kept in that case
29 // and RefreshPolicies becomes a no-op. 27 // and RefreshPolicies becomes a no-op. Policies for any installed extensions
28 // will be kept as well in that case.
30 class DeviceLocalAccountPolicyProvider 29 class DeviceLocalAccountPolicyProvider
31 : public ConfigurationPolicyProvider, 30 : public ConfigurationPolicyProvider,
32 public DeviceLocalAccountPolicyService::Observer, 31 public DeviceLocalAccountPolicyService::Observer {
33 public ComponentCloudPolicyService::Delegate {
34 public: 32 public:
35 DeviceLocalAccountPolicyProvider( 33 DeviceLocalAccountPolicyProvider(
36 const std::string& user_id, 34 const std::string& user_id,
37 DeviceLocalAccountPolicyService* service, 35 DeviceLocalAccountPolicyService* service,
38 scoped_ptr<PolicyMap> chrome_policy_overrides); 36 scoped_ptr<PolicyMap> chrome_policy_overrides);
39 virtual ~DeviceLocalAccountPolicyProvider(); 37 virtual ~DeviceLocalAccountPolicyProvider();
40 38
41 // Factory function to create and initialize a provider for |user_id|. Returns 39 // Factory function to create and initialize a provider for |user_id|. Returns
42 // NULL if |user_id| is not a device-local account or user policy isn't 40 // NULL if |user_id| is not a device-local account or user policy isn't
43 // applicable for user_id's user type. 41 // applicable for user_id's user type.
44 static scoped_ptr<DeviceLocalAccountPolicyProvider> Create( 42 static scoped_ptr<DeviceLocalAccountPolicyProvider> Create(
45 const std::string& user_id, 43 const std::string& user_id,
46 DeviceLocalAccountPolicyService* service); 44 DeviceLocalAccountPolicyService* service);
47 45
48 // ConfigurationPolicyProvider: 46 // ConfigurationPolicyProvider:
49 virtual void Init(SchemaRegistry* registry) OVERRIDE;
50 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE; 47 virtual bool IsInitializationComplete(PolicyDomain domain) const OVERRIDE;
51 virtual void RefreshPolicies() OVERRIDE; 48 virtual void RefreshPolicies() OVERRIDE;
52 virtual void Shutdown() OVERRIDE;
53 49
54 // DeviceLocalAccountPolicyService::Observer: 50 // DeviceLocalAccountPolicyService::Observer:
55 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE; 51 virtual void OnPolicyUpdated(const std::string& user_id) OVERRIDE;
56 virtual void OnDeviceLocalAccountsChanged() OVERRIDE; 52 virtual void OnDeviceLocalAccountsChanged() OVERRIDE;
57 virtual void OnBrokerShutdown(
58 DeviceLocalAccountPolicyBroker* broker) OVERRIDE;
59
60 // ComponentCloudPolicyService::Delegate:
61 virtual void OnComponentCloudPolicyUpdated() OVERRIDE;
62 53
63 private: 54 private:
64 // Returns the broker for |user_id_| or NULL if not available. 55 // Returns the broker for |user_id_| or NULL if not available.
65 DeviceLocalAccountPolicyBroker* GetBroker(); 56 DeviceLocalAccountPolicyBroker* GetBroker() const;
66 57
67 // Handles completion of policy refreshes and triggers the update callback. 58 // Handles completion of policy refreshes and triggers the update callback.
68 // |success| is true if the policy refresh was successful. 59 // |success| is true if the policy refresh was successful.
69 void ReportPolicyRefresh(bool success); 60 void ReportPolicyRefresh(bool success);
70 61
71 // Unless |waiting_for_policy_refresh_|, calls UpdatePolicy(), using the 62 // Unless |waiting_for_policy_refresh_|, calls UpdatePolicy(), using the
72 // policy from the broker if available or keeping the current policy. 63 // policy from the broker if available or keeping the current policy.
73 void UpdateFromBroker(); 64 void UpdateFromBroker();
74 65
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
79 const std::string user_id_; 66 const std::string user_id_;
80 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; 67 scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_;
81 68
82 DeviceLocalAccountPolicyService* service_; 69 DeviceLocalAccountPolicyService* service_;
83 70
84 // A policy map providing overrides to apply on top of the Chrome policy 71 // A policy map providing overrides to apply on top of the Chrome policy
85 // received from |service_|. This is used to fix certain policies for public 72 // received from |service_|. This is used to fix certain policies for public
86 // sessions regardless of what's actually specified in policy. 73 // sessions regardless of what's actually specified in policy.
87 scoped_ptr<PolicyMap> chrome_policy_overrides_; 74 scoped_ptr<PolicyMap> chrome_policy_overrides_;
88 75
89 bool store_initialized_; 76 bool store_initialized_;
90 bool waiting_for_policy_refresh_; 77 bool waiting_for_policy_refresh_;
91 78
92 scoped_ptr<ComponentCloudPolicyService> component_policy_service_;
93
94 base::WeakPtrFactory<DeviceLocalAccountPolicyProvider> weak_factory_; 79 base::WeakPtrFactory<DeviceLocalAccountPolicyProvider> weak_factory_;
95 80
96 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyProvider); 81 DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyProvider);
97 }; 82 };
98 83
99 } // namespace policy 84 } // namespace policy
100 85
101 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H _ 86 #endif // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_LOCAL_ACCOUNT_POLICY_PROVIDER_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698