1 // Copyright 2015 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.
7 var dialogSettings
= {};
9 function mountFileSystem(onSuccess
, onError
) {
10 chrome
.fileSystemProvider
.getAll(function(mounted
) {
11 var index
= mounted
.length
+ 1;
12 chrome
.fileSystemProvider
.mount({
13 fileSystemId
: 'test-fs-' + index
,
14 displayName
: 'Test (' + index
+ ')'
19 chrome
.fileSystemProvider
.onGetMetadataRequested
.addListener(
20 function(options
, onSuccess
, onError
) {
25 modificationTime
: new Date()
29 chrome
.fileSystemProvider
.onReadDirectoryRequested
.addListener(
30 function(options
, onSuccess
, onError
) {
31 onSuccess([], false /* hasMore */);
34 chrome
.fileSystemProvider
.onMountRequested
.addListener(mountFileSystem
);
36 chrome
.fileSystemProvider
.onUnmountRequested
.addListener(
37 function(options
, onSuccess
, onError
) {
38 chrome
.fileSystemProvider
.unmount(
40 fileSystemId
: options
.fileSystemId
43 if (chrome
.runtime
.lastError
)
44 onError(chrome
.runtime
.lastError
.message
);
50 // If the manifest for device or file source is used, then mount a fake file
52 if (chrome
.runtime
.getManifest().name
=== "Testing Provider Device" ||
53 chrome
.runtime
.getManifest().name
=== "Testing Provider File") {
54 chrome
.runtime
.onInstalled
.addListener(mountFileSystem
);