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

Unified Diff: chrome/browser/chromeos/drive/resource_metadata.cc

Issue 66293005: drive: Add drive/trash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix RemoveEntry Created 7 years, 1 month 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/drive/resource_metadata.cc
diff --git a/chrome/browser/chromeos/drive/resource_metadata.cc b/chrome/browser/chromeos/drive/resource_metadata.cc
index 89e8064c05fdd351fcbfea938c0a9fc8cba9bba1..1fd95dc98a82944dfa10e12e8f142b68839c2a8b 100644
--- a/chrome/browser/chromeos/drive/resource_metadata.cc
+++ b/chrome/browser/chromeos/drive/resource_metadata.cc
@@ -114,7 +114,7 @@ ResourceMetadata::~ResourceMetadata() {
bool ResourceMetadata::SetUpDefaultEntries() {
DCHECK(blocking_task_runner_->RunsTasksOnCurrentThread());
- // Initialize the grand root and "other" entries. "/drive" and "/drive/other".
+ // Initialize "/drive", "/drive/other" and "drive/trash".
ResourceEntry entry;
if (!storage_->GetEntry(util::kDriveGrandRootLocalId, &entry)) {
ResourceEntry root;
@@ -138,6 +138,15 @@ bool ResourceMetadata::SetUpDefaultEntries() {
if (!PutEntryUnderDirectory(other_dir))
return false;
}
+ if (!storage_->GetEntry(util::kDriveTrashDirLocalId, &entry)) {
+ ResourceEntry trash_dir;
+ trash_dir.mutable_file_info()->set_is_directory(true);
+ trash_dir.set_local_id(util::kDriveTrashDirLocalId);
+ trash_dir.set_parent_local_id(util::kDriveGrandRootLocalId);
+ trash_dir.set_title(util::kDriveTrashDirName);
+ if (!PutEntryUnderDirectory(trash_dir))
+ return false;
+ }
return true;
}
@@ -202,8 +211,10 @@ FileError ResourceMetadata::RemoveEntry(const std::string& id) {
if (!EnoughDiskSpaceIsAvailableForDBOperation(storage_->directory_path()))
return FILE_ERROR_NO_LOCAL_SPACE;
- // Disallow deletion of special entries "/drive" and "/drive/other".
- if (util::IsSpecialResourceId(id))
+ // Disallow deletion of default entries.
+ if (id == util::kDriveGrandRootLocalId ||
+ id == util::kDriveOtherDirLocalId ||
+ id == util::kDriveTrashDirLocalId)
return FILE_ERROR_ACCESS_DENIED;
ResourceEntry entry;
« no previous file with comments | « chrome/browser/chromeos/drive/file_system_util.h ('k') | chrome/browser/chromeos/drive/resource_metadata_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698