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

Side by Side Diff: chrome/common/extensions/image_writer/image_writer_test_util_mac.cc

Issue 294163008: Adds USB writing for OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@list-devices
Patch Set: Creates a location for code shared between browser and utility process. Created 6 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
(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 "chrome/common/extensions/image_writer/image_writer_test_util_mac.h"
6
7 namespace extensions {
8 namespace image_writer {
9
10 // Creates a disk-description dictionary.
11 base::ScopedCFTypeRef<CFDictionaryRef> CreateDiskDictionary(
12 const std::string& bsd_name,
13 const std::string& vendor,
14 const std::string& model,
15 int64 capacity,
16 DriveType type) {
17 base::ScopedCFTypeRef<CFMutableDictionaryRef> dict(
18 CFDictionaryCreateMutable(kCFAllocatorDefault,
19 0,
20 &kCFTypeDictionaryKeyCallBacks,
21 &kCFTypeDictionaryValueCallBacks));
22
23 CFDictionaryAddValue(dict,
24 kDADiskDescriptionMediaBSDNameKey,
25 base::SysUTF8ToCFStringRef(bsd_name));
26 CFDictionaryAddValue(dict,
27 kDADiskDescriptionDeviceVendorKey,
28 base::SysUTF8ToCFStringRef(vendor));
29 CFDictionaryAddValue(dict,
30 kDADiskDescriptionDeviceModelKey,
31 base::SysUTF8ToCFStringRef(model));
32 CFDictionaryAddValue(dict, kDADiskDescriptionMediaWholeKey, kCFBooleanTrue);
33 CFDictionaryAddValue(
34 dict,
35 kDADiskDescriptionMediaSizeKey,
36 CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &capacity));
37
38 if (type == DriveType::FIXED) {
39 CFDictionaryAddValue(dict,
40 kDADiskDescriptionDeviceProtocolKey,
41 CFSTR(kIOPropertyPhysicalInterconnectTypeSerialATA));
42 CFDictionaryAddValue(
43 dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanTrue);
44 CFDictionaryAddValue(
45 dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanFalse);
46 CFDictionaryAddValue(
47 dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanFalse);
48 CFDictionaryAddValue(
49 dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
50 CFDictionaryAddValue(
51 dict, kDADiskDescriptionDevicePathKey, CFSTR("Fixed Device Path"));
52 } else if (type == DriveType::USB) {
53 CFDictionaryAddValue(dict,
54 kDADiskDescriptionDeviceProtocolKey,
55 CFSTR(kIOPropertyPhysicalInterconnectTypeUSB));
56 CFDictionaryAddValue(
57 dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanFalse);
58 CFDictionaryAddValue(
59 dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
60 CFDictionaryAddValue(
61 dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
62 CFDictionaryAddValue(
63 dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
64 CFDictionaryAddValue(
65 dict, kDADiskDescriptionDevicePathKey, CFSTR("USB Device Path"));
66 } else if (type == DriveType::CD) {
67 CFDictionaryAddValue(dict,
68 kDADiskDescriptionDeviceProtocolKey,
69 CFSTR(kIOPropertyPhysicalInterconnectTypeSerialATA));
70 CFDictionaryAddValue(
71 dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanFalse);
72 CFDictionaryAddValue(
73 dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
74 CFDictionaryAddValue(
75 dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
76 CFDictionaryAddValue(
77 dict, kDADiskDescriptionMediaKindKey, CFSTR("IOCDMedia"));
78 CFDictionaryAddValue(
79 dict, kDADiskDescriptionDevicePathKey, CFSTR("CD Device Path"));
80 } else if (type == DriveType::SD) {
81 CFDictionaryAddValue(dict,
82 kDADiskDescriptionDeviceProtocolKey,
83 CFSTR(kIOPropertyPhysicalInterconnectTypeUSB));
84 CFDictionaryAddValue(
85 dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanTrue);
86 CFDictionaryAddValue(
87 dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
88 CFDictionaryAddValue(
89 dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
90 CFDictionaryAddValue(
91 dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
92 CFDictionaryAddValue(dict,
93 kDADiskDescriptionDevicePathKey,
94 CFSTR("SD Device Path e.g. AppleUSBCardReader"));
95 }
96
97 return base::ScopedCFTypeRef<CFDictionaryRef>(dict,
98 base::scoped_policy::RETAIN);
99 }
100
101 } // image_writer
102 } // extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698