summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/cloud_policy_subsystem.h
blob: 503e6070f1e4f5a13f6f7a88f2c34e348ad3c90e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2011 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_CLOUD_POLICY_SUBSYSTEM_H_
#define CHROME_BROWSER_POLICY_CLOUD_POLICY_SUBSYSTEM_H_
#pragma once

#include "base/scoped_ptr.h"
#include "chrome/browser/prefs/pref_member.h"
#include "chrome/common/notification_observer.h"

class FilePath;
class PrefService;
class URLRequestContextGetter;

namespace policy {

class CloudPolicyCache;
class CloudPolicyController;
class CloudPolicyIdentityStrategy;
class ConfigurationPolicyProvider;
class DeviceManagementService;
class DeviceTokenFetcher;

// This class is a container for the infrastructure required to support cloud
// policy. It glues together the backend, the policy controller and manages the
// life cycle of the policy providers.
class CloudPolicySubsystem : public NotificationObserver {
 public:
  CloudPolicySubsystem(const FilePath& policy_cache_file,
                       CloudPolicyIdentityStrategy* identity_strategy);
  virtual ~CloudPolicySubsystem();

  // Initializes the subsystem.
  void Initialize(PrefService* prefs,
                  const char* refresh_rate_pref_name,
                  URLRequestContextGetter* request_context);

  // Shuts the subsystem down. This must be called before threading and network
  // infrastructure goes away.
  void Shutdown();

  ConfigurationPolicyProvider* GetManagedPolicyProvider();
  ConfigurationPolicyProvider* GetRecommendedPolicyProvider();

 private:
  // Updates the policy controller with a new refresh rate value.
  void UpdatePolicyRefreshRate();

  // NotificationObserver overrides.
  virtual void Observe(NotificationType type,
                       const NotificationSource& source,
                       const NotificationDetails& details);

  // The pref service that controls the refresh rate.
  PrefService* prefs_;

  // Tracks the pref value for the policy refresh rate.
  IntegerPrefMember policy_refresh_rate_;

  // Cloud policy infrastructure stuff.
  scoped_ptr<DeviceManagementService> device_management_service_;
  scoped_ptr<DeviceTokenFetcher> device_token_fetcher_;
  scoped_ptr<CloudPolicyCache> cloud_policy_cache_;
  scoped_ptr<CloudPolicyController> cloud_policy_controller_;

  DISALLOW_COPY_AND_ASSIGN(CloudPolicySubsystem);
};

}  // namespace policy

#endif  // CHROME_BROWSER_POLICY_CLOUD_POLICY_SUBSYSTEM_H_