1 // Copyright (c) 2012 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.mediaGalleries</code> API to access media files (images, 6 // video, audio) from the user's local disks (with the user's consent). 7 namespace mediaGalleries { 8 9 [inline_doc] enum GetMediaFileSystemsInteractivity { 10 // Do not act interactively. 11 no, 12 // Ask the user to manage permitted media galleries. 13 yes, 14 // Ask the user to manage permitted galleries only if the return set would 15 // otherwise be empty. 16 if_needed 17 }; 18 19 enum GetMetadataType { 20 // Retrieve all available metadata. 21 all, 22 // Retrieve only the mime type. 23 mimeTypeOnly 24 }; 25 26 [inline_doc] dictionary MediaFileSystemsDetails { 27 // Whether to prompt the user for permission to additional media galleries 28 // before returning the permitted set. Default is silent. If the value 29 // 'yes' is passed, or if the application has not been granted access to 30 // any media galleries and the value 'if_needed' is passed, then the 31 // media gallery configuration dialog will be displayed. 32 GetMediaFileSystemsInteractivity? interactive; 33 }; 34 35 dictionary MediaMetadataOptions { 36 // Specifies which subset of the metadata to retrieve. Defaults to 'all' 37 // if the option is omitted. 38 GetMetadataType? metadataType; 39 }; 40 41 callback MediaFileSystemsCallback = 42 void ([instanceOf=DOMFileSystem] optional object[] mediaFileSystems); 43 44 [inline_doc] dictionary MediaFileSystemMetadata { 45 // The name of the file system. 46 DOMString name; 47 48 // A unique and persistent id for the media gallery. 49 DOMString galleryId; 50 51 // If the media gallery is on a removable device, a unique id for the 52 // device while the device is online. 53 DOMString? deviceId; 54 55 // True if the media gallery is on a removable device. 56 boolean isRemovable; 57 58 // True if the device the media gallery is on was detected as a media 59 // device. i.e. a PTP or MTP device, or a DCIM directory is present. 60 boolean isMediaDevice; 61 62 // True if the device is currently available. 63 boolean isAvailable; 64 }; 65 66 callback MediaFileSystemsMetadataCallback = 67 void (MediaFileSystemMetadata[] metadata); 68 69 dictionary MediaMetadata { 70 // The browser sniffed mime type. 71 DOMString mimeType; 72 }; 73 74 callback MediaMetadataCallback = void (MediaMetadata metadata); 75 76 interface Functions { 77 // Get the media galleries configured in this user agent. If none are 78 // configured or available, the callback will receive an empty array. 79 static void getMediaFileSystems(optional MediaFileSystemsDetails details, 80 MediaFileSystemsCallback callback); 81 82 // Get metadata about a specific media file system. 83 [nocompile] static MediaFileSystemMetadata getMediaFileSystemMetadata( 84 [instanceOf=DOMFileSystem] object mediaFileSystem); 85 86 // Get metadata for all available media galleries. 87 static void getAllMediaFileSystemMetadata( 88 MediaFileSystemsMetadataCallback callback); 89 90 // Gets the media-specific metadata for a media file. This should work 91 // for files in media galleries as well as other DOM filesystems. 92 static void getMetadata([instanceOf=Blob] object mediaFile, 93 optional MediaMetadataOptions options, 94 MediaMetadataCallback callback); 95 }; 96 97 }; 98