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