cloud_policy_subsystem.h revision dc0f95d653279beabeb9817299e2902918ba123e
1// Copyright (c) 2011 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_CLOUD_POLICY_SUBSYSTEM_H_
6#define CHROME_BROWSER_POLICY_CLOUD_POLICY_SUBSYSTEM_H_
7#pragma once
8
9#include "base/scoped_ptr.h"
10#include "chrome/browser/prefs/pref_member.h"
11#include "chrome/common/notification_observer.h"
12
13class FilePath;
14class PrefService;
15class URLRequestContextGetter;
16
17namespace policy {
18
19class CloudPolicyCache;
20class CloudPolicyController;
21class CloudPolicyIdentityStrategy;
22class ConfigurationPolicyProvider;
23class DeviceManagementService;
24class DeviceTokenFetcher;
25
26// This class is a container for the infrastructure required to support cloud
27// policy. It glues together the backend, the policy controller and manages the
28// life cycle of the policy providers.
29class CloudPolicySubsystem : public NotificationObserver {
30 public:
31  CloudPolicySubsystem(const FilePath& policy_cache_file,
32                       CloudPolicyIdentityStrategy* identity_strategy);
33  virtual ~CloudPolicySubsystem();
34
35  // Initializes the subsystem.
36  void Initialize(PrefService* prefs,
37                  const char* refresh_rate_pref_name,
38                  URLRequestContextGetter* request_context);
39
40  // Shuts the subsystem down. This must be called before threading and network
41  // infrastructure goes away.
42  void Shutdown();
43
44  ConfigurationPolicyProvider* GetManagedPolicyProvider();
45  ConfigurationPolicyProvider* GetRecommendedPolicyProvider();
46
47 private:
48  // Updates the policy controller with a new refresh rate value.
49  void UpdatePolicyRefreshRate();
50
51  // NotificationObserver overrides.
52  virtual void Observe(NotificationType type,
53                       const NotificationSource& source,
54                       const NotificationDetails& details);
55
56  // The pref service that controls the refresh rate.
57  PrefService* prefs_;
58
59  // Tracks the pref value for the policy refresh rate.
60  IntegerPrefMember policy_refresh_rate_;
61
62  // Cloud policy infrastructure stuff.
63  scoped_ptr<DeviceManagementService> device_management_service_;
64  scoped_ptr<DeviceTokenFetcher> device_token_fetcher_;
65  scoped_ptr<CloudPolicyCache> cloud_policy_cache_;
66  scoped_ptr<CloudPolicyController> cloud_policy_controller_;
67
68  DISALLOW_COPY_AND_ASSIGN(CloudPolicySubsystem);
69};
70
71}  // namespace policy
72
73#endif  // CHROME_BROWSER_POLICY_CLOUD_POLICY_SUBSYSTEM_H_
74