Index: chrome/browser/chromeos/policy/device_local_account_policy_service.h |
diff --git a/chrome/browser/chromeos/policy/device_local_account_policy_service.h b/chrome/browser/chromeos/policy/device_local_account_policy_service.h |
index f91fc95f22ea039e1e61ee9910cf8d0606197848..e92f6d1ed7331a74eaef6023e44b173ee37b1006 100644 |
--- a/chrome/browser/chromeos/policy/device_local_account_policy_service.h |
+++ b/chrome/browser/chromeos/policy/device_local_account_policy_service.h |
@@ -10,6 +10,7 @@ |
#include <string> |
#include "base/basictypes.h" |
+#include "base/callback_forward.h" |
#include "base/compiler_specific.h" |
#include "base/files/file_path.h" |
#include "base/memory/ref_counted.h" |
@@ -21,6 +22,7 @@ |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
#include "components/policy/core/common/cloud/cloud_policy_core.h" |
#include "components/policy/core/common/cloud/cloud_policy_store.h" |
+#include "components/policy/core/common/cloud/component_cloud_policy_service.h" |
namespace base { |
class SequencedTaskRunner; |
@@ -37,15 +39,21 @@ class URLRequestContextGetter; |
namespace policy { |
+class ComponentCloudPolicyService; |
bartfab (slow)
2014/06/20 09:44:23
You include the header for ComponentCloudPolicySer
Joao da Silva
2014/06/20 15:36:08
Done.
|
struct DeviceLocalAccount; |
class DeviceLocalAccountExternalDataService; |
class DeviceLocalAccountPolicyStore; |
class DeviceManagementService; |
+class SchemaRegistryService; |
// The main switching central that downloads, caches, refreshes, etc. policy for |
// a single device-local account. |
-class DeviceLocalAccountPolicyBroker { |
+class DeviceLocalAccountPolicyBroker |
+ : public CloudPolicyStore::Observer, |
+ public ComponentCloudPolicyService::Delegate { |
public: |
+ // |policy_update_callback| can be invoked to notify observers that the policy |
bartfab (slow)
2014/06/20 09:44:23
Nit: "can" sounds like it may or may not be invoke
Joao da Silva
2014/06/20 15:36:08
Done.
|
+ // for |account| has been updated. |
// |task_runner| is the runner for policy refresh tasks. |
DeviceLocalAccountPolicyBroker( |
const DeviceLocalAccount& account, |
@@ -53,12 +61,18 @@ class DeviceLocalAccountPolicyBroker { |
scoped_ptr<DeviceLocalAccountPolicyStore> store, |
scoped_refptr<DeviceLocalAccountExternalDataManager> |
external_data_manager, |
+ const base::Closure& policy_updated_callback, |
const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
- ~DeviceLocalAccountPolicyBroker(); |
+ virtual ~DeviceLocalAccountPolicyBroker(); |
// Initialize the broker, loading its |store_|. |
void Initialize(); |
+ // Called by the SchemaRegistryServiceFactory to tell the broker that its |
+ // SchemaRegistryService is going to shutdown soon. This is only called if |
bartfab (slow)
2014/06/20 09:44:23
Nit: s/shutdown/shut down/
Joao da Silva
2014/06/20 15:36:08
Obsolete
|
+ // release_schema_registry() was used before. |
+ void OnSchemaRegistryShutdown(); |
+ |
// For the difference between |account_id| and |user_id|, see the |
// documentation of DeviceLocalAccount. |
const std::string& account_id() const { return account_id_; } |
@@ -74,6 +88,16 @@ class DeviceLocalAccountPolicyBroker { |
return external_data_manager_; |
} |
+ ComponentCloudPolicyService* component_policy_service() const { |
+ return component_policy_service_.get(); |
+ } |
+ |
+ // The broker creates a SchemaRegistryService before a Profile is created |
+ // for this account (if ever). This method allows the |
+ // SchemaRegistryServiceFactory to obtain the SchemaRegistryService that was |
+ // created for the account. |
+ scoped_ptr<SchemaRegistryService> release_schema_registry(); |
bartfab (slow)
2014/06/20 09:44:23
1: This should be hacker_style(). It is not a simp
Joao da Silva
2014/06/20 15:36:07
Obsolete
|
+ |
// Fire up the cloud connection for fetching policy for the account from the |
// cloud if this is an enterprise-managed device. |
void ConnectIfPossible( |
@@ -88,20 +112,28 @@ class DeviceLocalAccountPolicyBroker { |
// empty string if the policy is not present. |
std::string GetDisplayName() const; |
- // Returns a directory where component policy for this account can be cached. |
- // The DeviceLocalAccountPolicyService takes care of cleaning up caches of |
- // accounts that have been removed. |
- base::FilePath GetComponentPolicyCachePath() const; |
+ // CloudPolicyStore::Observer: |
+ virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
+ virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
+ |
+ // ComponentCloudPolicyService::Delegate: |
+ virtual void OnComponentCloudPolicyUpdated() OVERRIDE; |
private: |
+ void CreateComponentCloudPolicyService( |
+ const scoped_refptr<net::URLRequestContextGetter>& request_context); |
+ |
const std::string account_id_; |
const std::string user_id_; |
const base::FilePath component_policy_cache_path_; |
+ scoped_ptr<SchemaRegistryService> schema_registry_; |
const scoped_ptr<DeviceLocalAccountPolicyStore> store_; |
scoped_refptr<DeviceLocalAccountExternalDataManager> external_data_manager_; |
scoped_refptr<chromeos::DeviceLocalAccountExternalPolicyLoader> |
extension_loader_; |
CloudPolicyCore core_; |
+ scoped_ptr<ComponentCloudPolicyService> component_policy_service_; |
+ base::Closure policy_update_callback_; |
bartfab (slow)
2014/06/20 09:44:23
Since you have a base::Closure member, you will ne
Joao da Silva
2014/06/20 15:36:07
Done.
|
DISALLOW_COPY_AND_ASSIGN(DeviceLocalAccountPolicyBroker); |
}; |
@@ -110,7 +142,7 @@ class DeviceLocalAccountPolicyBroker { |
// The actual policy blobs are brokered by session_manager (to prevent file |
// manipulation), and we're making signature checks on the policy blobs to |
// ensure they're issued by the device owner. |
-class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { |
+class DeviceLocalAccountPolicyService { |
public: |
// Interface for interested parties to observe policy changes. |
class Observer { |
@@ -122,9 +154,6 @@ class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { |
// The list of accounts has been updated. |
virtual void OnDeviceLocalAccountsChanged() = 0; |
- |
- // The given |broker| is about to be destroyed. |
- virtual void OnBrokerShutdown(DeviceLocalAccountPolicyBroker* broker) {} |
}; |
DeviceLocalAccountPolicyService( |
@@ -153,15 +182,9 @@ class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { |
// |user_id|. |
bool IsPolicyAvailableForUser(const std::string& user_id); |
- scoped_refptr<net::URLRequestContextGetter> request_context() const; |
- |
void AddObserver(Observer* observer); |
void RemoveObserver(Observer* observer); |
- // CloudPolicyStore::Observer: |
- virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
- virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
- |
private: |
typedef std::map<std::string, DeviceLocalAccountPolicyBroker*> |
PolicyBrokerMap; |
@@ -203,6 +226,9 @@ class DeviceLocalAccountPolicyService : public CloudPolicyStore::Observer { |
// Find the broker for a given |store|. Returns NULL if |store| is unknown. |
DeviceLocalAccountPolicyBroker* GetBrokerForStore(CloudPolicyStore* store); |
+ // Notifies the |observers_| that the policy for |user_id| has changed. |
+ void NotifyPolicyUpdated(const std::string& user_id); |
+ |
ObserverList<Observer, true> observers_; |
chromeos::SessionManagerClient* session_manager_client_; |