diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 11:09:52 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-05 11:09:52 +0000 |
commit | b0b3dbd9358e55e70a4592428c6dca07f76eccde (patch) | |
tree | 055d90c2581792b42eb7b8bd7f91b9a1a342dfad /google_apis | |
parent | 67a8f5a2310ebd4a6936a17632169d7660ebb3df (diff) | |
download | chromium_src-b0b3dbd9358e55e70a4592428c6dca07f76eccde.zip chromium_src-b0b3dbd9358e55e70a4592428c6dca07f76eccde.tar.gz chromium_src-b0b3dbd9358e55e70a4592428c6dca07f76eccde.tar.bz2 |
Parse 'shared' attribute in WAPI/DriveAPI.
In WAPI, a label "shared" is added to the category of an entry.
In Drive API, the File resources contain a boolean field "shared".
BUG=264812
Review URL: https://codereview.chromium.org/104193002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238936 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/drive/drive_api_parser.cc | 4 | ||||
-rw-r--r-- | google_apis/drive/drive_api_parser.h | 7 | ||||
-rw-r--r-- | google_apis/drive/drive_api_parser_unittest.cc | 6 |
3 files changed, 16 insertions, 1 deletions
diff --git a/google_apis/drive/drive_api_parser.cc b/google_apis/drive/drive_api_parser.cc index c3cb669..4b05e8b 100644 --- a/google_apis/drive/drive_api_parser.cc +++ b/google_apis/drive/drive_api_parser.cc @@ -140,6 +140,7 @@ const char kWebContentLink[] = "webContentLink"; const char kOpenWithLinks[] = "openWithLinks"; const char kLabels[] = "labels"; const char kImageMediaMetadata[] = "imageMediaMetadata"; +const char kShared[] = "shared"; // These 5 flags are defined under |labels|. const char kLabelStarred[] = "starred"; const char kLabelHidden[] = "hidden"; @@ -423,7 +424,7 @@ bool ParentReference::Parse(const base::Value& value) { //////////////////////////////////////////////////////////////////////////////// // FileResource implementation -FileResource::FileResource() : file_size_(0) {} +FileResource::FileResource() : shared_(false), file_size_(0) {} FileResource::~FileResource() {} @@ -460,6 +461,7 @@ void FileResource::RegisterJSONConverter( kSharedWithMeDate, &FileResource::shared_with_me_date_, &util::GetTimeFromString); + converter->RegisterBoolField(kShared, &FileResource::shared_); converter->RegisterCustomField<GURL>(kDownloadUrl, &FileResource::download_url_, GetGURLFromString); diff --git a/google_apis/drive/drive_api_parser.h b/google_apis/drive/drive_api_parser.h index 1f7ddb8..2ee230d 100644 --- a/google_apis/drive/drive_api_parser.h +++ b/google_apis/drive/drive_api_parser.h @@ -525,6 +525,9 @@ class FileResource { return shared_with_me_date_; } + // Returns the 'shared' attribute of the file. + bool shared() const { return shared_; } + // Returns the short-lived download URL for the file. This field exists // only when the file content is stored in Drive. const GURL& download_url() const { return download_url_; } @@ -596,6 +599,9 @@ class FileResource { void set_shared_with_me_date(const base::Time& shared_with_me_date) { shared_with_me_date_ = shared_with_me_date; } + void set_shared(bool shared) { + shared_ = shared; + } void set_download_url(const GURL& download_url) { download_url_ = download_url; } @@ -645,6 +651,7 @@ class FileResource { base::Time modified_by_me_date_; base::Time last_viewed_by_me_date_; base::Time shared_with_me_date_; + bool shared_; GURL download_url_; std::string file_extension_; std::string md5_checksum_; diff --git a/google_apis/drive/drive_api_parser_unittest.cc b/google_apis/drive/drive_api_parser_unittest.cc index 4aae844..0960b27 100644 --- a/google_apis/drive/drive_api_parser_unittest.cc +++ b/google_apis/drive/drive_api_parser_unittest.cc @@ -149,6 +149,7 @@ TEST(DriveAPIParserTest, FileListParser) { EXPECT_FALSE(file1.labels().is_trashed()); EXPECT_FALSE(file1.labels().is_restricted()); EXPECT_TRUE(file1.labels().is_viewed()); + EXPECT_FALSE(file1.shared()); EXPECT_EQ(640, file1.image_media_metadata().width()); EXPECT_EQ(480, file1.image_media_metadata().height()); @@ -201,6 +202,7 @@ TEST(DriveAPIParserTest, FileListParser) { EXPECT_TRUE(file2.labels().is_trashed()); EXPECT_TRUE(file2.labels().is_restricted()); EXPECT_TRUE(file2.labels().is_viewed()); + EXPECT_TRUE(file2.shared()); EXPECT_EQ(-1, file2.image_media_metadata().width()); EXPECT_EQ(-1, file2.image_media_metadata().height()); @@ -230,6 +232,7 @@ TEST(DriveAPIParserTest, FileListParser) { EXPECT_EQ("TestFolder", file3.title()); EXPECT_EQ("application/vnd.google-apps.folder", file3.mime_type()); ASSERT_TRUE(file3.IsDirectory()); + EXPECT_FALSE(file3.shared()); ASSERT_EQ(1U, file3.parents().size()); EXPECT_EQ("0AIv7G8yEYAWHUk9ABC", file3.parents()[0]->file_id()); @@ -262,18 +265,21 @@ TEST(DriveAPIParserTest, ChangeListParser) { EXPECT_FALSE(change1.is_deleted()); EXPECT_EQ("1Pc8jzfU1ErbN_eucMMqdqzY3eBm0v8sxXm_1CtLxABC", change1.file_id()); EXPECT_EQ(change1.file_id(), change1.file()->file_id()); + EXPECT_FALSE(change1.file()->shared()); const ChangeResource& change2 = *changelist->items()[1]; EXPECT_EQ(8424, change2.change_id()); EXPECT_FALSE(change2.is_deleted()); EXPECT_EQ("0B4v7G8yEYAWHUmRrU2lMS2hLABC", change2.file_id()); EXPECT_EQ(change2.file_id(), change2.file()->file_id()); + EXPECT_TRUE(change2.file()->shared()); const ChangeResource& change3 = *changelist->items()[2]; EXPECT_EQ(8429, change3.change_id()); EXPECT_FALSE(change3.is_deleted()); EXPECT_EQ("0B4v7G8yEYAWHYW1OcExsUVZLABC", change3.file_id()); EXPECT_EQ(change3.file_id(), change3.file()->file_id()); + EXPECT_FALSE(change3.file()->shared()); // Deleted entry. const ChangeResource& change4 = *changelist->items()[3]; |