| 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 binding for the fileBrowserPrivate API. | 5 // Custom binding for the fileManagerPrivate API. |
| 6 | 6 |
| 7 // Bindings | 7 // Bindings |
| 8 var binding = require('binding').Binding.create('fileBrowserPrivate'); | 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 fileBrowserPrivateNatives = requireNative('file_browser_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 fileBrowserPrivateInternal = | 16 var fileManagerPrivateInternal = |
| 17 require('binding').Binding.create('fileBrowserPrivateInternal').generate(); | 17 require('binding').Binding.create('fileManagerPrivateInternal').generate(); |
| 18 | 18 |
| 19 // Shorthands | 19 // Shorthands |
| 20 var GetFileSystem = fileBrowserPrivateNatives.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', | 26 apiFunctions.setCustomCallback('requestFileSystem', |
| 27 function(name, request, response) { | 27 function(name, request, response) { |
| 28 var fs = null; | 28 var fs = null; |
| 29 if (response && !response.error) | 29 if (response && !response.error) |
| 30 fs = GetFileSystem(response.name, response.root_url); | 30 fs = GetFileSystem(response.name, response.root_url); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 if (request.callback) | 66 if (request.callback) |
| 67 request.callback(response); | 67 request.callback(response); |
| 68 request.callback = null; | 68 request.callback = null; |
| 69 }); | 69 }); |
| 70 | 70 |
| 71 apiFunctions.setHandleRequest('resolveIsolatedEntries', | 71 apiFunctions.setHandleRequest('resolveIsolatedEntries', |
| 72 function(entries, callback) { | 72 function(entries, callback) { |
| 73 var urls = entries.map(function(entry) { | 73 var urls = entries.map(function(entry) { |
| 74 return fileBrowserHandlerNatives.GetEntryURL(entry); | 74 return fileBrowserHandlerNatives.GetEntryURL(entry); |
| 75 }); | 75 }); |
| 76 fileBrowserPrivateInternal.resolveIsolatedEntries(urls, function( | 76 fileManagerPrivateInternal.resolveIsolatedEntries(urls, function( |
| 77 entryDescriptions) { | 77 entryDescriptions) { |
| 78 callback(entryDescriptions.map(function(description) { | 78 callback(entryDescriptions.map(function(description) { |
| 79 return GetExternalFileEntry(description); | 79 return GetExternalFileEntry(description); |
| 80 })); | 80 })); |
| 81 }); | 81 }); |
| 82 }); | 82 }); |
| 83 }); | 83 }); |
| 84 | 84 |
| 85 eventBindings.registerArgumentMassager( | 85 eventBindings.registerArgumentMassager( |
| 86 'fileBrowserPrivate.onDirectoryChanged', function(args, dispatch) { | 86 'fileManagerPrivate.onDirectoryChanged', function(args, dispatch) { |
| 87 // Convert the entry arguments into a real Entry object. | 87 // Convert the entry arguments into a real Entry object. |
| 88 args[0].entry = GetExternalFileEntry(args[0].entry); | 88 args[0].entry = GetExternalFileEntry(args[0].entry); |
| 89 dispatch(args); | 89 dispatch(args); |
| 90 }); | 90 }); |
| 91 | 91 |
| 92 exports.binding = binding.generate(); | 92 exports.binding = binding.generate(); |
| OLD | NEW |