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

Side by Side Diff: chrome/renderer/resources/extensions/file_manager_private_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 fileManagerPrivate API. 5 // Custom binding for the fileManagerPrivate API.
6 6
7 // Bindings 7 // Bindings
8 var binding = require('binding').Binding.create('fileManagerPrivate'); 8 var binding = require('binding').Binding.create('fileManagerPrivate');
9 var eventBindings = require('event_bindings'); 9 var eventBindings = require('event_bindings');
10 10
11 // Natives 11 // Natives
12 var fileManagerPrivateNatives = requireNative('file_manager_private'); 12 var fileManagerPrivateNatives = requireNative('file_manager_private');
13 var fileBrowserHandlerNatives = requireNative('file_browser_handler'); 13 var fileBrowserHandlerNatives = requireNative('file_browser_handler');
14 14
15 // Internals 15 // Internals
16 var fileManagerPrivateInternal = 16 var fileManagerPrivateInternal =
17 require('binding').Binding.create('fileManagerPrivateInternal').generate(); 17 require('binding').Binding.create('fileManagerPrivateInternal').generate();
18 18
19 // Shorthands 19 // Shorthands
20 var GetFileSystem = fileManagerPrivateNatives.GetFileSystem; 20 var GetFileSystem = fileManagerPrivateNatives.GetFileSystem;
21 var GetExternalFileEntry = fileBrowserHandlerNatives.GetExternalFileEntry; 21 var GetExternalFileEntry = fileBrowserHandlerNatives.GetExternalFileEntry;
22 22
23 binding.registerCustomHook(function(bindingsAPI) { 23 binding.registerCustomHook(function(bindingsAPI) {
24 var apiFunctions = bindingsAPI.apiFunctions; 24 var apiFunctions = bindingsAPI.apiFunctions;
25 25
26 apiFunctions.setCustomCallback('requestFileSystem',
27 function(name, request, callback, response) {
28 var fs = null;
29 if (response && !response.error)
30 fs = GetFileSystem(response.name, response.root_url);
31 if (callback)
32 callback(fs);
33 });
34
35 apiFunctions.setCustomCallback('searchDrive', 26 apiFunctions.setCustomCallback('searchDrive',
36 function(name, request, callback, response) { 27 function(name, request, callback, response) {
37 if (response && !response.error && response.entries) { 28 if (response && !response.error && response.entries) {
38 response.entries = response.entries.map(function(entry) { 29 response.entries = response.entries.map(function(entry) {
39 return GetExternalFileEntry(entry); 30 return GetExternalFileEntry(entry);
40 }); 31 });
41 } 32 }
42 33
43 // So |callback| doesn't break if response is not defined. 34 // So |callback| doesn't break if response is not defined.
44 if (!response) 35 if (!response)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 }); 71 });
81 72
82 eventBindings.registerArgumentMassager( 73 eventBindings.registerArgumentMassager(
83 'fileManagerPrivate.onDirectoryChanged', function(args, dispatch) { 74 'fileManagerPrivate.onDirectoryChanged', function(args, dispatch) {
84 // Convert the entry arguments into a real Entry object. 75 // Convert the entry arguments into a real Entry object.
85 args[0].entry = GetExternalFileEntry(args[0].entry); 76 args[0].entry = GetExternalFileEntry(args[0].entry);
86 dispatch(args); 77 dispatch(args);
87 }); 78 });
88 79
89 exports.binding = binding.generate(); 80 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698