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

Side by Side Diff: chrome/browser/chromeos/gdata/drive_api_parser.cc

Issue 10828277: Get EntryKind from parsed FileResource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_api_parser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/gdata/drive_api_parser.h" 5 #include "chrome/browser/chromeos/gdata/drive_api_parser.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // https://developers.google.com/drive/v2/reference/changes 111 // https://developers.google.com/drive/v2/reference/changes
112 const char kChangeKind[] = "drive#change"; 112 const char kChangeKind[] = "drive#change";
113 const char kFileId[] = "fileId"; 113 const char kFileId[] = "fileId";
114 const char kDeleted[] = "deleted"; 114 const char kDeleted[] = "deleted";
115 const char kFile[] = "file"; 115 const char kFile[] = "file";
116 116
117 // Changes List 117 // Changes List
118 // https://developers.google.com/drive/v2/reference/changes/list 118 // https://developers.google.com/drive/v2/reference/changes/list
119 const char kChangeListKind[] = "drive#changeList"; 119 const char kChangeListKind[] = "drive#changeList";
120 120
121 // Google Apps MIME types:
122 const char kGoogleDocumentMimeType[] = "application/vnd.google-apps.document";
123 const char kGoogleDrawingMimeType[] = "application/vnd.google-apps.drawing";
124 const char kGoogleFormMimeType[] = "application/vnd.google-apps.form";
125 const char kGooglePresentationMimeType[] =
126 "application/vnd.google-apps.presentation";
127 const char kGoogleScriptMimeType[] = "application/vnd.google-apps.script";
128 const char kGoogleSiteMimeType[] = "application/vnd.google-apps.site";
129 const char kGoogleSpreadsheetMimeType[] =
130 "application/vnd.google-apps.spreadsheet";
131 const char kGoogleTableMimeType[] = "application/vnd.google-apps.table";
132
121 // Maps category name to enum IconCategory. 133 // Maps category name to enum IconCategory.
122 struct AppIconCategoryMap { 134 struct AppIconCategoryMap {
123 gdata::DriveAppIcon::IconCategory category; 135 gdata::DriveAppIcon::IconCategory category;
124 const char* category_name; 136 const char* category_name;
125 }; 137 };
126 138
127 const AppIconCategoryMap kAppIconCategoryMap[] = { 139 const AppIconCategoryMap kAppIconCategoryMap[] = {
128 { gdata::DriveAppIcon::DOCUMENT, "document" }, 140 { gdata::DriveAppIcon::DOCUMENT, "document" },
129 { gdata::DriveAppIcon::APPLICATION, "application" }, 141 { gdata::DriveAppIcon::APPLICATION, "application" },
130 { gdata::DriveAppIcon::SHARED_DOCUMENT, "documentShared" }, 142 { gdata::DriveAppIcon::SHARED_DOCUMENT, "documentShared" },
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 LOG(ERROR) << "Unable to create: Invalid FileResource JSON!"; 435 LOG(ERROR) << "Unable to create: Invalid FileResource JSON!";
424 return scoped_ptr<FileResource>(NULL); 436 return scoped_ptr<FileResource>(NULL);
425 } 437 }
426 return resource.Pass(); 438 return resource.Pass();
427 } 439 }
428 440
429 bool FileResource::IsDirectory() const { 441 bool FileResource::IsDirectory() const {
430 return mime_type_ == kDriveFolderMimeType; 442 return mime_type_ == kDriveFolderMimeType;
431 } 443 }
432 444
445 DocumentEntry::EntryKind FileResource::GetKind() const {
446 if (mime_type() == kGoogleDocumentMimeType)
447 return DocumentEntry::DOCUMENT;
448 if (mime_type() == kGoogleSpreadsheetMimeType)
449 return DocumentEntry::SPREADSHEET;
450 if (mime_type() == kGooglePresentationMimeType)
451 return DocumentEntry::PRESENTATION;
452 if (mime_type() == kGoogleDrawingMimeType)
453 return DocumentEntry::DRAWING;
454 if (mime_type() == kGoogleTableMimeType)
455 return DocumentEntry::TABLE;
456 if (mime_type() == kDriveFolderMimeType)
457 return DocumentEntry::FOLDER;
458 if (mime_type() == "application/pdf")
459 return DocumentEntry::PDF;
460 return DocumentEntry::FILE;
461 }
462
433 bool FileResource::Parse(const base::Value& value) { 463 bool FileResource::Parse(const base::Value& value) {
434 base::JSONValueConverter<FileResource> converter; 464 base::JSONValueConverter<FileResource> converter;
435 if (!converter.Convert(value, this)) { 465 if (!converter.Convert(value, this)) {
436 LOG(ERROR) << "Unable to parse: Invalid FileResource"; 466 LOG(ERROR) << "Unable to parse: Invalid FileResource";
437 return false; 467 return false;
438 } 468 }
439 return true; 469 return true;
440 } 470 }
441 471
442 //////////////////////////////////////////////////////////////////////////////// 472 ////////////////////////////////////////////////////////////////////////////////
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 bool ChangeList::Parse(const base::Value& value) { 582 bool ChangeList::Parse(const base::Value& value) {
553 base::JSONValueConverter<ChangeList> converter; 583 base::JSONValueConverter<ChangeList> converter;
554 if (!converter.Convert(value, this)) { 584 if (!converter.Convert(value, this)) {
555 LOG(ERROR) << "Unable to parse: Invalid ChangeList"; 585 LOG(ERROR) << "Unable to parse: Invalid ChangeList";
556 return false; 586 return false;
557 } 587 }
558 return true; 588 return true;
559 } 589 }
560 590
561 } // namespace gdata 591 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/drive_api_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698