| 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 bindings for the fileSystem API. | 5 // Custom bindings for the fileSystem API. |
| 6 | 6 |
| 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 7 var Bindings = require('schema_binding_generator').Bindings; |
| 8 var bindings = new Bindings('fileSystem'); |
| 9 |
| 8 var fileSystemNatives = requireNative('file_system_natives'); | 10 var fileSystemNatives = requireNative('file_system_natives'); |
| 9 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; | 11 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; |
| 10 var lastError = require('lastError'); | 12 var lastError = require('lastError'); |
| 11 var entryIdManager = require('entryIdManager'); | 13 var entryIdManager = require('entryIdManager'); |
| 12 | 14 |
| 13 chromeHidden.registerCustomHook('fileSystem', function(bindingsAPI) { | 15 bindings.registerCustomHook(function(bindingsAPI) { |
| 14 var apiFunctions = bindingsAPI.apiFunctions; | 16 var apiFunctions = bindingsAPI.apiFunctions; |
| 17 var fileSystem = bindingsAPI.compiledApi; |
| 18 |
| 15 function bindFileEntryFunction(functionName) { | 19 function bindFileEntryFunction(functionName) { |
| 16 apiFunctions.setUpdateArgumentsPostValidate( | 20 apiFunctions.setUpdateArgumentsPostValidate( |
| 17 functionName, function(fileEntry, callback) { | 21 functionName, function(fileEntry, callback) { |
| 18 var fileSystemName = fileEntry.filesystem.name; | 22 var fileSystemName = fileEntry.filesystem.name; |
| 19 var relativePath = fileEntry.fullPath.slice(1); | 23 var relativePath = fileEntry.fullPath.slice(1); |
| 20 return [fileSystemName, relativePath, callback]; | 24 return [fileSystemName, relativePath, callback]; |
| 21 }); | 25 }); |
| 22 } | 26 } |
| 23 ['getDisplayPath', 'getWritableEntry', 'isWritableEntry'] | 27 ['getDisplayPath', 'getWritableEntry', 'isWritableEntry'] |
| 24 .forEach(bindFileEntryFunction); | 28 .forEach(bindFileEntryFunction); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 62 |
| 59 apiFunctions.setHandleRequest('getEntryId', function(fileEntry) { | 63 apiFunctions.setHandleRequest('getEntryId', function(fileEntry) { |
| 60 return entryIdManager.getEntryId(fileEntry); | 64 return entryIdManager.getEntryId(fileEntry); |
| 61 }); | 65 }); |
| 62 | 66 |
| 63 apiFunctions.setHandleRequest('getEntryById', function(id) { | 67 apiFunctions.setHandleRequest('getEntryById', function(id) { |
| 64 return entryIdManager.getEntryById(id); | 68 return entryIdManager.getEntryById(id); |
| 65 }); | 69 }); |
| 66 | 70 |
| 67 // TODO(benwells): Remove these deprecated versions of the functions. | 71 // TODO(benwells): Remove these deprecated versions of the functions. |
| 68 chrome.fileSystem.getWritableFileEntry = function() { | 72 fileSystem.getWritableFileEntry = function() { |
| 69 console.log("chrome.fileSystem.getWritableFileEntry is deprecated"); | 73 console.log("chrome.fileSystem.getWritableFileEntry is deprecated"); |
| 70 console.log("Please use chrome.fileSystem.getWritableEntry instead"); | 74 console.log("Please use chrome.fileSystem.getWritableEntry instead"); |
| 71 chrome.fileSystem.getWritableEntry.apply(this, arguments); | 75 fileSystem.getWritableEntry.apply(this, arguments); |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 chrome.fileSystem.isWritableFileEntry = function() { | 78 fileSystem.isWritableFileEntry = function() { |
| 75 console.log("chrome.fileSystem.isWritableFileEntry is deprecated"); | 79 console.log("chrome.fileSystem.isWritableFileEntry is deprecated"); |
| 76 console.log("Please use chrome.fileSystem.isWritableEntry instead"); | 80 console.log("Please use chrome.fileSystem.isWritableEntry instead"); |
| 77 chrome.fileSystem.isWritableEntry.apply(this, arguments); | 81 fileSystem.isWritableEntry.apply(this, arguments); |
| 78 }; | 82 }; |
| 79 | 83 |
| 80 chrome.fileSystem.chooseFile = function() { | 84 fileSystem.chooseFile = function() { |
| 81 console.log("chrome.fileSystem.chooseFile is deprecated"); | 85 console.log("chrome.fileSystem.chooseFile is deprecated"); |
| 82 console.log("Please use chrome.fileSystem.chooseEntry instead"); | 86 console.log("Please use chrome.fileSystem.chooseEntry instead"); |
| 83 chrome.fileSystem.chooseEntry.apply(this, arguments); | 87 fileSystem.chooseEntry.apply(this, arguments); |
| 84 }; | 88 }; |
| 85 }); | 89 }); |
| 90 |
| 91 exports.bindings = bindings.generate(); |
| OLD | NEW |