Commit 5ad3b5eb authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Forward Drive capabilities from DriveFS.

Bug: 844292
Change-Id: I89b008ab1483aee6c5d619435e0e082d463fc2b3
Reviewed-on: https://chromium-review.googlesource.com/1107424
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarSasha Morrissey <sashab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569158}
parent 0c13198a
......@@ -676,11 +676,12 @@ class SingleEntryPropertiesGetterForDriveFs {
std::make_unique<bool>(metadata->available_offline);
properties_->present = std::make_unique<bool>(metadata->available_offline);
properties_->dirty = std::make_unique<bool>(metadata->dirty);
properties_->hosted = std::make_unique<bool>(metadata->hosted);
properties_->present =
std::make_unique<bool>(metadata->available_offline || metadata->hosted);
properties_->available_when_metered =
std::make_unique<bool>(metadata->available_offline || metadata->hosted);
properties_->hosted = std::make_unique<bool>(
metadata->type == drivefs::mojom::FileMetadata::Type::kHosted);
properties_->present = std::make_unique<bool>(metadata->available_offline ||
*properties_->hosted);
properties_->available_when_metered = std::make_unique<bool>(
metadata->available_offline || *properties_->hosted);
properties_->pinned = std::make_unique<bool>(metadata->pinned);
properties_->shared = std::make_unique<bool>(metadata->shared);
properties_->starred = std::make_unique<bool>(metadata->starred);
......@@ -721,6 +722,21 @@ class SingleEntryPropertiesGetterForDriveFs {
std::make_unique<int32_t>(metadata->image_metadata->rotation);
}
}
properties_->can_delete =
std::make_unique<bool>(metadata->capabilities->can_delete);
properties_->can_rename =
std::make_unique<bool>(metadata->capabilities->can_rename);
properties_->can_add_children =
std::make_unique<bool>(metadata->capabilities->can_add_children);
// Only set the |can_copy| capability for hosted documents; for other files,
// we must have read access, so |can_copy| is implicitly true.
properties_->can_copy = std::make_unique<bool>(
!*properties_->hosted || metadata->capabilities->can_copy);
properties_->can_share =
std::make_unique<bool>(metadata->capabilities->can_share);
if (metadata->thumbnail) {
base::PostTaskAndReplyWithResult(
FROM_HERE,
......
......@@ -143,7 +143,7 @@ void OpenHostedDriveFsFile(const base::FilePath& file_path,
drivefs::mojom::FileMetadataPtr metadata) {
if (error != drive::FILE_ERROR_OK)
return;
if (!metadata->hosted) {
if (metadata->type != drivefs::mojom::FileMetadata::Type::kHosted) {
OpenGDocUrlFromFile(file_path, profile);
return;
}
......
......@@ -153,10 +153,14 @@ void FakeDriveFs::GetMetadata(const base::FilePath& path,
metadata->pinned = stored_metadata.pinned;
metadata->content_mime_type = stored_metadata.mime_type;
metadata->hosted = stored_metadata.hosted;
metadata->type = stored_metadata.hosted
? mojom::FileMetadata::Type::kHosted
: info.is_directory
? mojom::FileMetadata::Type::kDirectory
: mojom::FileMetadata::Type::kFile;
base::StringPiece prefix;
if (metadata->hosted) {
if (stored_metadata.hosted) {
prefix = "https://document_alternate_link/";
} else if (info.is_directory) {
prefix = "https://folder_alternate_link/";
......@@ -167,6 +171,7 @@ void FakeDriveFs::GetMetadata(const base::FilePath& path,
? path.BaseName().value()
: stored_metadata.original_name;
metadata->alternate_url = GURL(base::StrCat({prefix, suffix})).spec();
metadata->capabilities = mojom::Capabilities::New();
std::move(callback).Run(drive::FILE_ERROR_OK, std::move(metadata));
}
......
......@@ -85,6 +85,18 @@ enum FileError {
};
struct FileMetadata {
enum Type {
// A regular file.
kFile,
// A hosted document (e.g. a gdoc).
kHosted,
// A directory.
kDirectory,
};
Type type;
int64 size;
string content_mime_type;
......@@ -102,7 +114,6 @@ struct FileMetadata {
bool available_offline;
bool dirty;
bool hosted;
bool pinned;
bool shared;
bool starred;
......@@ -113,6 +124,8 @@ struct FileMetadata {
// The thumbnail as a PNG. It is only set if |want_thumbnail| is true in the
// request and the file has a thumbnail available.
array<uint8>? thumbnail;
Capabilities capabilities;
};
struct ImageMetadata {
......@@ -124,6 +137,15 @@ struct ImageMetadata {
int32 rotation = 0;
};
// Drive capabilities:
struct Capabilities {
bool can_share = true;
bool can_copy = true;
bool can_delete = true;
bool can_rename = true;
bool can_add_children = true;
};
struct ItemEvent {
enum State {
kQueued,
......
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