| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/user_prefs/tracked/device_id.h" | |
| 6 | |
| 7 #include <IOKit/IOKitLib.h> | |
| 8 | |
| 9 #include "base/mac/foundation_util.h" | |
| 10 #include "base/mac/scoped_cftyperef.h" | |
| 11 #include "base/mac/scoped_ioobject.h" | |
| 12 #include "base/strings/sys_string_conversions.h" | |
| 13 | |
| 14 MachineIdStatus GetDeterministicMachineSpecificId(std::string* machine_id) { | |
| 15 base::mac::ScopedIOObject<io_service_t> platform_expert( | |
| 16 IOServiceGetMatchingService(kIOMasterPortDefault, | |
| 17 IOServiceMatching("IOPlatformExpertDevice"))); | |
| 18 if (!platform_expert.get()) | |
| 19 return MachineIdStatus::FAILURE; | |
| 20 | |
| 21 base::ScopedCFTypeRef<CFTypeRef> uuid(IORegistryEntryCreateCFProperty( | |
| 22 platform_expert, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0)); | |
| 23 if (!uuid.get()) | |
| 24 return MachineIdStatus::FAILURE; | |
| 25 | |
| 26 CFStringRef uuid_string = base::mac::CFCast<CFStringRef>(uuid); | |
| 27 if (!uuid_string) | |
| 28 return MachineIdStatus::FAILURE; | |
| 29 | |
| 30 *machine_id = base::SysCFStringRefToUTF8(uuid_string); | |
| 31 return MachineIdStatus::SUCCESS; | |
| 32 } | |
| OLD | NEW |