Index: components/drive/resource_entry_conversion.cc |
diff --git a/components/drive/resource_entry_conversion.cc b/components/drive/resource_entry_conversion.cc |
index 52eda29bffc8b0f0c4a9c826d707920a90129d48..f797cfa68f9c57d9615730d6422a368b3f930309 100644 |
--- a/components/drive/resource_entry_conversion.cc |
+++ b/components/drive/resource_entry_conversion.cc |
@@ -26,12 +26,16 @@ bool ConvertChangeResourceToResourceEntry( |
ResourceEntry converted; |
std::string parent_resource_id; |
- if (input.file() && |
- !ConvertFileResourceToResourceEntry(*input.file(), &converted, |
- &parent_resource_id)) |
+ if (input.type() == google_apis::ChangeResource::TEAM_DRIVE) { |
+ if (!ConvertTeamDriveChangeResourceToResourceEntry(input, &converted)) { |
return false; |
- |
- converted.set_resource_id(input.file_id()); |
+ } |
+ } else { |
+ if (input.file() && !ConvertFileResourceToResourceEntry( |
+ *input.file(), &converted, &parent_resource_id)) |
+ return false; |
+ converted.set_resource_id(input.file_id()); |
+ } |
converted.set_deleted(converted.deleted() || input.is_deleted()); |
converted.set_modification_date(input.modification_date().ToInternalValue()); |
@@ -128,6 +132,39 @@ bool ConvertFileResourceToResourceEntry( |
return true; |
} |
+bool ConvertTeamDriveResourceToResourceEntry( |
+ const google_apis::TeamDriveResource& input, |
+ ResourceEntry* out_entry) { |
+ DCHECK(out_entry); |
+ if (input.id().empty()) |
+ return false; |
+ out_entry->set_title(input.name()); |
+ out_entry->set_base_name(input.name()); |
+ out_entry->set_resource_id(input.id()); |
hashimoto
2017/04/11 07:55:14
set_resource_id() is called with input.team_drive_
yamaguchi
2017/04/11 10:11:41
Done.
This will be needed when we call this functi
|
+ return true; |
+} |
+ |
+bool ConvertTeamDriveChangeResourceToResourceEntry( |
hashimoto
2017/04/11 07:55:14
This code should be part of ConvertChangeResourceT
yamaguchi
2017/04/11 10:11:41
Done.
|
+ const google_apis::ChangeResource& input, |
+ ResourceEntry* out_entry) { |
+ DCHECK(out_entry); |
+ DCHECK_EQ(google_apis::ChangeResource::TEAM_DRIVE, input.type()); |
+ ResourceEntry converted; |
+ converted.mutable_file_info()->set_is_directory(true); |
+ converted.set_parent_local_id(util::kDriveTeamDrivesDirLocalId); |
+ if (input.team_drive()) |
+ if (!ConvertTeamDriveResourceToResourceEntry(*input.team_drive(), |
+ &converted)) |
+ return false; |
+ if (!input.team_drive_id().empty()) { |
hashimoto
2017/04/11 07:55:14
I don't think we need to do this check
yamaguchi
2017/04/11 10:11:41
Done.
|
+ converted.set_resource_id(input.team_drive_id()); |
+ } |
+ if (converted.resource_id().empty()) |
hashimoto
2017/04/11 07:55:14
and this (are you receiving Team Drive resource wi
yamaguchi
2017/04/11 10:11:41
Done.
|
+ return false; |
+ out_entry->Swap(&converted); |
+ return true; |
+} |
+ |
void ConvertResourceEntryToFileInfo(const ResourceEntry& entry, |
base::File::Info* file_info) { |
file_info->size = entry.file_info().size(); |