1 // Copyright 2013 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 // Use the <code>chrome.system.storage</code> API to query storage device 6 // information and be notified when a removable storage device is attached and 7 // detached. 8 namespace system.storage { 9 10 enum StorageUnitType { 11 // The storage has fixed media, e.g. hard disk or SSD. 12 fixed, 13 // The storage is removable, e.g. USB flash drive. 14 removable, 15 // The storage type is unknown. 16 unknown 17 }; 18 19 dictionary StorageUnitInfo { 20 // The transient ID that uniquely identifies the storage device. 21 // This ID will be persistent within the same run of a single application. 22 // It will not be a persistent identifier between different runs of an 23 // application, or between different applications. 24 DOMString id; 25 // The name of the storage unit. 26 DOMString name; 27 // The media type of the storage unit. 28 StorageUnitType type; 29 // The total amount of the storage space, in bytes. 30 double capacity; 31 }; 32 33 [inline_doc] enum EjectDeviceResultCode { 34 // The ejection command is successful -- the application can prompt the user 35 // to remove the device. 36 success, 37 // The device is in use by another application. The ejection did not 38 // succeed; the user should not remove the device until the other 39 // application is done with the device. 40 in_use, 41 // There is no such device known. 42 no_such_device, 43 // The ejection command failed. 44 failure 45 }; 46 47 callback EjectDeviceCallback = void (EjectDeviceResultCode result); 48 49 callback StorageInfoCallback = void (StorageUnitInfo[] info); 50 51 interface Functions { 52 // Get the storage information from the system. The argument passed to the 53 // callback is an array of StorageUnitInfo objects. 54 static void getInfo(StorageInfoCallback callback); 55 56 // Ejects a removable storage device. 57 static void ejectDevice(DOMString id, EjectDeviceCallback callback); 58 }; 59 60 interface Events { 61 // Fired when a new removable storage is attached to the system. 62 static void onAttached(StorageUnitInfo info); 63 64 // Fired when a removable storage is detached from the system. 65 static void onDetached(DOMString id); 66 }; 67 68 }; 69 70