Commit 44798b14 authored by Naoki Fukino's avatar Naoki Fukino Committed by Commit Bot

Filter recent files from Drive by specified file_type.

We can filter recent files from RecentDriveSource by specifying mime
type to the query for DriveFS.

Bug: 1040049
Test: Manually tested by checking result from Google Drive.
Change-Id: I798965c0544a35daf94e73d54bde4516646f8d1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1993065
Commit-Queue: Naoki Fukino <fukino@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733574}
parent 5030c330
...@@ -30,6 +30,10 @@ namespace chromeos { ...@@ -30,6 +30,10 @@ namespace chromeos {
const char RecentDriveSource::kLoadHistogramName[] = const char RecentDriveSource::kLoadHistogramName[] =
"FileBrowser.Recent.LoadDrive"; "FileBrowser.Recent.LoadDrive";
const char kAudioMimeType[] = "audio";
const char kImageMimeType[] = "image";
const char kVideoMimeType[] = "video";
RecentDriveSource::RecentDriveSource(Profile* profile) : profile_(profile) { RecentDriveSource::RecentDriveSource(Profile* profile) : profile_(profile) {
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
} }
...@@ -64,6 +68,20 @@ void RecentDriveSource::GetRecentFiles(Params params) { ...@@ -64,6 +68,20 @@ void RecentDriveSource::GetRecentFiles(Params params) {
drivefs::mojom::QueryParameters::SortField::kLastModified; drivefs::mojom::QueryParameters::SortField::kLastModified;
query_params->sort_direction = query_params->sort_direction =
drivefs::mojom::QueryParameters::SortDirection::kDescending; drivefs::mojom::QueryParameters::SortDirection::kDescending;
switch (params_->file_type()) {
case FileType::kAudio:
query_params->mime_type = kAudioMimeType;
break;
case FileType::kImage:
query_params->mime_type = kImageMimeType;
break;
case FileType::kVideo:
query_params->mime_type = kVideoMimeType;
break;
default:
// Leave the mime_type null to query all files.
break;
}
integration_service->GetDriveFsInterface()->StartSearchQuery( integration_service->GetDriveFsInterface()->StartSearchQuery(
search_query_.BindNewPipeAndPassReceiver(), std::move(query_params)); search_query_.BindNewPipeAndPassReceiver(), std::move(query_params));
search_query_->GetNextPage(base::BindOnce( search_query_->GetNextPage(base::BindOnce(
......
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