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

Side by Side Diff: trunk/src/device/hid/hid_utils_mac.cc

Issue 364213005: Revert 281282 "Revert 281133 "chrome.hid: enrich model with repo..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/device/hid/hid_utils_mac.h ('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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "device/hid/hid_utils_mac.h"
6
7 #include "base/mac/foundation_util.h"
8 #include "base/strings/sys_string_conversions.h"
9
10 namespace device {
11
12 int32_t GetHidIntProperty(IOHIDDeviceRef device, CFStringRef key) {
13 int32_t value;
14 if (TryGetHidIntProperty(device, key, &value))
15 return value;
16 return 0;
17 }
18
19 std::string GetHidStringProperty(IOHIDDeviceRef device, CFStringRef key) {
20 std::string value;
21 TryGetHidStringProperty(device, key, &value);
22 return value;
23 }
24
25 bool TryGetHidIntProperty(IOHIDDeviceRef device,
26 CFStringRef key,
27 int32_t* result) {
28 CFNumberRef ref = base::mac::CFCast<CFNumberRef>(
29 IOHIDDeviceGetProperty(device, key));
30 return ref && CFNumberGetValue(ref, kCFNumberSInt32Type, result);
31 }
32
33 bool TryGetHidStringProperty(IOHIDDeviceRef device,
34 CFStringRef key,
35 std::string* result) {
36 CFStringRef ref = base::mac::CFCast<CFStringRef>(
37 IOHIDDeviceGetProperty(device, key));
38 if (!ref) {
39 return false;
40 }
41 *result = base::SysCFStringRefToUTF8(ref);
42 return true;
43 }
44
45 } // namespace device
OLDNEW
« no previous file with comments | « trunk/src/device/hid/hid_utils_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698