| OLD | NEW |
| 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 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // lossy. Check the type before trying to convert. | 57 // lossy. Check the type before trying to convert. |
| 58 if (CFNumberIsFloatType(number)) { | 58 if (CFNumberIsFloatType(number)) { |
| 59 double double_value = 0.0; | 59 double double_value = 0.0; |
| 60 if (CFNumberGetValue(number, kCFNumberDoubleType, &double_value)) { | 60 if (CFNumberGetValue(number, kCFNumberDoubleType, &double_value)) { |
| 61 return scoped_ptr<base::Value>( | 61 return scoped_ptr<base::Value>( |
| 62 base::Value::CreateDoubleValue(double_value)); | 62 base::Value::CreateDoubleValue(double_value)); |
| 63 } | 63 } |
| 64 } else { | 64 } else { |
| 65 int int_value = 0; | 65 int int_value = 0; |
| 66 if (CFNumberGetValue(number, kCFNumberIntType, &int_value)) { | 66 if (CFNumberGetValue(number, kCFNumberIntType, &int_value)) { |
| 67 return scoped_ptr<base::Value>( | 67 return scoped_ptr<base::Value>(new base::FundamentalValue(int_value)); |
| 68 base::Value::CreateIntegerValue(int_value)); | |
| 69 } | 68 } |
| 70 } | 69 } |
| 71 } | 70 } |
| 72 | 71 |
| 73 if (CFStringRef string = CFCast<CFStringRef>(property)) { | 72 if (CFStringRef string = CFCast<CFStringRef>(property)) { |
| 74 return scoped_ptr<base::Value>( | 73 return scoped_ptr<base::Value>( |
| 75 base::Value::CreateStringValue(base::SysCFStringRefToUTF8(string))); | 74 base::Value::CreateStringValue(base::SysCFStringRefToUTF8(string))); |
| 76 } | 75 } |
| 77 | 76 |
| 78 if (CFDictionaryRef dict = CFCast<CFDictionaryRef>(property)) { | 77 if (CFDictionaryRef dict = CFCast<CFDictionaryRef>(property)) { |
| 79 scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue()); | 78 scoped_ptr<base::DictionaryValue> dict_value(new base::DictionaryValue()); |
| 80 CFDictionaryApplyFunction(dict, DictionaryEntryToValue, dict_value.get()); | 79 CFDictionaryApplyFunction(dict, DictionaryEntryToValue, dict_value.get()); |
| 81 return dict_value.PassAs<base::Value>(); | 80 return dict_value.PassAs<base::Value>(); |
| 82 } | 81 } |
| 83 | 82 |
| 84 if (CFArrayRef array = CFCast<CFArrayRef>(property)) { | 83 if (CFArrayRef array = CFCast<CFArrayRef>(property)) { |
| 85 scoped_ptr<base::ListValue> list_value(new base::ListValue()); | 84 scoped_ptr<base::ListValue> list_value(new base::ListValue()); |
| 86 CFArrayApplyFunction(array, | 85 CFArrayApplyFunction(array, |
| 87 CFRangeMake(0, CFArrayGetCount(array)), | 86 CFRangeMake(0, CFArrayGetCount(array)), |
| 88 ArrayEntryToValue, | 87 ArrayEntryToValue, |
| 89 list_value.get()); | 88 list_value.get()); |
| 90 return list_value.PassAs<base::Value>(); | 89 return list_value.PassAs<base::Value>(); |
| 91 } | 90 } |
| 92 | 91 |
| 93 return scoped_ptr<base::Value>(); | 92 return scoped_ptr<base::Value>(); |
| 94 } | 93 } |
| 95 | 94 |
| 96 } // namespace policy | 95 } // namespace policy |
| OLD | NEW |