Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(498)

Side by Side Diff: components/policy/core/common/preg_parser_win.cc

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_win.h" 5 #include "components/policy/core/common/preg_parser_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return base::UTF16ToUTF8(result); 111 return base::UTF16ToUTF8(result);
112 } 112 }
113 113
114 // Decodes a value from a PReg file given as a uint8 vector. 114 // Decodes a value from a PReg file given as a uint8 vector.
115 bool DecodePRegValue(uint32 type, 115 bool DecodePRegValue(uint32 type,
116 const std::vector<uint8>& data, 116 const std::vector<uint8>& data,
117 scoped_ptr<base::Value>* value) { 117 scoped_ptr<base::Value>* value) {
118 switch (type) { 118 switch (type) {
119 case REG_SZ: 119 case REG_SZ:
120 case REG_EXPAND_SZ: 120 case REG_EXPAND_SZ:
121 value->reset(base::Value::CreateStringValue(DecodePRegStringValue(data))); 121 value->reset(new base::StringValue(DecodePRegStringValue(data)));
122 return true; 122 return true;
123 case REG_DWORD_LITTLE_ENDIAN: 123 case REG_DWORD_LITTLE_ENDIAN:
124 case REG_DWORD_BIG_ENDIAN: 124 case REG_DWORD_BIG_ENDIAN:
125 if (data.size() == sizeof(uint32)) { 125 if (data.size() == sizeof(uint32)) {
126 uint32 val = *reinterpret_cast<const uint32*>(vector_as_array(&data)); 126 uint32 val = *reinterpret_cast<const uint32*>(vector_as_array(&data));
127 if (type == REG_DWORD_BIG_ENDIAN) 127 if (type == REG_DWORD_BIG_ENDIAN)
128 val = base::NetToHost32(val); 128 val = base::NetToHost32(val);
129 else 129 else
130 val = base::ByteSwapToLE32(val); 130 val = base::ByteSwapToLE32(val);
131 value->reset(new base::FundamentalValue(static_cast<int>(val))); 131 value->reset(new base::FundamentalValue(static_cast<int>(val)));
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 } 300 }
301 301
302 LOG(ERROR) << "Error parsing " << file_path.value() << " at offset " 302 LOG(ERROR) << "Error parsing " << file_path.value() << " at offset "
303 << reinterpret_cast<const uint8*>(cursor - 1) - mapped_file.data(); 303 << reinterpret_cast<const uint8*>(cursor - 1) - mapped_file.data();
304 status->Add(POLICY_LOAD_STATUS_PARSE_ERROR); 304 status->Add(POLICY_LOAD_STATUS_PARSE_ERROR);
305 return false; 305 return false;
306 } 306 }
307 307
308 } // namespace preg_parser 308 } // namespace preg_parser
309 } // namespace policy 309 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698