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

Unified Diff: chrome/browser/drive/drive_api_util.cc

Issue 135643005: drive: Stop using DictionaryValue to store data in FakeDriveService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 11 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
« no previous file with comments | « no previous file | chrome/browser/drive/fake_drive_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/drive/drive_api_util.cc
diff --git a/chrome/browser/drive/drive_api_util.cc b/chrome/browser/drive/drive_api_util.cc
index 610f735afc8cb2c863c801d8cbd33e13386a055c..ef4d12812752ba942277685bfb3b8f437de636d6 100644
--- a/chrome/browser/drive/drive_api_util.cc
+++ b/chrome/browser/drive/drive_api_util.cc
@@ -39,6 +39,25 @@ const char kGoogleTableMimeType[] = "application/vnd.google-apps.table";
const char kGoogleFormMimeType[] = "application/vnd.google-apps.form";
const char kDriveFolderMimeType[] = "application/vnd.google-apps.folder";
+std::string GetMimeTypeFromEntryKind(google_apis::DriveEntryKind kind) {
+ switch (kind) {
+ case google_apis::ENTRY_KIND_DOCUMENT:
+ return kGoogleDocumentMimeType;
+ case google_apis::ENTRY_KIND_SPREADSHEET:
+ return kGoogleSpreadsheetMimeType;
+ case google_apis::ENTRY_KIND_PRESENTATION:
+ return kGooglePresentationMimeType;
+ case google_apis::ENTRY_KIND_DRAWING:
+ return kGoogleDrawingMimeType;
+ case google_apis::ENTRY_KIND_TABLE:
+ return kGoogleTableMimeType;
+ case google_apis::ENTRY_KIND_FORM:
+ return kGoogleFormMimeType;
+ default:
+ return std::string();
+ }
+}
+
ScopedVector<std::string> CopyScopedVectorString(
const ScopedVector<std::string>& source) {
ScopedVector<std::string> result;
@@ -323,10 +342,14 @@ scoped_ptr<google_apis::FileResource> ConvertResourceEntryToFileResource(
"shared") != entry.labels().end());
file->set_download_url(entry.download_url());
- if (entry.is_folder())
+ if (entry.is_folder()) {
file->set_mime_type(kDriveFolderMimeType);
- else
- file->set_mime_type(entry.content_mime_type());
+ } else {
+ std::string mime_type = GetMimeTypeFromEntryKind(entry.kind());
+ if (mime_type.empty())
+ mime_type = entry.content_mime_type();
+ file->set_mime_type(mime_type);
+ }
file->set_md5_checksum(entry.file_md5());
file->set_file_size(entry.file_size());
« no previous file with comments | « no previous file | chrome/browser/drive/fake_drive_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698