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

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

Issue 10837201: Pass parsed ChangeList to GDataFileSystem. (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
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"
11 #include "base/json/json_value_converter.h" 11 #include "base/json/json_value_converter.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/string_piece.h" 14 #include "base/string_piece.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "chrome/browser/chromeos/gdata/gdata_util.h" 17 #include "chrome/browser/chromeos/gdata/gdata_util.h"
18 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h"
18 19
19 using base::Value; 20 using base::Value;
20 using base::DictionaryValue; 21 using base::DictionaryValue;
21 using base::ListValue; 22 using base::ListValue;
22 23
23 namespace { 24 namespace {
24 25
25 // Converts |url_string| to |result|. Always returns true to be used 26 // Converts |url_string| to |result|. Always returns true to be used
26 // for JSONValueConverter::RegisterCustomField method. 27 // for JSONValueConverter::RegisterCustomField method.
27 // TODO(mukai): make it return false in case of invalid |url_string|. 28 // TODO(mukai): make it return false in case of invalid |url_string|.
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // https://developers.google.com/drive/v2/reference/changes 112 // https://developers.google.com/drive/v2/reference/changes
112 const char kChangeKind[] = "drive#change"; 113 const char kChangeKind[] = "drive#change";
113 const char kFileId[] = "fileId"; 114 const char kFileId[] = "fileId";
114 const char kDeleted[] = "deleted"; 115 const char kDeleted[] = "deleted";
115 const char kFile[] = "file"; 116 const char kFile[] = "file";
116 117
117 // Changes List 118 // Changes List
118 // https://developers.google.com/drive/v2/reference/changes/list 119 // https://developers.google.com/drive/v2/reference/changes/list
119 const char kChangeListKind[] = "drive#changeList"; 120 const char kChangeListKind[] = "drive#changeList";
120 121
122 // Google Apps MIME types:
123 const char kGoogleDocumentMimeType[] = "application/vnd.google-apps.document";
124 const char kGoogleDrawingMimeType[] = "application/vnd.google-apps.drawing";
125 const char kGoogleFormMimeType[] = "application/vnd.google-apps.form";
126 const char kGooglePresentationMimeType[] =
127 "application/vnd.google-apps.presentation";
128 const char kGoogleScriptMimeType[] = "application/vnd.google-apps.script";
129 const char kGoogleSiteMimeType[] = "application/vnd.google-apps.site";
130 const char kGoogleSpreadsheetMimeType[] =
131 "application/vnd.google-apps.spreadsheet";
132 const char kGoogleTableMimeType[] = "application/vnd.google-apps.table";
133
121 // Maps category name to enum IconCategory. 134 // Maps category name to enum IconCategory.
122 struct AppIconCategoryMap { 135 struct AppIconCategoryMap {
123 gdata::DriveAppIcon::IconCategory category; 136 gdata::DriveAppIcon::IconCategory category;
124 const char* category_name; 137 const char* category_name;
125 }; 138 };
126 139
127 const AppIconCategoryMap kAppIconCategoryMap[] = { 140 const AppIconCategoryMap kAppIconCategoryMap[] = {
128 { gdata::DriveAppIcon::DOCUMENT, "document" }, 141 { gdata::DriveAppIcon::DOCUMENT, "document" },
129 { gdata::DriveAppIcon::APPLICATION, "application" }, 142 { gdata::DriveAppIcon::APPLICATION, "application" },
130 { gdata::DriveAppIcon::SHARED_DOCUMENT, "documentShared" }, 143 { 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!"; 436 LOG(ERROR) << "Unable to create: Invalid FileResource JSON!";
424 return scoped_ptr<FileResource>(NULL); 437 return scoped_ptr<FileResource>(NULL);
425 } 438 }
426 return resource.Pass(); 439 return resource.Pass();
427 } 440 }
428 441
429 bool FileResource::IsDirectory() const { 442 bool FileResource::IsDirectory() const {
430 return mime_type_ == kDriveFolderMimeType; 443 return mime_type_ == kDriveFolderMimeType;
431 } 444 }
432 445
446 DocumentEntry::EntryKind FileResource::GetKind() const {
447 if (mime_type() == kGoogleDocumentMimeType)
448 return DocumentEntry::DOCUMENT;
449 if (mime_type() == kGoogleSpreadsheetMimeType)
450 return DocumentEntry::SPREADSHEET;
451 if (mime_type() == kGooglePresentationMimeType)
452 return DocumentEntry::PRESENTATION;
453 if (mime_type() == kGoogleDrawingMimeType)
454 return DocumentEntry::DRAWING;
455 if (mime_type() == kGoogleTableMimeType)
456 return DocumentEntry::TABLE;
457 if (mime_type() == kDriveFolderMimeType)
458 return DocumentEntry::FOLDER;
459 if (mime_type() == "application/pdf")
460 return DocumentEntry::PDF;
461 return DocumentEntry::FILE;
satorux1 2012/08/10 18:14:34 I think the changes in drive_api_parser.h/cc can b
kochi 2012/08/13 09:08:39 Done. https://chromiumcodereview.appspot.com/10828
462 }
463
433 bool FileResource::Parse(const base::Value& value) { 464 bool FileResource::Parse(const base::Value& value) {
434 base::JSONValueConverter<FileResource> converter; 465 base::JSONValueConverter<FileResource> converter;
435 if (!converter.Convert(value, this)) { 466 if (!converter.Convert(value, this)) {
436 LOG(ERROR) << "Unable to parse: Invalid FileResource"; 467 LOG(ERROR) << "Unable to parse: Invalid FileResource";
437 return false; 468 return false;
438 } 469 }
439 return true; 470 return true;
440 } 471 }
441 472
442 //////////////////////////////////////////////////////////////////////////////// 473 ////////////////////////////////////////////////////////////////////////////////
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 bool ChangeList::Parse(const base::Value& value) { 583 bool ChangeList::Parse(const base::Value& value) {
553 base::JSONValueConverter<ChangeList> converter; 584 base::JSONValueConverter<ChangeList> converter;
554 if (!converter.Convert(value, this)) { 585 if (!converter.Convert(value, this)) {
555 LOG(ERROR) << "Unable to parse: Invalid ChangeList"; 586 LOG(ERROR) << "Unable to parse: Invalid ChangeList";
556 return false; 587 return false;
557 } 588 }
558 return true; 589 return true;
559 } 590 }
560 591
561 } // namespace gdata 592 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698