summaryrefslogtreecommitdiffstats
path: root/chrome/browser/configuration_policy_provider_win.h
blob: 235e2ee1268bf630ea565a969bc64525f76c9469 (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
// Copyright (c) 2010 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_CONFIGURATION_POLICY_PROVIDER_WIN_H_
#define CHROME_BROWSER_CONFIGURATION_POLICY_PROVIDER_WIN_H_

#include "chrome/browser/configuration_policy_store.h"
#include "chrome/browser/configuration_policy_provider.h"

// An implementation of |ConfigurationPolicyProvider| using the
// mechanism provided by Windows Groups Policy. Policy decisions are
// stored as values in a special section of the Windows Registry.
// On a managed machine in a domain, this portion of the registry is
// periodically updated by the Windows Group Policy machinery to contain
// the latest version of the policy set by administrators.
class ConfigurationPolicyProviderWin : public ConfigurationPolicyProvider {
 public:
  ConfigurationPolicyProviderWin();
  virtual ~ConfigurationPolicyProviderWin() { }

  // ConfigurationPolicyProvider method overrides:
  virtual bool Provide(ConfigurationPolicyStore* store);

 protected:
  // The sub key path for Chromium's Group Policy information in the
  // Windows registry.
  static const wchar_t kPolicyRegistrySubKey[];

  // Constants specifying the names of policy-specifying registry values
  // in |kChromiumPolicySubKey|.
  static const wchar_t kHomepageRegistryValueName[];
  static const wchar_t kHomepageIsNewTabPageRegistryValueName[];
  static const wchar_t kCookiesModeRegistryValueName[];

 private:
  // For each Group Policy registry value that maps to a browser policy, there
  // is an entry in |registry_to_policy_map_| of type |RegistryPolicyMapEntry|
  // that specifies the registry value name and the browser policy that it
  // maps to.
  struct RegistryPolicyMapEntry {
    Value::ValueType value_type;
    ConfigurationPolicyStore::PolicyType policy_type;
    const wchar_t* registry_value_name;
  };

  static const RegistryPolicyMapEntry registry_to_policy_map_[];

  // Methods to perfrom type-specific policy lookups in the registry.
  // HKLM is checked first, then HKCU.
  bool GetRegistryPolicyString(const wchar_t* value_name, string16* result);
  bool GetRegistryPolicyBoolean(const wchar_t* value_name, bool* result);
  bool GetRegistryPolicyInteger(const wchar_t* value_name, uint32* result);
};

#endif  // CHROME_BROWSER_CONFIGURATION_POLICY_PROVIDER_WIN_H_