| 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 | 8 |
| 9 var fileSystemNatives = requireNative('file_system_natives'); | 9 var fileSystemNatives = requireNative('file_system_natives'); |
| 10 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; | 10 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 binding.registerCustomHook(function(bindingsAPI) { | 71 binding.registerCustomHook(function(bindingsAPI) { |
| 72 var apiFunctions = bindingsAPI.apiFunctions; | 72 var apiFunctions = bindingsAPI.apiFunctions; |
| 73 var fileSystem = bindingsAPI.compiledApi; | 73 var fileSystem = bindingsAPI.compiledApi; |
| 74 | 74 |
| 75 function bindFileEntryFunction(functionName) { | 75 function bindFileEntryFunction(functionName) { |
| 76 apiFunctions.setUpdateArgumentsPostValidate( | 76 apiFunctions.setUpdateArgumentsPostValidate( |
| 77 functionName, function(fileEntry, callback) { | 77 functionName, function(fileEntry, callback) { |
| 78 var fileSystemName = fileEntry.filesystem.name; | 78 var fileSystemName = fileEntry.filesystem.name; |
| 79 var relativePath = fileEntry.fullPath.slice(1); | 79 var relativePath = $String.slice(fileEntry.fullPath, 1); |
| 80 return [fileSystemName, relativePath, callback]; | 80 return [fileSystemName, relativePath, callback]; |
| 81 }); | 81 }); |
| 82 } | 82 } |
| 83 $Array.forEach(['getDisplayPath', 'getWritableEntry', 'isWritableEntry'], | 83 $Array.forEach(['getDisplayPath', 'getWritableEntry', 'isWritableEntry'], |
| 84 bindFileEntryFunction); | 84 bindFileEntryFunction); |
| 85 | 85 |
| 86 $Array.forEach(['getWritableEntry', 'chooseEntry', 'restoreEntry'], | 86 $Array.forEach(['getWritableEntry', 'chooseEntry', 'restoreEntry'], |
| 87 function(functionName) { | 87 function(functionName) { |
| 88 bindFileEntryCallback(functionName, apiFunctions); | 88 bindFileEntryCallback(functionName, apiFunctions); |
| 89 }); | 89 }); |
| 90 | 90 |
| 91 apiFunctions.setHandleRequest('retainEntry', function(fileEntry) { | 91 apiFunctions.setHandleRequest('retainEntry', function(fileEntry) { |
| 92 var id = entryIdManager.getEntryId(fileEntry); | 92 var id = entryIdManager.getEntryId(fileEntry); |
| 93 if (!id) | 93 if (!id) |
| 94 return ''; | 94 return ''; |
| 95 var fileSystemName = fileEntry.filesystem.name; | 95 var fileSystemName = fileEntry.filesystem.name; |
| 96 var relativePath = fileEntry.fullPath.slice(1); | 96 var relativePath = $String.slice(fileEntry.fullPath, 1); |
| 97 | 97 |
| 98 sendRequest(this.name, [id, fileSystemName, relativePath], | 98 sendRequest(this.name, [id, fileSystemName, relativePath], |
| 99 this.definition.parameters, {}); | 99 this.definition.parameters, {}); |
| 100 return id; | 100 return id; |
| 101 }); | 101 }); |
| 102 | 102 |
| 103 apiFunctions.setHandleRequest('isRestorable', | 103 apiFunctions.setHandleRequest('isRestorable', |
| 104 function(id, callback) { | 104 function(id, callback) { |
| 105 var savedEntry = entryIdManager.getEntryById(id); | 105 var savedEntry = entryIdManager.getEntryById(id); |
| 106 if (savedEntry) { | 106 if (savedEntry) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 122 // Ask the browser process for a new file entry for this id, to be passed | 122 // Ask the browser process for a new file entry for this id, to be passed |
| 123 // to |callback|. | 123 // to |callback|. |
| 124 return [id, true, callback]; | 124 return [id, true, callback]; |
| 125 } | 125 } |
| 126 }); | 126 }); |
| 127 | 127 |
| 128 // TODO(benwells): Remove these deprecated versions of the functions. | 128 // TODO(benwells): Remove these deprecated versions of the functions. |
| 129 fileSystem.getWritableFileEntry = function() { | 129 fileSystem.getWritableFileEntry = function() { |
| 130 console.log("chrome.fileSystem.getWritableFileEntry is deprecated"); | 130 console.log("chrome.fileSystem.getWritableFileEntry is deprecated"); |
| 131 console.log("Please use chrome.fileSystem.getWritableEntry instead"); | 131 console.log("Please use chrome.fileSystem.getWritableEntry instead"); |
| 132 fileSystem.getWritableEntry.apply(this, arguments); | 132 $Function.apply(fileSystem.getWritableEntry, this, arguments); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 fileSystem.isWritableFileEntry = function() { | 135 fileSystem.isWritableFileEntry = function() { |
| 136 console.log("chrome.fileSystem.isWritableFileEntry is deprecated"); | 136 console.log("chrome.fileSystem.isWritableFileEntry is deprecated"); |
| 137 console.log("Please use chrome.fileSystem.isWritableEntry instead"); | 137 console.log("Please use chrome.fileSystem.isWritableEntry instead"); |
| 138 fileSystem.isWritableEntry.apply(this, arguments); | 138 $Function.apply(fileSystem.isWritableEntry, this, arguments); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 fileSystem.chooseFile = function() { | 141 fileSystem.chooseFile = function() { |
| 142 console.log("chrome.fileSystem.chooseFile is deprecated"); | 142 console.log("chrome.fileSystem.chooseFile is deprecated"); |
| 143 console.log("Please use chrome.fileSystem.chooseEntry instead"); | 143 console.log("Please use chrome.fileSystem.chooseEntry instead"); |
| 144 fileSystem.chooseEntry.apply(this, arguments); | 144 $Function.apply(fileSystem.chooseEntry, this, arguments); |
| 145 }; | 145 }; |
| 146 }); | 146 }); |
| 147 | 147 |
| 148 exports.bindFileEntryCallback = bindFileEntryCallback; | 148 exports.bindFileEntryCallback = bindFileEntryCallback; |
| 149 exports.binding = binding.generate(); | 149 exports.binding = binding.generate(); |
| OLD | NEW |