| Index: device/hid/hid_utils_mac.cc
|
| diff --git a/device/hid/hid_utils_mac.cc b/device/hid/hid_utils_mac.cc
|
| index 588041a3ccb2b3c614b29c413236302d2af731fb..46605d87bdb2a12fa165e54901b822a6a5433f68 100644
|
| --- a/device/hid/hid_utils_mac.cc
|
| +++ b/device/hid/hid_utils_mac.cc
|
| @@ -1,32 +1,38 @@
|
| -// Copyright (c) 2014 The Chromium Authors. All rights reserved.
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| #include "device/hid/hid_utils_mac.h"
|
|
|
| -#include "base/basictypes.h"
|
| -#include "base/logging.h"
|
| #include "base/mac/foundation_util.h"
|
| #include "base/strings/sys_string_conversions.h"
|
|
|
| -#if defined(OS_MACOSX)
|
| -#include <CoreFoundation/CoreFoundation.h>
|
| -#include <IOKit/hid/IOHIDManager.h>
|
| -#endif
|
| -
|
| namespace device {
|
|
|
| -bool GetHidIntProperty(IOHIDDeviceRef device,
|
| - CFStringRef key,
|
| - int32_t* result) {
|
| +int32_t GetHidIntProperty(IOHIDDeviceRef device, CFStringRef key) {
|
| + int32_t value;
|
| + if (TryGetHidIntProperty(device, key, &value))
|
| + return value;
|
| + return 0;
|
| +}
|
| +
|
| +std::string GetHidStringProperty(IOHIDDeviceRef device, CFStringRef key) {
|
| + std::string value;
|
| + TryGetHidStringProperty(device, key, &value);
|
| + return value;
|
| +}
|
| +
|
| +bool TryGetHidIntProperty(IOHIDDeviceRef device,
|
| + CFStringRef key,
|
| + int32_t* result) {
|
| CFNumberRef ref = base::mac::CFCast<CFNumberRef>(
|
| IOHIDDeviceGetProperty(device, key));
|
| return ref && CFNumberGetValue(ref, kCFNumberSInt32Type, result);
|
| }
|
|
|
| -bool GetHidStringProperty(IOHIDDeviceRef device,
|
| - CFStringRef key,
|
| - std::string* result) {
|
| +bool TryGetHidStringProperty(IOHIDDeviceRef device,
|
| + CFStringRef key,
|
| + std::string* result) {
|
| CFStringRef ref = base::mac::CFCast<CFStringRef>(
|
| IOHIDDeviceGetProperty(device, key));
|
| if (!ref) {
|
|
|