| 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 "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_wapi_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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 kind_ = GetEntryKindFromTerm(category->term()); | 689 kind_ = GetEntryKindFromTerm(category->term()); |
| 690 else if (category->type() == Category::LABEL) | 690 else if (category->type() == Category::LABEL) |
| 691 labels_.push_back(category->label()); | 691 labels_.push_back(category->label()); |
| 692 } | 692 } |
| 693 } | 693 } |
| 694 | 694 |
| 695 // static | 695 // static |
| 696 DocumentEntry* DocumentEntry::ExtractAndParse( | 696 DocumentEntry* DocumentEntry::ExtractAndParse( |
| 697 const base::Value& value) { | 697 const base::Value& value) { |
| 698 const base::DictionaryValue* as_dict = NULL; | 698 const base::DictionaryValue* as_dict = NULL; |
| 699 base::DictionaryValue* entry_dict = NULL; | 699 const base::DictionaryValue* entry_dict = NULL; |
| 700 if (value.GetAsDictionary(&as_dict) && | 700 if (value.GetAsDictionary(&as_dict) && |
| 701 as_dict->GetDictionary(kEntryField, &entry_dict)) { | 701 as_dict->GetDictionary(kEntryField, &entry_dict)) { |
| 702 return DocumentEntry::CreateFrom(*entry_dict); | 702 return DocumentEntry::CreateFrom(*entry_dict); |
| 703 } | 703 } |
| 704 return NULL; | 704 return NULL; |
| 705 } | 705 } |
| 706 | 706 |
| 707 // static | 707 // static |
| 708 DocumentEntry* DocumentEntry::CreateFrom(const base::Value& value) { | 708 DocumentEntry* DocumentEntry::CreateFrom(const base::Value& value) { |
| 709 base::JSONValueConverter<DocumentEntry> converter; | 709 base::JSONValueConverter<DocumentEntry> converter; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 entry->FillRemainingFields(); | 852 entry->FillRemainingFields(); |
| 853 ++iter; | 853 ++iter; |
| 854 } | 854 } |
| 855 return true; | 855 return true; |
| 856 } | 856 } |
| 857 | 857 |
| 858 // static | 858 // static |
| 859 scoped_ptr<DocumentFeed> DocumentFeed::ExtractAndParse( | 859 scoped_ptr<DocumentFeed> DocumentFeed::ExtractAndParse( |
| 860 const base::Value& value) { | 860 const base::Value& value) { |
| 861 const base::DictionaryValue* as_dict = NULL; | 861 const base::DictionaryValue* as_dict = NULL; |
| 862 base::DictionaryValue* feed_dict = NULL; | 862 const base::DictionaryValue* feed_dict = NULL; |
| 863 if (value.GetAsDictionary(&as_dict) && | 863 if (value.GetAsDictionary(&as_dict) && |
| 864 as_dict->GetDictionary(kFeedField, &feed_dict)) { | 864 as_dict->GetDictionary(kFeedField, &feed_dict)) { |
| 865 return DocumentFeed::CreateFrom(*feed_dict); | 865 return DocumentFeed::CreateFrom(*feed_dict); |
| 866 } | 866 } |
| 867 return scoped_ptr<DocumentFeed>(NULL); | 867 return scoped_ptr<DocumentFeed>(NULL); |
| 868 } | 868 } |
| 869 | 869 |
| 870 // static | 870 // static |
| 871 scoped_ptr<DocumentFeed> DocumentFeed::CreateFrom(const base::Value& value) { | 871 scoped_ptr<DocumentFeed> DocumentFeed::CreateFrom(const base::Value& value) { |
| 872 scoped_ptr<DocumentFeed> feed(new DocumentFeed()); | 872 scoped_ptr<DocumentFeed> feed(new DocumentFeed()); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 &base::StringToInt); | 1000 &base::StringToInt); |
| 1001 converter->RegisterRepeatedMessage(kInstalledAppField, | 1001 converter->RegisterRepeatedMessage(kInstalledAppField, |
| 1002 &AccountMetadataFeed::installed_apps_); | 1002 &AccountMetadataFeed::installed_apps_); |
| 1003 } | 1003 } |
| 1004 | 1004 |
| 1005 // static | 1005 // static |
| 1006 scoped_ptr<AccountMetadataFeed> AccountMetadataFeed::CreateFrom( | 1006 scoped_ptr<AccountMetadataFeed> AccountMetadataFeed::CreateFrom( |
| 1007 const base::Value& value) { | 1007 const base::Value& value) { |
| 1008 scoped_ptr<AccountMetadataFeed> feed(new AccountMetadataFeed()); | 1008 scoped_ptr<AccountMetadataFeed> feed(new AccountMetadataFeed()); |
| 1009 const base::DictionaryValue* dictionary = NULL; | 1009 const base::DictionaryValue* dictionary = NULL; |
| 1010 base::Value* entry = NULL; | 1010 const base::Value* entry = NULL; |
| 1011 if (!value.GetAsDictionary(&dictionary) || | 1011 if (!value.GetAsDictionary(&dictionary) || |
| 1012 !dictionary->Get(kEntryField, &entry) || | 1012 !dictionary->Get(kEntryField, &entry) || |
| 1013 !feed->Parse(*entry)) { | 1013 !feed->Parse(*entry)) { |
| 1014 LOG(ERROR) << "Unable to create: Invalid account metadata feed!"; | 1014 LOG(ERROR) << "Unable to create: Invalid account metadata feed!"; |
| 1015 return scoped_ptr<AccountMetadataFeed>(NULL); | 1015 return scoped_ptr<AccountMetadataFeed>(NULL); |
| 1016 } | 1016 } |
| 1017 | 1017 |
| 1018 return feed.Pass(); | 1018 return feed.Pass(); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 bool AccountMetadataFeed::Parse(const base::Value& value) { | 1021 bool AccountMetadataFeed::Parse(const base::Value& value) { |
| 1022 base::JSONValueConverter<AccountMetadataFeed> converter; | 1022 base::JSONValueConverter<AccountMetadataFeed> converter; |
| 1023 if (!converter.Convert(value, this)) { | 1023 if (!converter.Convert(value, this)) { |
| 1024 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; | 1024 LOG(ERROR) << "Unable to parse: Invalid account metadata feed!"; |
| 1025 return false; | 1025 return false; |
| 1026 } | 1026 } |
| 1027 return true; | 1027 return true; |
| 1028 } | 1028 } |
| 1029 | 1029 |
| 1030 } // namespace gdata | 1030 } // namespace gdata |
| OLD | NEW |