-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpolicy_tool.h
55 lines (40 loc) · 1.74 KB
/
policy_tool.h
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
// Copyright 2018 The Chromium OS 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 POLICY_UTILS_POLICY_TOOL_H_
#define POLICY_UTILS_POLICY_TOOL_H_
#include <string>
#include <vector>
#include <base/command_line.h>
#include "policy_utils/policy_writer.h"
namespace policy_utils {
// Utility class to parse a command, policy name and optional parameters from a
// list of cmd-line arguments and perform the desired action.
class PolicyTool {
public:
// The directory path where JSON files should be stored to automatically
// override policies in Chrome.
constexpr static char kChromePolicyDirPath[] =
"/etc/opt/chrome/policies/managed/";
// The directory path where JSON files should be stored to automatically
// override policies in Chromium.
constexpr static char kChromiumPolicyDirPath[] =
"/etc/chromium/policies/managed";
// PolicyList is a list of policy names.
typedef std::vector<const std::string> PolicyList;
// Create a PolicyTool instance that writes policy JSON files to the specified
// directory. Use one of the standard paths above for overriding policies in
// Chrome or Chromium.
explicit PolicyTool(const std::string& policy_dir_path);
PolicyTool(const PolicyTool&) = delete;
PolicyTool& operator=(const PolicyTool&) = delete;
~PolicyTool() = default;
// Parse and perform the command specified by args. Return whether successful.
bool DoCommand(const base::CommandLine::StringVector& args) const;
// Return a list of policies this tool knows how to handle.
static const PolicyList& get_policies();
private:
PolicyWriter writer_;
};
} // namespace policy_utils
#endif // POLICY_UTILS_POLICY_TOOL_H_