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.
5 // Use the <code>chrome.image_writer</code> API to write images to
8 // See the design doc for a detailed description of this API.
9 // https://goo.gl/KzMEFq
10 namespace imageWriterPrivate
{
11 // The different stages of a write call.
14 // <dt>confirmation</dt>
15 // <dd>The process starts by prompting the user for confirmation.</dd>
17 // <dd>The image file is being download if a remote image was
19 // <dt>verifyDownload</dt>
20 // <dd>The download is being verified to match the image hash, if
23 // <dd>The image is being extracted from the downloaded zip file</dd>
25 // <dd>The image is being written to disk.</dd>
26 // <dt>verifyWrite</dt>
27 // <dt>The system is verifying that the written image matches the
28 // downloaded image.</dd>
40 // Options for writing an image.
41 dictionary UrlWriteOptions
{
42 // If present, verify that the downloaded image matches this hash.
44 // If true, save the downloaded image as a file using the user's downloads
46 boolean? saveAsDownload
;
49 dictionary ProgressInfo
{
50 // The $(ref:Stage) that the write process is currently in.
52 // Current progress within the stage.
56 dictionary RemovableStorageDevice
{
57 DOMString storageUnitId
;
64 callback WriteImageCallback
= void ();
65 callback WriteCancelCallback
= void ();
66 callback ListRemovableStorageDevicesCallback
= void (RemovableStorageDevice
[] devices
);
67 callback DestroyPartitionsCallback
= void ();
70 // Write an image to the disk downloaded from the provided URL. The
71 // callback will be called when the entire operation completes, either
72 // successfully or on error.
74 // |storageUnitId|: The identifier for the storage unit
75 // |imageUrl|: The url of the image to download which will be written
76 // to the storage unit identified by |storageUnitId|
77 // |options|: Optional parameters if comparing the download with a given
78 // hash or saving the download to the users Downloads folder instead of a
79 // temporary directory is desired
80 // |callback|: The callback which signifies that the write operation has
81 // been started by the system and provides a unique ID for this operation.
82 static
void writeFromUrl
(DOMString storageUnitId
,
84 optional UrlWriteOptions options
,
85 WriteImageCallback
callback);
87 // Write an image to the disk, prompting the user to supply the image from
88 // a local file. The callback will be called when the entire operation
89 // completes, either successfully or on error.
91 // |storageUnitId|: The identifier for the storage unit
92 // |fileEntry|: The FileEntry object of the image to be burned.
93 // |callback|: The callback which signifies that the write operation has
94 // been started by the system and provides a unique ID for this operation.
95 static
void writeFromFile
(DOMString storageUnitId
,
96 [instanceOf
=FileEntry
] object fileEntry
,
97 WriteImageCallback
callback);
99 // Cancel a current write operation.
101 // |callback|: The callback which is triggered with the write is
102 // successfully cancelled, passing the $(ref:ProgressInfo) of the operation at
103 // the time it was cancelled.
104 static
boolean cancelWrite
(WriteCancelCallback
callback);
106 // Destroys the partition table of a disk, effectively erasing it. This is
107 // a fairly quick operation and so it does not have complex stages or
108 // progress information, just a write phase.
110 // |storageUnitId|: The identifier of the storage unit to wipe
111 // |callback|: A callback that triggers when the operation has been
112 // successfully started.
113 static
void destroyPartitions
(DOMString storageUnitId
,
114 DestroyPartitionsCallback
callback);
116 // List all the removable block devices currently attached to the system.
117 // |callback|: A callback called with a list of removable storage devices
118 static
void listRemovableStorageDevices
(
119 ListRemovableStorageDevicesCallback
callback);
123 // Fires periodically throughout the writing operation and at least once per
125 static
void onWriteProgress
(ProgressInfo info
);
127 // Fires when the write operation has completely finished, such as all
128 // devices being finalized and resources released.
129 static
void onWriteComplete
();
131 // Fires when an error occured during writing, passing the $(ref:ProgressInfo)
132 // of the operation at the time the error occured.
133 static
void onWriteError
(ProgressInfo info
, DOMString error
);
135 // Fires when a removable storage device is inserted.
136 static
void onDeviceInserted
(RemovableStorageDevice device
);
138 // Fires when a removable storage device is removed.
139 static
void onDeviceRemoved
(RemovableStorageDevice device
);