Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: chrome/renderer/resources/extensions/file_system_custom_bindings.js

Issue 10914284: Rename chrome.fileSystem apis to be expandable to directories if we wish. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
8 var fileSystemNatives = requireNative('file_system_natives'); 8 var fileSystemNatives = requireNative('file_system_natives');
9 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem; 9 var GetIsolatedFileSystem = fileSystemNatives.GetIsolatedFileSystem;
10 var lastError = require('lastError'); 10 var lastError = require('lastError');
11 11
12 chromeHidden.registerCustomHook('fileSystem', function(bindingsAPI) { 12 chromeHidden.registerCustomHook('fileSystem', function(bindingsAPI) {
13 var apiFunctions = bindingsAPI.apiFunctions; 13 var apiFunctions = bindingsAPI.apiFunctions;
14 function bindFileEntryFunction(functionName) { 14 function bindFileEntryFunction(functionName) {
15 apiFunctions.setUpdateArgumentsPostValidate( 15 apiFunctions.setUpdateArgumentsPostValidate(
16 functionName, function(fileEntry, callback) { 16 functionName, function(fileEntry, callback) {
17 var fileSystemName = fileEntry.filesystem.name; 17 var fileSystemName = fileEntry.filesystem.name;
18 var relativePath = fileEntry.fullPath.slice(1); 18 var relativePath = fileEntry.fullPath.slice(1);
19 return [fileSystemName, relativePath, callback]; 19 return [fileSystemName, relativePath, callback];
20 }); 20 });
21 } 21 }
22 ['getDisplayPath', 'getWritableFileEntry', 'isWritableFileEntry'] 22 ['getDisplayPath', 'getWritableEntry', 'isWritableEntry']
23 .forEach(bindFileEntryFunction); 23 .forEach(bindFileEntryFunction);
24 24
25 function bindFileEntryCallback(functionName) { 25 function bindFileEntryCallback(functionName) {
26 apiFunctions.setCustomCallback(functionName, 26 apiFunctions.setCustomCallback(functionName,
27 function(name, request, response) { 27 function(name, request, response) {
28 if (request.callback && response) { 28 if (request.callback && response) {
29 var callback = request.callback; 29 var callback = request.callback;
30 request.callback = null; 30 request.callback = null;
31 31
32 var fileSystemId = response.fileSystemId; 32 var fileSystemId = response.fileSystemId;
33 var baseName = response.baseName; 33 var baseName = response.baseName;
34 var fs = GetIsolatedFileSystem(fileSystemId); 34 var fs = GetIsolatedFileSystem(fileSystemId);
35 35
36 try { 36 try {
37 fs.root.getFile(baseName, {}, function(fileEntry) { 37 fs.root.getFile(baseName, {}, function(fileEntry) {
38 callback(fileEntry); 38 callback(fileEntry);
39 }, function(fileError) { 39 }, function(fileError) {
40 lastError.set('Error getting fileEntry, code: ' + fileError.code); 40 lastError.set('Error getting fileEntry, code: ' + fileError.code);
41 callback(); 41 callback();
42 }); 42 });
43 } catch (e) { 43 } catch (e) {
44 lastError.set('Error in event handler for onLaunched: ' + e.stack); 44 lastError.set('Error in event handler for onLaunched: ' + e.stack);
45 callback(); 45 callback();
46 } 46 }
47 } 47 }
48 }); 48 });
49 } 49 }
50 ['getWritableFileEntry', 'chooseFile'].forEach(bindFileEntryCallback); 50 ['getWritableEntry', 'chooseEntry'].forEach(bindFileEntryCallback);
51
52 // TODO(benwells): Remove these deprecated versions of the functions.
53 chrome.fileSystem.getWritableFileEntry = function() {
54 console.log("chrome.fileSystem.getWritableFileEntry is deprecated");
55 console.log("Please use chrome.fileSystem.getWritableEntry instead");
56 chrome.fileSystem.getWritableEntry.apply(this, arguments);
57 };
58
59 chrome.fileSystem.isWritableFileEntry = function() {
60 console.log("chrome.fileSystem.isWritableFileEntry is deprecated");
61 console.log("Please use chrome.fileSystem.isWritableEntry instead");
62 chrome.fileSystem.isWritableEntry.apply(this, arguments);
63 };
64
65 chrome.fileSystem.chooseFile = function() {
66 console.log("chrome.fileSystem.chooseFile is deprecated");
67 console.log("Please use chrome.fileSystem.chooseEntry instead");
68 chrome.fileSystem.chooseEntry.apply(this, arguments);
69 };
51 }); 70 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698