OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/policy/core/common/preg_parser.h" | 5 #include "components/policy/core/common/preg_parser.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 return base::UTF16ToUTF8(result); | 141 return base::UTF16ToUTF8(result); |
142 } | 142 } |
143 | 143 |
144 // Decodes a value from a PReg file given as a uint8_t vector. | 144 // Decodes a value from a PReg file given as a uint8_t vector. |
145 bool DecodePRegValue(uint32_t type, | 145 bool DecodePRegValue(uint32_t type, |
146 const std::vector<uint8_t>& data, | 146 const std::vector<uint8_t>& data, |
147 std::unique_ptr<base::Value>* value) { | 147 std::unique_ptr<base::Value>* value) { |
148 switch (type) { | 148 switch (type) { |
149 case REG_SZ: | 149 case REG_SZ: |
150 case REG_EXPAND_SZ: | 150 case REG_EXPAND_SZ: |
151 value->reset(new base::StringValue(DecodePRegStringValue(data))); | 151 value->reset(new base::Value(DecodePRegStringValue(data))); |
152 return true; | 152 return true; |
153 case REG_DWORD_LITTLE_ENDIAN: | 153 case REG_DWORD_LITTLE_ENDIAN: |
154 case REG_DWORD_BIG_ENDIAN: | 154 case REG_DWORD_BIG_ENDIAN: |
155 if (data.size() == sizeof(uint32_t)) { | 155 if (data.size() == sizeof(uint32_t)) { |
156 uint32_t val = *reinterpret_cast<const uint32_t*>(data.data()); | 156 uint32_t val = *reinterpret_cast<const uint32_t*>(data.data()); |
157 if (type == REG_DWORD_BIG_ENDIAN) | 157 if (type == REG_DWORD_BIG_ENDIAN) |
158 val = base::NetToHost32(val); | 158 val = base::NetToHost32(val); |
159 else | 159 else |
160 val = base::ByteSwapToLE32(val); | 160 val = base::ByteSwapToLE32(val); |
161 value->reset(new base::Value(static_cast<int>(val))); | 161 value->reset(new base::Value(static_cast<int>(val))); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 | 343 |
344 LOG(ERROR) << "Error parsing " << file_path.value() << " at offset " | 344 LOG(ERROR) << "Error parsing " << file_path.value() << " at offset " |
345 << reinterpret_cast<const uint8_t*>(cursor - 1) - | 345 << reinterpret_cast<const uint8_t*>(cursor - 1) - |
346 mapped_file.data(); | 346 mapped_file.data(); |
347 status->Add(POLICY_LOAD_STATUS_PARSE_ERROR); | 347 status->Add(POLICY_LOAD_STATUS_PARSE_ERROR); |
348 return false; | 348 return false; |
349 } | 349 } |
350 | 350 |
351 } // namespace preg_parser | 351 } // namespace preg_parser |
352 } // namespace policy | 352 } // namespace policy |
OLD | NEW |