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

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

Issue 9581024: Added proper extensions for hosted documents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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/gdata_parser.h" 5 #include "chrome/browser/chromeos/gdata/gdata_parser.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/json/json_value_converter.h" 8 #include "base/json/json_value_converter.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 18 matching lines...) Expand all
29 const char kPdfTerm[] = "pdf"; 29 const char kPdfTerm[] = "pdf";
30 const char kDocumentTerm[] = "document"; 30 const char kDocumentTerm[] = "document";
31 const char kSpreadSheetTerm[] = "spreadsheet"; 31 const char kSpreadSheetTerm[] = "spreadsheet";
32 const char kPresentationTerm[] = "presentation"; 32 const char kPresentationTerm[] = "presentation";
33 33
34 const char kSchemeLabels[] = "http://schemas.google.com/g/2005/labels"; 34 const char kSchemeLabels[] = "http://schemas.google.com/g/2005/labels";
35 35
36 struct EntryKindMap { 36 struct EntryKindMap {
37 DocumentEntry::EntryKind kind; 37 DocumentEntry::EntryKind kind;
38 const char* entry; 38 const char* entry;
39 const char* extension;
39 }; 40 };
40 41
41 const EntryKindMap kEntryKindMap[] = { 42 const EntryKindMap kEntryKindMap[] = {
42 { DocumentEntry::ITEM, "item" }, 43 { DocumentEntry::ITEM, "item", NULL},
43 { DocumentEntry::DOCUMENT, "document"}, 44 { DocumentEntry::DOCUMENT, "document", ".gdoc"},
44 { DocumentEntry::SPREADSHEET, "spreadsheet" }, 45 { DocumentEntry::SPREADSHEET, "spreadsheet", ".gsheet"},
45 { DocumentEntry::PRESENTATION, "presentation" }, 46 { DocumentEntry::PRESENTATION, "presentation", ".gslides" },
46 { DocumentEntry::DRAWING, "drawing"}, 47 { DocumentEntry::DRAWING, "drawing", ".gdraw"},
47 { DocumentEntry::TABLE, "table"}, 48 { DocumentEntry::TABLE, "table", ".gtable"},
48 { DocumentEntry::SITE, "site"}, 49 { DocumentEntry::SITE, "site", NULL},
49 { DocumentEntry::FOLDER, "folder"}, 50 { DocumentEntry::FOLDER, "folder", NULL},
50 { DocumentEntry::FILE, "file"}, 51 { DocumentEntry::FILE, "file", NULL},
51 { DocumentEntry::PDF, "pdf"}, 52 { DocumentEntry::PDF, "pdf", NULL},
52 }; 53 };
53 54
54 struct LinkTypeMap { 55 struct LinkTypeMap {
55 Link::LinkType type; 56 Link::LinkType type;
56 const char* rel; 57 const char* rel;
57 }; 58 };
58 59
59 const LinkTypeMap kLinkTypeMap[] = { 60 const LinkTypeMap kLinkTypeMap[] = {
60 { Link::SELF, 61 { Link::SELF,
61 "self" }, 62 "self" },
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // that's no problem because those feed must not have these fields 340 // that's no problem because those feed must not have these fields
340 // themselves, which does not report errors. 341 // themselves, which does not report errors.
341 converter->RegisterStringField(kFileNameField, &DocumentEntry::filename_); 342 converter->RegisterStringField(kFileNameField, &DocumentEntry::filename_);
342 converter->RegisterStringField(kMD5Field, &DocumentEntry::file_md5_); 343 converter->RegisterStringField(kMD5Field, &DocumentEntry::file_md5_);
343 converter->RegisterCustomField<int64>( 344 converter->RegisterCustomField<int64>(
344 kSizeField, &DocumentEntry::file_size_, &base::StringToInt64); 345 kSizeField, &DocumentEntry::file_size_, &base::StringToInt64);
345 converter->RegisterStringField( 346 converter->RegisterStringField(
346 kSuggestedFileNameField, &DocumentEntry::suggested_filename_); 347 kSuggestedFileNameField, &DocumentEntry::suggested_filename_);
347 } 348 }
348 349
349 std::string DocumentEntry::GetEntryKindText() const { 350 std::string DocumentEntry::GetHostedDocumentExtension() const {
350 return std::string(GetEntryKindDescription(kind_)); 351 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) {
352 if (kEntryKindMap[i].kind == kind_) {
353 if (kEntryKindMap[i].extension)
354 return std::string(kEntryKindMap[i].extension);
355 else
356 return std::string();
357 }
358 }
359 return std::string();
351 } 360 }
352 361
353 // static 362 // static
354 const char* DocumentEntry::GetEntryKindDescription(
355 DocumentEntry::EntryKind kind) {
356 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) {
357 if (kEntryKindMap[i].kind == kind)
358 return kEntryKindMap[i].entry;
359 }
360 return "";
361 }
362
363 // static
364 DocumentEntry::EntryKind DocumentEntry::GetEntryKindFromTerm( 363 DocumentEntry::EntryKind DocumentEntry::GetEntryKindFromTerm(
365 const std::string& term) { 364 const std::string& term) {
366 if (!StartsWithASCII(term, kTermPrefix, false)) { 365 if (!StartsWithASCII(term, kTermPrefix, false)) {
367 DVLOG(1) << "Unexpected term prefix term " << term; 366 DVLOG(1) << "Unexpected term prefix term " << term;
368 return DocumentEntry::UNKNOWN; 367 return DocumentEntry::UNKNOWN;
369 } 368 }
370 369
371 std::string type = term.substr(strlen(kTermPrefix)); 370 std::string type = term.substr(strlen(kTermPrefix));
372 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) { 371 for (size_t i = 0; i < arraysize(kEntryKindMap); i++) {
373 if (type == kEntryKindMap[i].entry) 372 if (type == kEntryKindMap[i].entry)
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 for (size_t i = 0; i < links_.size(); ++i) { 461 for (size_t i = 0; i < links_.size(); ++i) {
463 if (links_[i]->type() == Link::NEXT) { 462 if (links_[i]->type() == Link::NEXT) {
464 *url = links_[i]->href(); 463 *url = links_[i]->href();
465 return true; 464 return true;
466 } 465 }
467 } 466 }
468 return false; 467 return false;
469 } 468 }
470 469
471 } // namespace gdata 470 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_parser.h ('k') | chrome/browser/resources/file_manager/css/file_manager.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698