Chromium Code Reviews| Index: chrome/browser/policy/user_cloud_policy_manager.h |
| diff --git a/chrome/browser/policy/user_cloud_policy_manager.h b/chrome/browser/policy/user_cloud_policy_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d091dfafea683a1cbb00fed596258111b01d5d8c |
| --- /dev/null |
| +++ b/chrome/browser/policy/user_cloud_policy_manager.h |
| @@ -0,0 +1,106 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
| +#define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |
| +#pragma once |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/browser/policy/cloud_policy_client.h" |
| +#include "chrome/browser/policy/cloud_policy_constants.h" |
| +#include "chrome/browser/policy/cloud_policy_service.h" |
|
Joao da Silva
2012/06/01 12:27:47
CloudPolicyService can be forward-declared in this
Mattias Nissler (ping if slow)
2012/06/04 17:42:37
Done.
|
| +#include "chrome/browser/policy/cloud_policy_store.h" |
| +#include "chrome/browser/policy/configuration_policy_provider.h" |
| + |
| +class PrefService; |
| + |
| +namespace chromeos { |
| +class SessionManagerClient; |
|
Joao da Silva
2012/06/01 12:27:47
Not needed
Mattias Nissler (ping if slow)
2012/06/04 17:42:37
Done.
|
| +} |
| + |
| +namespace policy { |
| + |
| +class CloudPolicyRefreshScheduler; |
| +class DeviceManagementService; |
| + |
| +// UserCloudPolicyManager keeps track of all things user policy, drives the |
| +// corresponding cloud policy service and publishes policy through the |
| +// ConfigurationPolicyProvider interface. |
| +class UserCloudPolicyManager : public ConfigurationPolicyProvider, |
| + public CloudPolicyClient::Observer, |
| + public CloudPolicyStore::Observer { |
| + public: |
| + // If |wait_for_policy| fetch is true, IsInitializationComplete() will return |
| + // false as long as there hasn't been a successful policy fetch. |
| + UserCloudPolicyManager(const PolicyDefinitionList* policy_list, |
| + scoped_ptr<CloudPolicyStore> store, |
| + bool wait_for_policy_fetch); |
| + virtual ~UserCloudPolicyManager(); |
| + |
| + // Initializes the cloud connection. |prefs| and |service| must stay valid |
| + // until Shutdown() gets called. |
| + void Initialize(PrefService* prefs, |
| + DeviceManagementService* service, |
| + UserAffiliation user_affiliation); |
| + void Shutdown(); |
| + |
| + // Cancels waiting for the policy fetch and flags the |
| + // ConfigurationPolicyProvider ready (assuming all other initialization tasks |
| + // have completed). |
| + void CancelWaitForPolicyFetch(); |
| + |
| + CloudPolicyService* cloud_policy_service() { return service_.get(); } |
|
Joao da Silva
2012/06/01 12:27:47
const method?
Mattias Nissler (ping if slow)
2012/06/04 17:42:37
You mean a const variant of the getter? Let's add
Joao da Silva
2012/06/05 07:21:46
I mean that this method can be const:
CloudPolicy
|
| + |
| + // ConfigurationPolicyProvider: |
| + virtual bool IsInitializationComplete() const OVERRIDE; |
| + virtual void RefreshPolicies() OVERRIDE; |
| + |
| + // CloudPolicyClient::Observer: |
| + virtual void OnPolicyFetched(CloudPolicyClient* client) OVERRIDE; |
| + virtual void OnRegistrationStateChanged(CloudPolicyClient* client) OVERRIDE; |
| + virtual void OnClientError(CloudPolicyClient* client) OVERRIDE; |
| + |
| + // CloudPolicyStore::Observer: |
| + virtual void OnStoreLoaded(CloudPolicyStore* store) OVERRIDE; |
| + virtual void OnStoreError(CloudPolicyStore* store) OVERRIDE; |
| + |
| +#if defined(OS_CHROMEOS) |
| + // Creates a UserCloudPolicyService instance for the Chrome OS platform. |
| + static scoped_ptr<UserCloudPolicyManager> Create(bool wait_for_policy_fetch); |
| +#endif |
|
Joao da Silva
2012/06/01 12:27:47
Put this declaration after the dtor, to preserve t
Mattias Nissler (ping if slow)
2012/06/04 17:42:37
Done.
|
| + |
| + private: |
| + // Check whether fully initialized and if so, publish policy by calling |
| + // ConfigurationPolicyStore::UpdatePolicy(). |
| + void CheckAndPublishPolicy(); |
| + |
| + // Completion handler for the explicit policy fetch triggered on startup in |
| + // case |wait_for_policy_fetch_| is true. |
| + void OnInitialPolicyFetchComplete(); |
| + |
| + // Completion handler for policy refresh operations. |
| + void OnRefreshComplete(); |
| + |
| + // Whether to wait for a policy fetch to complete before reporting |
| + // IsInitializationComplete(). |
| + bool wait_for_policy_fetch_; |
| + |
| + // Whether there's a policy refresh operation pending, in which case all |
| + // policy update notifications are deferred until after it completes. |
| + bool wait_for_policy_refresh_; |
| + |
| + scoped_ptr<CloudPolicyStore> store_; |
| + scoped_ptr<CloudPolicyService> service_; |
| + scoped_ptr<CloudPolicyRefreshScheduler> refresh_scheduler_; |
| + |
| + // The pref service to pass to the refresh scheduler on initialization. |
| + PrefService* prefs_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManager); |
| +}; |
| + |
| +} // namespace policy |
| + |
| +#endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_H_ |