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

Side by Side Diff: mojo/common/values_struct_traits.cc

Issue 2636113002: Change base::DictionaryValue mojo deserialization to not expand paths. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « mojo/common/common_custom_types_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "mojo/common/values_struct_traits.h" 6 #include "mojo/common/values_struct_traits.h"
7 7
8 namespace mojo { 8 namespace mojo {
9 9
10 bool StructTraits<common::mojom::ListValueDataView, 10 bool StructTraits<common::mojom::ListValueDataView,
(...skipping 21 matching lines...) Expand all
32 std::unique_ptr<base::DictionaryValue>* value_out) { 32 std::unique_ptr<base::DictionaryValue>* value_out) {
33 mojo::MapDataView<mojo::StringDataView, common::mojom::ValueDataView> view; 33 mojo::MapDataView<mojo::StringDataView, common::mojom::ValueDataView> view;
34 data.GetValuesDataView(&view); 34 data.GetValuesDataView(&view);
35 auto dictionary_value = base::MakeUnique<base::DictionaryValue>(); 35 auto dictionary_value = base::MakeUnique<base::DictionaryValue>();
36 for (size_t i = 0; i < view.size(); ++i) { 36 for (size_t i = 0; i < view.size(); ++i) {
37 base::StringPiece key; 37 base::StringPiece key;
38 std::unique_ptr<base::Value> value; 38 std::unique_ptr<base::Value> value;
39 if (!view.keys().Read(i, &key) || !view.values().Read(i, &value)) 39 if (!view.keys().Read(i, &key) || !view.values().Read(i, &value))
40 return false; 40 return false;
41 41
42 dictionary_value->Set(key, std::move(value)); 42 dictionary_value->SetWithoutPathExpansion(key, std::move(value));
43 } 43 }
44 *value_out = std::move(dictionary_value); 44 *value_out = std::move(dictionary_value);
45 return true; 45 return true;
46 } 46 }
47 47
48 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>:: 48 bool UnionTraits<common::mojom::ValueDataView, std::unique_ptr<base::Value>>::
49 Read(common::mojom::ValueDataView data, 49 Read(common::mojom::ValueDataView data,
50 std::unique_ptr<base::Value>* value_out) { 50 std::unique_ptr<base::Value>* value_out) {
51 switch (data.tag()) { 51 switch (data.tag()) {
52 case common::mojom::ValueDataView::Tag::NULL_VALUE: { 52 case common::mojom::ValueDataView::Tag::NULL_VALUE: {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (!data.ReadListValue(&list_value)) 93 if (!data.ReadListValue(&list_value))
94 return false; 94 return false;
95 *value_out = std::move(list_value); 95 *value_out = std::move(list_value);
96 return true; 96 return true;
97 } 97 }
98 } 98 }
99 return false; 99 return false;
100 } 100 }
101 101
102 } // namespace mojo 102 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/common/common_custom_types_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698