1 // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef LIBBRILLO_POLICY_POLICY_UTIL_H_ 6 #define LIBBRILLO_POLICY_POLICY_UTIL_H_ 7 8 #include <string> 9 10 #include <base/files/file_path.h> 11 #include <brillo/brillo_export.h> 12 13 #include "bindings/device_management_backend.pb.h" 14 15 namespace policy { 16 17 // The detailed information of the result from loading the policy data. 18 enum class BRILLO_EXPORT LoadPolicyResult { 19 kSuccess = 0, 20 kFileNotFound = 1, 21 kFailedToReadFile = 2, 22 kEmptyFile = 3, 23 kInvalidPolicyData = 4 24 }; 25 26 // Reads and parses the policy data from |policy_path|. Returns the details 27 // in LoadPolicyResult. In case response is |kSuccess|, |policy_data_str_out| 28 // contains the raw data from the file, while |policy_out| contains the parsed 29 // policy data. Otherwise the contents of |policy_data_str_out| and |policy_out| 30 // is undefined. 31 BRILLO_EXPORT LoadPolicyResult LoadPolicyFromPath( 32 const base::FilePath& policy_path, 33 std::string* policy_data_str_out, 34 enterprise_management::PolicyFetchResponse* policy_out); 35 36 } // namespace policy 37 38 #endif // LIBBRILLO_POLICY_POLICY_UTIL_H_ 39