Commit 95dc7bfd authored by mtomasz's avatar mtomasz Committed by Commit bot

[fsp] Generalize fileBrowserPrivate.getEntryProperties().

This patch makes the method providing additional metadata for entries available
for provided file systems too.

NOTRY=True
TEST=Tested manually. Files app works as before.
BUG=408017

Review URL: https://codereview.chromium.org/515033002

Cr-Commit-Position: refs/heads/master@{#292851}
parent af2ddaa0
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_DRIVE_H_
#include "base/files/file.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/chromeos/drive/file_errors.h" #include "chrome/browser/chromeos/drive/file_errors.h"
#include "chrome/browser/chromeos/drive/file_system_interface.h" #include "chrome/browser/chromeos/drive/file_system_interface.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
...@@ -26,32 +28,35 @@ namespace extensions { ...@@ -26,32 +28,35 @@ namespace extensions {
namespace api { namespace api {
namespace file_browser_private { namespace file_browser_private {
struct DriveEntryProperties; struct EntryProperties;
} // namespace file_browser_private } // namespace file_browser_private
} // namespace api } // namespace api
// Retrieves property information for an entry and returns it as a dictionary. // Retrieves property information for an entry and returns it as a dictionary.
// On error, returns a dictionary with the key "error" set to the error number // On error, returns a dictionary with the key "error" set to the error number
// (drive::FileError). // (base::File::Error).
class FileBrowserPrivateGetDriveEntryPropertiesFunction class FileBrowserPrivateGetEntryPropertiesFunction
: public LoggedAsyncExtensionFunction { : public LoggedAsyncExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getDriveEntryProperties", DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getEntryProperties",
FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES) FILEBROWSERPRIVATE_GETENTRYPROPERTIES)
FileBrowserPrivateGetDriveEntryPropertiesFunction(); FileBrowserPrivateGetEntryPropertiesFunction();
protected: protected:
virtual ~FileBrowserPrivateGetDriveEntryPropertiesFunction(); virtual ~FileBrowserPrivateGetEntryPropertiesFunction();
// AsyncExtensionFunction overrides. // AsyncExtensionFunction overrides.
virtual bool RunAsync() OVERRIDE; virtual bool RunAsync() OVERRIDE;
private: private:
void CompleteGetFileProperties(drive::FileError error); void CompleteGetEntryProperties(
size_t index,
scoped_ptr<api::file_browser_private::EntryProperties> properties,
base::File::Error error);
size_t processed_count_; size_t processed_count_;
std::vector<linked_ptr<api::file_browser_private::DriveEntryProperties> > std::vector<linked_ptr<api::file_browser_private::EntryProperties> >
properties_list_; properties_list_;
}; };
......
...@@ -173,8 +173,8 @@ dictionary FileTask { ...@@ -173,8 +173,8 @@ dictionary FileTask {
boolean isDefault; boolean isDefault;
}; };
// Drive file properties. // Additional entry properties.
dictionary DriveEntryProperties { dictionary EntryProperties {
// Size of this file. // Size of this file.
double? fileSize; double? fileSize;
...@@ -477,12 +477,13 @@ callback AddFileWatchCallback = void(optional boolean success); ...@@ -477,12 +477,13 @@ callback AddFileWatchCallback = void(optional boolean success);
callback RemoveFileWatchCallback = void(optional boolean success); callback RemoveFileWatchCallback = void(optional boolean success);
// |fileSystem| A DOMFileSystem instance for local file system access. null if // |fileSystem| A DOMFileSystem instance for local file system access. null if
// |the caller has no appropriate permissions. // the caller has no appropriate permissions.
callback RequestFileSystemCallback = void(optional object fileSystem); callback RequestFileSystemCallback = void(optional object fileSystem);
// |fileProperties| A dictionary containing properties of the requested entries. // |entryProperties| A dictionary containing properties of the requested
callback GetDriveEntryPropertiesCallback = // entries.
void(DriveEntryProperties[] entryProperties); callback GetEntryPropertiesCallback =
void(EntryProperties[] entryProperties);
// |localFilePaths| An array of the local file paths for the requested files, // |localFilePaths| An array of the local file paths for the requested files,
// one entry for each file in fileUrls. // one entry for each file in fileUrls.
...@@ -628,12 +629,12 @@ interface Functions { ...@@ -628,12 +629,12 @@ interface Functions {
boolean shouldReturnLocalPath, boolean shouldReturnLocalPath,
SimpleCallback callback); SimpleCallback callback);
// Requests Drive file properties for files. // Requests additional properties for files.
// |fileUrls| list of URLs of files // |fileUrls| list of URLs of files
// |callback| // |callback|
static void getDriveEntryProperties( static void getEntryProperties(
DOMString[] fileUrls, DOMString[] fileUrls,
GetDriveEntryPropertiesCallback callback); GetEntryPropertiesCallback callback);
// Pins/unpins a Drive file in the cache. // Pins/unpins a Drive file in the cache.
// |fileUrl| URL of a file to pin/unpin. // |fileUrl| URL of a file to pin/unpin.
......
...@@ -135,7 +135,7 @@ enum HistogramValue { ...@@ -135,7 +135,7 @@ enum HistogramValue {
DELETED_FILEBROWSERPRIVATE_CLEARDRIVECACHE, DELETED_FILEBROWSERPRIVATE_CLEARDRIVECACHE,
SERIAL_GETCONTROLSIGNALS, SERIAL_GETCONTROLSIGNALS,
DEVELOPERPRIVATE_ENABLE, DEVELOPERPRIVATE_ENABLE,
FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES, FILEBROWSERPRIVATE_GETENTRYPROPERTIES,
USB_FINDDEVICES, USB_FINDDEVICES,
BOOKMARKMANAGERPRIVATE_DROP, BOOKMARKMANAGERPRIVATE_DROP,
DELETED_FILEBROWSERPRIVATE_GETFILETRANSFERS, DELETED_FILEBROWSERPRIVATE_GETFILETRANSFERS,
......
...@@ -40356,7 +40356,7 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -40356,7 +40356,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="74" label="DELETED_FILEBROWSERPRIVATE_CLEARDRIVECACHE"/> <int value="74" label="DELETED_FILEBROWSERPRIVATE_CLEARDRIVECACHE"/>
<int value="75" label="SERIAL_GETCONTROLSIGNALS"/> <int value="75" label="SERIAL_GETCONTROLSIGNALS"/>
<int value="76" label="DEVELOPERPRIVATE_ENABLE"/> <int value="76" label="DEVELOPERPRIVATE_ENABLE"/>
<int value="77" label="FILEBROWSERPRIVATE_GETDRIVEFILEPROPERTIES"/> <int value="77" label="FILEBROWSERPRIVATE_GETENTRYPROPERTIES"/>
<int value="78" label="USB_FINDDEVICES"/> <int value="78" label="USB_FINDDEVICES"/>
<int value="79" label="BOOKMARKMANAGERPRIVATE_DROP"/> <int value="79" label="BOOKMARKMANAGERPRIVATE_DROP"/>
<int value="80" label="DELETED_FILEBROWSERPRIVATE_GETFILETRANSFERS"/> <int value="80" label="DELETED_FILEBROWSERPRIVATE_GETFILETRANSFERS"/>
...@@ -263,7 +263,7 @@ FileTransferController.prototype = { ...@@ -263,7 +263,7 @@ FileTransferController.prototype = {
var processFileEntries = function(entries) { var processFileEntries = function(entries) {
return new Promise(function(callback) { return new Promise(function(callback) {
var urls = util.entriesToURLs(entries); var urls = util.entriesToURLs(entries);
chrome.fileBrowserPrivate.getDriveEntryProperties(urls, callback); chrome.fileBrowserPrivate.getEntryProperties(urls, callback);
}). }).
then(function(metadatas) { then(function(metadatas) {
return entries.filter(function(entry, i) { return entries.filter(function(entry, i) {
......
...@@ -838,9 +838,9 @@ DriveProvider.prototype.callApi_ = function() { ...@@ -838,9 +838,9 @@ DriveProvider.prototype.callApi_ = function() {
this.callbacks_ = []; this.callbacks_ = [];
var self = this; var self = this;
// TODO(mtomasz): Make getDriveEntryProperties accept Entry instead of URL. // TODO(mtomasz): Make getEntryProperties accept Entry instead of URL.
var entryURLs = util.entriesToURLs(entries); var entryURLs = util.entriesToURLs(entries);
chrome.fileBrowserPrivate.getDriveEntryProperties( chrome.fileBrowserPrivate.getEntryProperties(
entryURLs, entryURLs,
function(propertiesList) { function(propertiesList) {
console.assert(propertiesList.length === callbacks.length); console.assert(propertiesList.length === callbacks.length);
......
...@@ -105,7 +105,7 @@ MediaManager.prototype.getMime = function() { ...@@ -105,7 +105,7 @@ MediaManager.prototype.getMime = function() {
return Promise.resolve(this.cachedDriveProp_.thumbnailUrl); return Promise.resolve(this.cachedDriveProp_.thumbnailUrl);
return new Promise(function(fulfill, reject) { return new Promise(function(fulfill, reject) {
chrome.fileBrowserPrivate.getDriveEntryProperties( chrome.fileBrowserPrivate.getEntryProperties(
[this.entry_.toURL()], fulfill); [this.entry_.toURL()], fulfill);
}.bind(this)).then(function(props) { }.bind(this)).then(function(props) {
if (!props || !props[0] || !props[0].contentMimeType) { if (!props || !props[0] || !props[0].contentMimeType) {
...@@ -128,7 +128,7 @@ MediaManager.prototype.getThumbnail = function() { ...@@ -128,7 +128,7 @@ MediaManager.prototype.getThumbnail = function() {
return Promise.resolve(this.cachedDriveProp_.thumbnailUrl); return Promise.resolve(this.cachedDriveProp_.thumbnailUrl);
return new Promise(function(fulfill, reject) { return new Promise(function(fulfill, reject) {
chrome.fileBrowserPrivate.getDriveEntryProperties( chrome.fileBrowserPrivate.getEntryProperties(
[this.entry_.toURL()], fulfill); [this.entry_.toURL()], fulfill);
}.bind(this)).then(function(props) { }.bind(this)).then(function(props) {
if (!props || !props[0] || !props[0].thumbnailUrl) { if (!props || !props[0] || !props[0].thumbnailUrl) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment