Commit 2ba73e87 authored by kochi@chromium.org's avatar kochi@chromium.org

Get EntryKind from parsed FileResource.

Returns DocumentEntry::EntryKind for corresponding MIME type of the
entry.

This CL is split off of https://chromiumcodereview.appspot.com/10837201/

BUG=chromium:127728
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10828277

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151425 0039d316-1c4b-4281-b951-d872f2087c98
parent 34146c18
......@@ -118,6 +118,18 @@ const char kFile[] = "file";
// https://developers.google.com/drive/v2/reference/changes/list
const char kChangeListKind[] = "drive#changeList";
// Google Apps MIME types:
const char kGoogleDocumentMimeType[] = "application/vnd.google-apps.document";
const char kGoogleDrawingMimeType[] = "application/vnd.google-apps.drawing";
const char kGoogleFormMimeType[] = "application/vnd.google-apps.form";
const char kGooglePresentationMimeType[] =
"application/vnd.google-apps.presentation";
const char kGoogleScriptMimeType[] = "application/vnd.google-apps.script";
const char kGoogleSiteMimeType[] = "application/vnd.google-apps.site";
const char kGoogleSpreadsheetMimeType[] =
"application/vnd.google-apps.spreadsheet";
const char kGoogleTableMimeType[] = "application/vnd.google-apps.table";
// Maps category name to enum IconCategory.
struct AppIconCategoryMap {
gdata::DriveAppIcon::IconCategory category;
......@@ -430,6 +442,24 @@ bool FileResource::IsDirectory() const {
return mime_type_ == kDriveFolderMimeType;
}
DocumentEntry::EntryKind FileResource::GetKind() const {
if (mime_type() == kGoogleDocumentMimeType)
return DocumentEntry::DOCUMENT;
if (mime_type() == kGoogleSpreadsheetMimeType)
return DocumentEntry::SPREADSHEET;
if (mime_type() == kGooglePresentationMimeType)
return DocumentEntry::PRESENTATION;
if (mime_type() == kGoogleDrawingMimeType)
return DocumentEntry::DRAWING;
if (mime_type() == kGoogleTableMimeType)
return DocumentEntry::TABLE;
if (mime_type() == kDriveFolderMimeType)
return DocumentEntry::FOLDER;
if (mime_type() == "application/pdf")
return DocumentEntry::PDF;
return DocumentEntry::FILE;
}
bool FileResource::Parse(const base::Value& value) {
base::JSONValueConverter<FileResource> converter;
if (!converter.Convert(value, this)) {
......
......@@ -15,6 +15,9 @@
#include "base/string_piece.h"
#include "base/time.h"
#include "googleurl/src/gurl.h"
// TODO(kochi): Eliminate this dependency once dependency to EntryKind is gone.
// http://crbug.com/142293
#include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h"
namespace base {
class Value;
......@@ -315,6 +318,11 @@ class FileResource {
// but outside this file we use "directory" to match HTML5 filesystem API.
bool IsDirectory() const;
// Returns EntryKind for this file.
// TODO(kochi): Remove this once FileResource is directly converted to proto.
// http://crbug.com/142293
DocumentEntry::EntryKind GetKind() const;
// Returns file ID. This is unique in all files in Google Drive.
const std::string& file_id() const { return file_id_; }
......
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