summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/network_configuration_updater.h
blob: 27a149a07c56881f977d024cee1c40983e486c7d (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
// 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_NETWORK_CONFIGURATION_UPDATER_H_
#define CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_
#pragma once

#include <string>

#include "chrome/browser/chromeos/cros/network_ui_data.h"
#include "chrome/browser/policy/configuration_policy_provider.h"

namespace chromeos {
class NetworkLibrary;
}

namespace policy {

class PolicyMap;

// Keeps track of the network configuration policy settings and updates the
// network definitions whenever the configuration changes.
class NetworkConfigurationUpdater
    : public ConfigurationPolicyProvider::Observer {
 public:
  NetworkConfigurationUpdater(ConfigurationPolicyProvider* provider,
                              chromeos::NetworkLibrary* network_library);
  virtual ~NetworkConfigurationUpdater();

  // ConfigurationPolicyProvider::Observer:
  virtual void OnUpdatePolicy(ConfigurationPolicyProvider* provider) OVERRIDE;

 private:
  // Grabs network configuration from policy and applies it.
  void Update();

  // Extracts ONC string from |policy_map| and pushes the configuration to
  // |network_library_| if it's different from |*cached_value| (which is
  // updated).
  void ApplyNetworkConfiguration(const PolicyMap& policy_map,
                                 ConfigurationPolicyType policy_type,
                                 chromeos::NetworkUIData::ONCSource onc_source,
                                 std::string* cached_value);

  // Wraps the provider we read network configuration from.
  ConfigurationPolicyObserverRegistrar provider_registrar_;

  // Network library to write network configuration to.
  chromeos::NetworkLibrary* network_library_;

  // Current settings.
  std::string device_network_config_;
  std::string user_network_config_;

  DISALLOW_COPY_AND_ASSIGN(NetworkConfigurationUpdater);
};

}  // namespace policy

#endif  // CHROME_BROWSER_POLICY_NETWORK_CONFIGURATION_UPDATER_H_