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

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

Issue 985533004: Implement chrome.fileSystem.requestFileSystem(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed kiosk mode. Created 5 years, 9 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
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 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 =
11 require('fileEntryBindingUtil').getFileBindingsForApi; 11 require('fileEntryBindingUtil').getFileBindingsForApi;
12 var fileBindings = getFileBindingsForApi('fileSystem'); 12 var fileBindings = getFileBindingsForApi('fileSystem');
13 var bindFileEntryCallback = fileBindings.bindFileEntryCallback; 13 var bindFileEntryCallback = fileBindings.bindFileEntryCallback;
14 var entryIdManager = fileBindings.entryIdManager; 14 var entryIdManager = fileBindings.entryIdManager;
15 var fileSystemNatives = requireNative('file_system_natives');
15 16
16 binding.registerCustomHook(function(bindingsAPI) { 17 binding.registerCustomHook(function(bindingsAPI) {
17 var apiFunctions = bindingsAPI.apiFunctions; 18 var apiFunctions = bindingsAPI.apiFunctions;
18 var fileSystem = bindingsAPI.compiledApi; 19 var fileSystem = bindingsAPI.compiledApi;
19 20
20 function bindFileEntryFunction(functionName) { 21 function bindFileEntryFunction(functionName) {
21 apiFunctions.setUpdateArgumentsPostValidate( 22 apiFunctions.setUpdateArgumentsPostValidate(
22 functionName, function(fileEntry, callback) { 23 functionName, function(fileEntry, callback) {
23 var fileSystemName = fileEntry.filesystem.name; 24 var fileSystemName = fileEntry.filesystem.name;
24 var relativePath = $String.slice(fileEntry.fullPath, 1); 25 var relativePath = $String.slice(fileEntry.fullPath, 1);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 callback, 73 callback,
73 [savedEntry]); 74 [savedEntry]);
74 return [id, false, null]; 75 return [id, false, null];
75 } else { 76 } else {
76 // Ask the browser process for a new file entry for this id, to be passed 77 // Ask the browser process for a new file entry for this id, to be passed
77 // to |callback|. 78 // to |callback|.
78 return [id, true, callback]; 79 return [id, true, callback];
79 } 80 }
80 }); 81 });
81 82
83 apiFunctions.setCustomCallback('requestFileSystem',
84 function(name, request, callback, response) {
85 var fileSystem = null;
86 if (response && response.file_system_id) {
87 fileSystem = fileSystemNatives.GetIsolatedFileSystem(
88 response.file_system_id, response.file_system_path);
89 }
90 sendRequest.safeCallbackApply(
91 'fileSystem.requestFileSystem',
92 request,
93 callback,
94 [fileSystem]);
95 });
96
82 // TODO(benwells): Remove these deprecated versions of the functions. 97 // TODO(benwells): Remove these deprecated versions of the functions.
83 fileSystem.getWritableFileEntry = function() { 98 fileSystem.getWritableFileEntry = function() {
84 console.log("chrome.fileSystem.getWritableFileEntry is deprecated"); 99 console.log("chrome.fileSystem.getWritableFileEntry is deprecated");
85 console.log("Please use chrome.fileSystem.getWritableEntry instead"); 100 console.log("Please use chrome.fileSystem.getWritableEntry instead");
86 $Function.apply(fileSystem.getWritableEntry, this, arguments); 101 $Function.apply(fileSystem.getWritableEntry, this, arguments);
87 }; 102 };
88 103
89 fileSystem.isWritableFileEntry = function() { 104 fileSystem.isWritableFileEntry = function() {
90 console.log("chrome.fileSystem.isWritableFileEntry is deprecated"); 105 console.log("chrome.fileSystem.isWritableFileEntry is deprecated");
91 console.log("Please use chrome.fileSystem.isWritableEntry instead"); 106 console.log("Please use chrome.fileSystem.isWritableEntry instead");
92 $Function.apply(fileSystem.isWritableEntry, this, arguments); 107 $Function.apply(fileSystem.isWritableEntry, this, arguments);
93 }; 108 };
94 109
95 fileSystem.chooseFile = function() { 110 fileSystem.chooseFile = function() {
96 console.log("chrome.fileSystem.chooseFile is deprecated"); 111 console.log("chrome.fileSystem.chooseFile is deprecated");
97 console.log("Please use chrome.fileSystem.chooseEntry instead"); 112 console.log("Please use chrome.fileSystem.chooseEntry instead");
98 $Function.apply(fileSystem.chooseEntry, this, arguments); 113 $Function.apply(fileSystem.chooseEntry, this, arguments);
99 }; 114 };
100 }); 115 });
101 116
102 exports.bindFileEntryCallback = bindFileEntryCallback; 117 exports.bindFileEntryCallback = bindFileEntryCallback;
103 exports.binding = binding.generate(); 118 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698