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
...@@ -35,7 +35,7 @@ using file_manager::util::EntryDefinitionList; ...@@ -35,7 +35,7 @@ using file_manager::util::EntryDefinitionList;
using file_manager::util::EntryDefinitionListCallback; using file_manager::util::EntryDefinitionListCallback;
using file_manager::util::FileDefinition; using file_manager::util::FileDefinition;
using file_manager::util::FileDefinitionList; using file_manager::util::FileDefinitionList;
using extensions::api::file_browser_private::DriveEntryProperties; using extensions::api::file_browser_private::EntryProperties;
namespace extensions { namespace extensions {
namespace { namespace {
...@@ -54,9 +54,9 @@ const char kDriveConnectionReasonNoService[] = "no_service"; ...@@ -54,9 +54,9 @@ const char kDriveConnectionReasonNoService[] = "no_service";
// Copies properties from |entry_proto| to |properties|. |shared_with_me| is // Copies properties from |entry_proto| to |properties|. |shared_with_me| is
// given from the running profile. // given from the running profile.
void FillDriveEntryPropertiesValue(const drive::ResourceEntry& entry_proto, void FillEntryPropertiesValue(const drive::ResourceEntry& entry_proto,
bool shared_with_me, bool shared_with_me,
DriveEntryProperties* properties) { EntryProperties* properties) {
properties->shared_with_me.reset(new bool(shared_with_me)); properties->shared_with_me.reset(new bool(shared_with_me));
properties->shared.reset(new bool(entry_proto.shared())); properties->shared.reset(new bool(entry_proto.shared()));
...@@ -145,55 +145,52 @@ void ConvertSearchResultInfoListToEntryDefinitionList( ...@@ -145,55 +145,52 @@ void ConvertSearchResultInfoListToEntryDefinitionList(
callback); callback);
} }
class SingleDriveEntryPropertiesGetter { class SingleEntryPropertiesGetterForDrive {
public: public:
typedef base::Callback<void(drive::FileError error)> ResultCallback; typedef base::Callback<void(scoped_ptr<EntryProperties> properties,
base::File::Error error)> ResultCallback;
// Creates an instance and starts the process. // Creates an instance and starts the process.
static void Start(const base::FilePath local_path, static void Start(const base::FilePath local_path,
linked_ptr<DriveEntryProperties> properties,
Profile* const profile, Profile* const profile,
const ResultCallback& callback) { const ResultCallback& callback) {
SingleEntryPropertiesGetterForDrive* instance =
SingleDriveEntryPropertiesGetter* instance = new SingleEntryPropertiesGetterForDrive(local_path, profile, callback);
new SingleDriveEntryPropertiesGetter(
local_path, properties, profile, callback);
instance->StartProcess(); instance->StartProcess();
// The instance will be destroyed by itself. // The instance will be destroyed by itself.
} }
virtual ~SingleDriveEntryPropertiesGetter() {} virtual ~SingleEntryPropertiesGetterForDrive() {}
private: private:
// Given parameters. // Given parameters.
const ResultCallback callback_; const ResultCallback callback_;
const base::FilePath local_path_; const base::FilePath local_path_;
const linked_ptr<DriveEntryProperties> properties_;
Profile* const running_profile_; Profile* const running_profile_;
// Values used in the process. // Values used in the process.
scoped_ptr<EntryProperties> properties_;
Profile* file_owner_profile_; Profile* file_owner_profile_;
base::FilePath file_path_; base::FilePath file_path_;
scoped_ptr<drive::ResourceEntry> owner_resource_entry_; scoped_ptr<drive::ResourceEntry> owner_resource_entry_;
base::WeakPtrFactory<SingleDriveEntryPropertiesGetter> weak_ptr_factory_; base::WeakPtrFactory<SingleEntryPropertiesGetterForDrive> weak_ptr_factory_;
SingleDriveEntryPropertiesGetter(const base::FilePath local_path, SingleEntryPropertiesGetterForDrive(const base::FilePath local_path,
linked_ptr<DriveEntryProperties> properties,
Profile* const profile, Profile* const profile,
const ResultCallback& callback) const ResultCallback& callback)
: callback_(callback), : callback_(callback),
local_path_(local_path), local_path_(local_path),
properties_(properties),
running_profile_(profile), running_profile_(profile),
properties_(new EntryProperties),
file_owner_profile_(NULL), file_owner_profile_(NULL),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
DCHECK(!callback_.is_null()); DCHECK(!callback_.is_null());
DCHECK(profile); DCHECK(profile);
} }
base::WeakPtr<SingleDriveEntryPropertiesGetter> GetWeakPtr() { base::WeakPtr<SingleEntryPropertiesGetterForDrive> GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr(); return weak_ptr_factory_.GetWeakPtr();
} }
...@@ -206,7 +203,7 @@ class SingleDriveEntryPropertiesGetter { ...@@ -206,7 +203,7 @@ class SingleDriveEntryPropertiesGetter {
if (!file_owner_profile_ || if (!file_owner_profile_ ||
!g_browser_process->profile_manager()->IsValidProfile( !g_browser_process->profile_manager()->IsValidProfile(
file_owner_profile_)) { file_owner_profile_)) {
CompleteGetFileProperties(drive::FILE_ERROR_FAILED); CompleteGetEntryProperties(drive::FILE_ERROR_FAILED);
return; return;
} }
...@@ -215,13 +212,13 @@ class SingleDriveEntryPropertiesGetter { ...@@ -215,13 +212,13 @@ class SingleDriveEntryPropertiesGetter {
drive::util::GetFileSystemByProfile(file_owner_profile_); drive::util::GetFileSystemByProfile(file_owner_profile_);
if (!file_system) { if (!file_system) {
// |file_system| is NULL if Drive is disabled or not mounted. // |file_system| is NULL if Drive is disabled or not mounted.
CompleteGetFileProperties(drive::FILE_ERROR_FAILED); CompleteGetEntryProperties(drive::FILE_ERROR_FAILED);
return; return;
} }
file_system->GetResourceEntry( file_system->GetResourceEntry(
file_path_, file_path_,
base::Bind(&SingleDriveEntryPropertiesGetter::OnGetFileInfo, base::Bind(&SingleEntryPropertiesGetterForDrive::OnGetFileInfo,
GetWeakPtr())); GetWeakPtr()));
} }
...@@ -230,7 +227,7 @@ class SingleDriveEntryPropertiesGetter { ...@@ -230,7 +227,7 @@ class SingleDriveEntryPropertiesGetter {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (error != drive::FILE_ERROR_OK) { if (error != drive::FILE_ERROR_OK) {
CompleteGetFileProperties(error); CompleteGetEntryProperties(error);
return; return;
} }
...@@ -247,12 +244,12 @@ class SingleDriveEntryPropertiesGetter { ...@@ -247,12 +244,12 @@ class SingleDriveEntryPropertiesGetter {
drive::FileSystemInterface* const file_system = drive::FileSystemInterface* const file_system =
drive::util::GetFileSystemByProfile(running_profile_); drive::util::GetFileSystemByProfile(running_profile_);
if (!file_system) { if (!file_system) {
CompleteGetFileProperties(drive::FILE_ERROR_FAILED); CompleteGetEntryProperties(drive::FILE_ERROR_FAILED);
return; return;
} }
file_system->GetPathFromResourceId( file_system->GetPathFromResourceId(
owner_resource_entry_->resource_id(), owner_resource_entry_->resource_id(),
base::Bind(&SingleDriveEntryPropertiesGetter::OnGetRunningPath, base::Bind(&SingleEntryPropertiesGetterForDrive::OnGetRunningPath,
GetWeakPtr())); GetWeakPtr()));
} }
...@@ -276,7 +273,7 @@ class SingleDriveEntryPropertiesGetter { ...@@ -276,7 +273,7 @@ class SingleDriveEntryPropertiesGetter {
file_system->GetResourceEntry( file_system->GetResourceEntry(
file_path, file_path,
base::Bind(&SingleDriveEntryPropertiesGetter::OnGetShareInfo, base::Bind(&SingleEntryPropertiesGetterForDrive::OnGetShareInfo,
GetWeakPtr())); GetWeakPtr()));
} }
...@@ -285,7 +282,7 @@ class SingleDriveEntryPropertiesGetter { ...@@ -285,7 +282,7 @@ class SingleDriveEntryPropertiesGetter {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (error != drive::FILE_ERROR_OK) { if (error != drive::FILE_ERROR_OK) {
CompleteGetFileProperties(error); CompleteGetEntryProperties(error);
return; return;
} }
...@@ -296,7 +293,7 @@ class SingleDriveEntryPropertiesGetter { ...@@ -296,7 +293,7 @@ class SingleDriveEntryPropertiesGetter {
void StartParseFileInfo(bool shared_with_me) { void StartParseFileInfo(bool shared_with_me) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
FillDriveEntryPropertiesValue( FillEntryPropertiesValue(
*owner_resource_entry_, shared_with_me, properties_.get()); *owner_resource_entry_, shared_with_me, properties_.get());
drive::FileSystemInterface* const file_system = drive::FileSystemInterface* const file_system =
...@@ -305,14 +302,14 @@ class SingleDriveEntryPropertiesGetter { ...@@ -305,14 +302,14 @@ class SingleDriveEntryPropertiesGetter {
drive::util::GetDriveAppRegistryByProfile(file_owner_profile_); drive::util::GetDriveAppRegistryByProfile(file_owner_profile_);
if (!file_system || !app_registry) { if (!file_system || !app_registry) {
// |file_system| or |app_registry| is NULL if Drive is disabled. // |file_system| or |app_registry| is NULL if Drive is disabled.
CompleteGetFileProperties(drive::FILE_ERROR_FAILED); CompleteGetEntryProperties(drive::FILE_ERROR_FAILED);
return; return;
} }
// The properties meaningful for directories are already filled in // The properties meaningful for directories are already filled in
// FillDriveEntryPropertiesValue(). // FillEntryPropertiesValue().
if (!owner_resource_entry_->has_file_specific_info()) { if (!owner_resource_entry_->has_file_specific_info()) {
CompleteGetFileProperties(drive::FILE_ERROR_OK); CompleteGetEntryProperties(drive::FILE_ERROR_OK);
return; return;
} }
...@@ -345,64 +342,85 @@ class SingleDriveEntryPropertiesGetter { ...@@ -345,64 +342,85 @@ class SingleDriveEntryPropertiesGetter {
} }
} }
CompleteGetFileProperties(drive::FILE_ERROR_OK); CompleteGetEntryProperties(drive::FILE_ERROR_OK);
} }
void CompleteGetFileProperties(drive::FileError error) { void CompleteGetEntryProperties(drive::FileError error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(!callback_.is_null()); DCHECK(!callback_.is_null());
callback_.Run(error);
callback_.Run(properties_.Pass(), drive::FileErrorToBaseFileError(error));
delete this; delete this;
} }
}; // class SingleDriveEntryPropertiesGetter }; // class SingleEntryPropertiesGetterForDrive
} // namespace } // namespace
FileBrowserPrivateGetDriveEntryPropertiesFunction:: FileBrowserPrivateGetEntryPropertiesFunction::
FileBrowserPrivateGetDriveEntryPropertiesFunction() FileBrowserPrivateGetEntryPropertiesFunction()
: processed_count_(0) {} : processed_count_(0) {
}
FileBrowserPrivateGetDriveEntryPropertiesFunction:: FileBrowserPrivateGetEntryPropertiesFunction::
~FileBrowserPrivateGetDriveEntryPropertiesFunction() {} ~FileBrowserPrivateGetEntryPropertiesFunction() {
}
bool FileBrowserPrivateGetDriveEntryPropertiesFunction::RunAsync() { bool FileBrowserPrivateGetEntryPropertiesFunction::RunAsync() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
using api::file_browser_private::GetDriveEntryProperties::Params; using api::file_browser_private::GetEntryProperties::Params;
const scoped_ptr<Params> params(Params::Create(*args_)); const scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params); EXTENSION_FUNCTION_VALIDATE(params);
properties_list_.resize(params->file_urls.size()); scoped_refptr<storage::FileSystemContext> file_system_context =
file_manager::util::GetFileSystemContextForRenderViewHost(
GetProfile(), render_view_host());
properties_list_.resize(params->file_urls.size());
for (size_t i = 0; i < params->file_urls.size(); i++) { for (size_t i = 0; i < params->file_urls.size(); i++) {
const GURL url = GURL(params->file_urls[i]); const GURL url = GURL(params->file_urls[i]);
const base::FilePath local_path = file_manager::util::GetLocalPathFromURL( const storage::FileSystemURL file_system_url =
render_view_host(), GetProfile(), url); file_system_context->CrackURL(url);
properties_list_[i] = make_linked_ptr(new DriveEntryProperties); switch (file_system_url.type()) {
case storage::kFileSystemTypeDrive:
SingleDriveEntryPropertiesGetter::Start( SingleEntryPropertiesGetterForDrive::Start(
local_path, file_system_url.path(),
properties_list_[i],
GetProfile(), GetProfile(),
base::Bind(&FileBrowserPrivateGetDriveEntryPropertiesFunction:: base::Bind(&FileBrowserPrivateGetEntryPropertiesFunction::
CompleteGetFileProperties, CompleteGetEntryProperties,
this)); this,
i));
break;
case storage::kFileSystemTypeProvided:
// TODO(mtomasz): Add support for provided file systems.
NOTIMPLEMENTED();
break;
default:
LOG(ERROR) << "Not supported file system type.";
CompleteGetEntryProperties(i,
make_scoped_ptr(new EntryProperties),
base::File::FILE_ERROR_INVALID_OPERATION);
}
} }
return true; return true;
} }
void FileBrowserPrivateGetDriveEntryPropertiesFunction:: void FileBrowserPrivateGetEntryPropertiesFunction::CompleteGetEntryProperties(
CompleteGetFileProperties(drive::FileError error) { size_t index,
scoped_ptr<EntryProperties> properties,
base::File::Error error) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK(0 <= processed_count_ && processed_count_ < properties_list_.size()); DCHECK(0 <= processed_count_ && processed_count_ < properties_list_.size());
properties_list_[index] = make_linked_ptr(properties.release());
processed_count_++; processed_count_++;
if (processed_count_ < properties_list_.size()) if (processed_count_ < properties_list_.size())
return; return;
results_ = extensions::api::file_browser_private::GetDriveEntryProperties:: results_ = extensions::api::file_browser_private::GetEntryProperties::
Results::Create(properties_list_); Results::Create(properties_list_);
SendResponse(true); SendResponse(true);
} }
......
...@@ -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