Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Unified Diff: chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc

Issue 513683002: [fsp] Add support for providing thumbnails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc
diff --git a/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc b/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc
index 99a620b89c04de9ec0bd14ea90435237110c4743..e37875caddc5e959fdab243fb13b65c61ef97e90 100644
--- a/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc
+++ b/chrome/browser/chromeos/file_system_provider/operations/get_metadata.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h"
+#include <algorithm>
#include <string>
#include "chrome/common/extensions/api/file_system_provider.h"
@@ -29,9 +30,6 @@ bool ConvertRequestValueToFileInfo(scoped_ptr<RequestValue> value,
output->is_directory = params->metadata.is_directory;
output->size = static_cast<int64>(params->metadata.size);
- if (params->metadata.mime_type.get())
- output->mime_type = *params->metadata.mime_type.get();
-
std::string input_modification_time;
if (!params->metadata.modification_time.additional_properties.GetString(
"value", &input_modification_time)) {
@@ -43,6 +41,27 @@ bool ConvertRequestValueToFileInfo(scoped_ptr<RequestValue> value,
base::Time::FromString(input_modification_time.c_str(),
&output->modification_time);
+ if (params->metadata.mime_type.get())
+ output->mime_type = *params->metadata.mime_type.get();
+
+ if (params->metadata.thumbnail.get()) {
+ // Sanity check for the thumbnail format. Note, that another, more granural
+ // check is done in custom bindings. Note, this is an extra check only for
+ // the security reasons.
+ const std::string expected_prefix = "data:";
+ std::string thumbnail_prefix =
+ params->metadata.thumbnail.get()->substr(0, expected_prefix.size());
+ std::transform(thumbnail_prefix.begin(),
+ thumbnail_prefix.end(),
+ thumbnail_prefix.begin(),
+ ::tolower);
+
+ if (expected_prefix != thumbnail_prefix)
+ return false;
+
+ output->thumbnail = *params->metadata.thumbnail.get();
+ }
+
return true;
}
@@ -52,9 +71,11 @@ GetMetadata::GetMetadata(
extensions::EventRouter* event_router,
const ProvidedFileSystemInfo& file_system_info,
const base::FilePath& entry_path,
+ ProvidedFileSystemInterface::MetadataFieldMask fields,
const ProvidedFileSystemInterface::GetMetadataCallback& callback)
: Operation(event_router, file_system_info),
entry_path_(entry_path),
+ fields_(fields),
callback_(callback) {
}
@@ -64,6 +85,10 @@ GetMetadata::~GetMetadata() {
bool GetMetadata::Execute(int request_id) {
scoped_ptr<base::DictionaryValue> values(new base::DictionaryValue);
values->SetString("entryPath", entry_path_.AsUTF8Unsafe());
+ values->SetBoolean(
+ "thumbnail",
+ (fields_ & ProvidedFileSystemInterface::METADATA_FIELD_THUMBNAIL) != 0);
+
return SendEvent(
request_id,
extensions::api::file_system_provider::OnGetMetadataRequested::kEventName,

Powered by Google App Engine
This is Rietveld 408576698