OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Custom binding for the fileSystem API. | 5 // Custom binding for the fileSystem API. |
6 | 6 |
7 var binding = require('binding').Binding.create('fileSystem'); | 7 var binding = require('binding').Binding.create('fileSystem'); |
8 var sendRequest = require('sendRequest'); | 8 var sendRequest = require('sendRequest'); |
9 | 9 |
10 var getFileBindingsForApi = | 10 var getFileBindingsForApi = |
(...skipping 24 matching lines...) Expand all Loading... |
35 }); | 35 }); |
36 | 36 |
37 apiFunctions.setHandleRequest('retainEntry', function(fileEntry) { | 37 apiFunctions.setHandleRequest('retainEntry', function(fileEntry) { |
38 var id = entryIdManager.getEntryId(fileEntry); | 38 var id = entryIdManager.getEntryId(fileEntry); |
39 if (!id) | 39 if (!id) |
40 return ''; | 40 return ''; |
41 var fileSystemName = fileEntry.filesystem.name; | 41 var fileSystemName = fileEntry.filesystem.name; |
42 var relativePath = $String.slice(fileEntry.fullPath, 1); | 42 var relativePath = $String.slice(fileEntry.fullPath, 1); |
43 | 43 |
44 sendRequest.sendRequest(this.name, [id, fileSystemName, relativePath], | 44 sendRequest.sendRequest(this.name, [id, fileSystemName, relativePath], |
45 this.definition.parameters, {}); | 45 this.definition.parameters); |
46 return id; | 46 return id; |
47 }); | 47 }); |
48 | 48 |
49 apiFunctions.setHandleRequest('isRestorable', | 49 apiFunctions.setHandleRequest('isRestorable', |
50 function(id, callback) { | 50 function(id, callback) { |
51 var savedEntry = entryIdManager.getEntryById(id); | 51 var savedEntry = entryIdManager.getEntryById(id); |
52 if (savedEntry) { | 52 if (savedEntry) { |
53 sendRequest.safeCallbackApply( | 53 sendRequest.safeCallbackApply( |
54 'fileSystem.isRestorable', | 54 'fileSystem.isRestorable', |
55 {}, | 55 {}, |
56 callback, | 56 callback, |
57 [true]); | 57 [true]); |
58 } else { | 58 } else { |
59 sendRequest.sendRequest( | 59 sendRequest.sendRequest( |
60 this.name, [id, callback], this.definition.parameters, {}); | 60 this.name, [id, callback], this.definition.parameters); |
61 } | 61 } |
62 }); | 62 }); |
63 | 63 |
64 apiFunctions.setUpdateArgumentsPostValidate('restoreEntry', | 64 apiFunctions.setUpdateArgumentsPostValidate('restoreEntry', |
65 function(id, callback) { | 65 function(id, callback) { |
66 var savedEntry = entryIdManager.getEntryById(id); | 66 var savedEntry = entryIdManager.getEntryById(id); |
67 if (savedEntry) { | 67 if (savedEntry) { |
68 // We already have a file entry for this id so pass it to the callback and | 68 // We already have a file entry for this id so pass it to the callback and |
69 // send a request to the browser to move it to the back of the LRU. | 69 // send a request to the browser to move it to the back of the LRU. |
70 sendRequest.safeCallbackApply( | 70 sendRequest.safeCallbackApply( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 fileSystem.chooseFile = function() { | 110 fileSystem.chooseFile = function() { |
111 console.log("chrome.fileSystem.chooseFile is deprecated"); | 111 console.log("chrome.fileSystem.chooseFile is deprecated"); |
112 console.log("Please use chrome.fileSystem.chooseEntry instead"); | 112 console.log("Please use chrome.fileSystem.chooseEntry instead"); |
113 $Function.apply(fileSystem.chooseEntry, this, arguments); | 113 $Function.apply(fileSystem.chooseEntry, this, arguments); |
114 }; | 114 }; |
115 }); | 115 }); |
116 | 116 |
117 exports.$set('bindFileEntryCallback', bindFileEntryCallback); | 117 exports.$set('bindFileEntryCallback', bindFileEntryCallback); |
118 exports.$set('binding', binding.generate()); | 118 exports.$set('binding', binding.generate()); |
OLD | NEW |