Commit 38e0b7d8 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Add support for retrieving thumbnails and download URLs from DriveFS.

Bug: 844292
Change-Id: I6555d4f18f09d7a010553c620da891d5e67cff66
Reviewed-on: https://chromium-review.googlesource.com/1077115Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Sam McNally <sammc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#563112}
parent e0a41b84
......@@ -16,6 +16,7 @@
#include "base/files/file.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h"
#include "chromeos/components/drivefs/mojom/drivefs.mojom.h"
#include "components/drive/chromeos/file_system_interface.h"
#include "components/drive/file_errors.h"
......@@ -98,7 +99,11 @@ class FileManagerPrivateInternalPinDriveFileFunction
bool RunAsync() override;
private:
// Callback for RunAsync().
bool RunAsyncForDrive(const GURL& url, bool pin);
bool RunAsyncForDriveFs(const storage::FileSystemURL& file_system_url,
bool pin);
// Callback for RunAsyncForDrive() and RunAsyncForDriveFs.
void OnPinStateSet(drive::FileError error);
};
......@@ -268,14 +273,23 @@ class FileManagerPrivateInternalGetDownloadUrlFunction
// ChromeAsyncExtensionFunction overrides.
bool RunAsync() override;
private:
bool RunAsyncForDrive(const GURL& url);
void OnGetResourceEntry(drive::FileError error,
std::unique_ptr<drive::ResourceEntry> entry);
void OnGotDownloadUrl(GURL download_url);
// Callback with an |access_token|, called by
// drive::DriveReadonlyTokenFetcher.
void OnTokenFetched(google_apis::DriveApiErrorCode code,
const std::string& access_token);
bool RunAsyncForDriveFs(const storage::FileSystemURL& file_system_url);
void OnGotMetadata(drive::FileError error,
drivefs::mojom::FileMetadataPtr metadata);
private:
GURL download_url_;
std::unique_ptr<google_apis::AuthService> auth_service_;
......
......@@ -193,7 +193,7 @@ bool OpenFileWithBrowser(Profile* profile,
integration_service->GetDriveFsInterface() &&
integration_service->GetMountPointPath().IsParent(file_path)) {
integration_service->GetDriveFsInterface()->GetMetadata(
file_path,
file_path, false,
base::BindOnce(&OpenHostedDriveFsFile, file_path, profile));
return true;
}
......
......@@ -20,8 +20,10 @@ interface DriveFsBootstrap {
// Implemented by DriveFS, used from Chrome.
interface DriveFs {
// Returns the metadata for |path|.
GetMetadata(mojo_base.mojom.FilePath path) => (
// Returns the metadata for |path|. Thumbnail requests may require requesting
// a thumbnail from the server so thumbnails are only populated for requests
// where |want_thumbnail| is true.
GetMetadata(mojo_base.mojom.FilePath path, bool want_thumbnail) => (
FileError error, FileMetadata? metadata);
// Sets the file at |path| to pinned or unpinned depending on the value of
......@@ -90,6 +92,9 @@ struct FileMetadata {
// A URL to open the file in the Drive website.
string alternate_url;
// A URL to download the file.
string download_url;
mojo_base.mojom.Time modification_time;
mojo_base.mojom.Time modification_by_me_time;
......@@ -102,6 +107,10 @@ struct FileMetadata {
// May be present if the file is an image.
ImageMetadata? image_metadata;
// 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;
};
struct ImageMetadata {
......
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