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