| OLD | NEW |
| 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 "google_apis/drive/gdata_wapi_parser.h" | 5 #include "google_apis/drive/gdata_wapi_parser.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 if (kEntryKindMap[i].extension) | 529 if (kEntryKindMap[i].extension) |
| 530 return std::string(kEntryKindMap[i].extension); | 530 return std::string(kEntryKindMap[i].extension); |
| 531 else | 531 else |
| 532 return std::string(); | 532 return std::string(); |
| 533 } | 533 } |
| 534 } | 534 } |
| 535 return std::string(); | 535 return std::string(); |
| 536 } | 536 } |
| 537 | 537 |
| 538 // static | 538 // static |
| 539 DriveEntryKind ResourceEntry::GetEntryKindFromExtension( |
| 540 const std::string& extension) { |
| 541 for (size_t i = 0; i < arraysize(kEntryKindMap); ++i) { |
| 542 const char* document_extension = kEntryKindMap[i].extension; |
| 543 if (document_extension && extension == document_extension) |
| 544 return kEntryKindMap[i].kind; |
| 545 } |
| 546 return ENTRY_KIND_UNKNOWN; |
| 547 } |
| 548 |
| 549 // static |
| 539 int ResourceEntry::ClassifyEntryKindByFileExtension( | 550 int ResourceEntry::ClassifyEntryKindByFileExtension( |
| 540 const base::FilePath& file_path) { | 551 const base::FilePath& file_path) { |
| 541 #if defined(OS_WIN) | 552 #if defined(OS_WIN) |
| 542 std::string file_extension = base::WideToUTF8(file_path.Extension()); | 553 std::string file_extension = base::WideToUTF8(file_path.Extension()); |
| 543 #else | 554 #else |
| 544 std::string file_extension = file_path.Extension(); | 555 std::string file_extension = file_path.Extension(); |
| 545 #endif | 556 #endif |
| 546 for (size_t i = 0; i < arraysize(kEntryKindMap); ++i) { | 557 return ClassifyEntryKind(GetEntryKindFromExtension(file_extension)); |
| 547 const char* document_extension = kEntryKindMap[i].extension; | |
| 548 if (document_extension && file_extension == document_extension) | |
| 549 return ClassifyEntryKind(kEntryKindMap[i].kind); | |
| 550 } | |
| 551 return 0; | |
| 552 } | 558 } |
| 553 | 559 |
| 554 // static | 560 // static |
| 555 DriveEntryKind ResourceEntry::GetEntryKindFromTerm( | 561 DriveEntryKind ResourceEntry::GetEntryKindFromTerm( |
| 556 const std::string& term) { | 562 const std::string& term) { |
| 557 if (!StartsWithASCII(term, kTermPrefix, false)) { | 563 if (!StartsWithASCII(term, kTermPrefix, false)) { |
| 558 DVLOG(1) << "Unexpected term prefix term " << term; | 564 DVLOG(1) << "Unexpected term prefix term " << term; |
| 559 return ENTRY_KIND_UNKNOWN; | 565 return ENTRY_KIND_UNKNOWN; |
| 560 } | 566 } |
| 561 | 567 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 bool AccountMetadata::Parse(const base::Value& value) { | 880 bool AccountMetadata::Parse(const base::Value& value) { |
| 875 base::JSONValueConverter<AccountMetadata> converter; | 881 base::JSONValueConverter<AccountMetadata> converter; |
| 876 if (!converter.Convert(value, this)) { | 882 if (!converter.Convert(value, this)) { |
| 877 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; | 883 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; |
| 878 return false; | 884 return false; |
| 879 } | 885 } |
| 880 return true; | 886 return true; |
| 881 } | 887 } |
| 882 | 888 |
| 883 } // namespace google_apis | 889 } // namespace google_apis |
| OLD | NEW |