summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/policy/device_network_configuration_updater.h
blob: 6b9b762fe016000b99b58f268c2fe2bbb1f3d25c (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
74
75
76
77
78
79
80
81
82
83
// Copyright 2013 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_CHROMEOS_POLICY_DEVICE_NETWORK_CONFIGURATION_UPDATER_H_
#define CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NETWORK_CONFIGURATION_UPDATER_H_

#include <string>

#include "base/basictypes.h"
#include "base/callback_list.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/policy/network_configuration_updater.h"
#include "components/onc/onc_constants.h"

namespace base {
class DictionaryValue;
class ListValue;
class Value;
}

namespace chromeos {
class CrosSettings;
class ManagedNetworkConfigurationHandler;
class NetworkDeviceHandler;

namespace onc {
class CertificateImporter;
}
}

namespace policy {

class PolicyService;

// Implements addtional special handling of ONC device policies, which requires
// listening for notifications from CrosSettings.
class DeviceNetworkConfigurationUpdater : public NetworkConfigurationUpdater {
 public:
  virtual ~DeviceNetworkConfigurationUpdater();

  // Creates an updater that applies the ONC device policy from |policy_service|
  // once the policy service is completely initialized and on each policy
  // change. The argument objects must outlive the returned updater.
  static scoped_ptr<DeviceNetworkConfigurationUpdater> CreateForDevicePolicy(
      scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer,
      PolicyService* policy_service,
      chromeos::ManagedNetworkConfigurationHandler* network_config_handler,
      chromeos::NetworkDeviceHandler* network_device_handler,
      chromeos::CrosSettings* cros_settings);

 private:
  DeviceNetworkConfigurationUpdater(
      scoped_ptr<chromeos::onc::CertificateImporter> certificate_importer,
      PolicyService* policy_service,
      chromeos::ManagedNetworkConfigurationHandler* network_config_handler,
      chromeos::NetworkDeviceHandler* network_device_handler,
      chromeos::CrosSettings* cros_settings);

  virtual void Init() OVERRIDE;
  virtual void ImportCertificates(const base::ListValue& certificates_onc)
      OVERRIDE;
  virtual void ApplyNetworkPolicy(base::ListValue* network_configs_onc,
                                  base::DictionaryValue* global_network_config)
      OVERRIDE;
  void OnDataRoamingSettingChanged();

  chromeos::NetworkDeviceHandler* network_device_handler_;
  chromeos::CrosSettings* cros_settings_;
  scoped_ptr<base::CallbackList<void(void)>::Subscription>
      data_roaming_setting_subscription_;

  base::WeakPtrFactory<DeviceNetworkConfigurationUpdater> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(DeviceNetworkConfigurationUpdater);
};

}  // namespace policy

#endif  // CHROME_BROWSER_CHROMEOS_POLICY_DEVICE_NETWORK_CONFIGURATION_UPDATER_H_