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

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

Issue 2911033002: Remove raw base::DictionaryValue::Set (Closed)
Patch Set: Proper Windows Fix Created 3 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/mac_util.h" 5 #include "components/policy/core/common/mac_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 14
15 using base::mac::CFCast; 15 using base::mac::CFCast;
16 16
17 namespace policy { 17 namespace policy {
18 18
19 namespace { 19 namespace {
20 20
21 // Callback function for CFDictionaryApplyFunction. |key| and |value| are an 21 // Callback function for CFDictionaryApplyFunction. |key| and |value| are an
22 // entry of the CFDictionary that should be converted into an equivalent entry 22 // entry of the CFDictionary that should be converted into an equivalent entry
23 // in the DictionaryValue in |context|. 23 // in the DictionaryValue in |context|.
24 void DictionaryEntryToValue(const void* key, const void* value, void* context) { 24 void DictionaryEntryToValue(const void* key, const void* value, void* context) {
25 if (CFStringRef cf_key = CFCast<CFStringRef>(key)) { 25 if (CFStringRef cf_key = CFCast<CFStringRef>(key)) {
26 std::unique_ptr<base::Value> converted = 26 std::unique_ptr<base::Value> converted =
27 PropertyToValue(static_cast<CFPropertyListRef>(value)); 27 PropertyToValue(static_cast<CFPropertyListRef>(value));
28 if (converted) { 28 if (converted) {
29 const std::string string = base::SysCFStringRefToUTF8(cf_key); 29 const std::string string = base::SysCFStringRefToUTF8(cf_key);
30 static_cast<base::DictionaryValue*>(context)->Set( 30 static_cast<base::DictionaryValue*>(context)->Set(string,
31 string, converted.release()); 31 std::move(converted));
32 } 32 }
33 } 33 }
34 } 34 }
35 35
36 // Callback function for CFArrayApplyFunction. |value| is an entry of the 36 // Callback function for CFArrayApplyFunction. |value| is an entry of the
37 // CFArray that should be converted into an equivalent entry in the ListValue 37 // CFArray that should be converted into an equivalent entry in the ListValue
38 // in |context|. 38 // in |context|.
39 void ArrayEntryToValue(const void* value, void* context) { 39 void ArrayEntryToValue(const void* value, void* context) {
40 std::unique_ptr<base::Value> converted = 40 std::unique_ptr<base::Value> converted =
41 PropertyToValue(static_cast<CFPropertyListRef>(value)); 41 PropertyToValue(static_cast<CFPropertyListRef>(value));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 CFRangeMake(0, CFArrayGetCount(array)), 88 CFRangeMake(0, CFArrayGetCount(array)),
89 ArrayEntryToValue, 89 ArrayEntryToValue,
90 list_value.get()); 90 list_value.get());
91 return std::move(list_value); 91 return std::move(list_value);
92 } 92 }
93 93
94 return nullptr; 94 return nullptr;
95 } 95 }
96 96
97 } // namespace policy 97 } // namespace policy
OLDNEW
« no previous file with comments | « components/cloud_devices/common/description_items_inl.h ('k') | components/policy/core/common/policy_loader_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698