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/drive_api_parser.h" | 5 #include "google_apis/drive/drive_api_parser.h" |
6 | 6 |
7 #include <algorithm> | |
8 | |
9 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
10 #include "base/files/file_path.h" | |
11 #include "base/json/json_value_converter.h" | 8 #include "base/json/json_value_converter.h" |
12 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
13 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
15 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
16 #include "base/values.h" | 13 #include "base/values.h" |
17 #include "google_apis/drive/time_util.h" | 14 #include "google_apis/drive/time_util.h" |
18 | 15 |
19 using base::Value; | |
20 using base::DictionaryValue; | |
21 using base::ListValue; | |
22 | |
23 namespace google_apis { | 16 namespace google_apis { |
24 | 17 |
25 namespace { | 18 namespace { |
26 | 19 |
27 const int64 kUnsetFileSize = -1; | 20 const int64 kUnsetFileSize = -1; |
28 | 21 |
29 bool CreateFileResourceFromValue(const base::Value* value, | 22 bool CreateFileResourceFromValue(const base::Value* value, |
30 scoped_ptr<FileResource>* file) { | 23 scoped_ptr<FileResource>* file) { |
31 *file = FileResource::CreateFrom(*value); | 24 *file = FileResource::CreateFrom(*value); |
32 return !!*file; | 25 return !!*file; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 const base::Value* value, | 61 const base::Value* value, |
69 std::vector<FileResource::OpenWithLink>* result) { | 62 std::vector<FileResource::OpenWithLink>* result) { |
70 DCHECK(value); | 63 DCHECK(value); |
71 DCHECK(result); | 64 DCHECK(result); |
72 | 65 |
73 const base::DictionaryValue* dictionary_value; | 66 const base::DictionaryValue* dictionary_value; |
74 if (!value->GetAsDictionary(&dictionary_value)) | 67 if (!value->GetAsDictionary(&dictionary_value)) |
75 return false; | 68 return false; |
76 | 69 |
77 result->reserve(dictionary_value->size()); | 70 result->reserve(dictionary_value->size()); |
78 for (DictionaryValue::Iterator iter(*dictionary_value); | 71 for (base::DictionaryValue::Iterator iter(*dictionary_value); |
79 !iter.IsAtEnd(); iter.Advance()) { | 72 !iter.IsAtEnd(); iter.Advance()) { |
80 std::string string_value; | 73 std::string string_value; |
81 if (!iter.value().GetAsString(&string_value)) | 74 if (!iter.value().GetAsString(&string_value)) |
82 return false; | 75 return false; |
83 | 76 |
84 FileResource::OpenWithLink open_with_link; | 77 FileResource::OpenWithLink open_with_link; |
85 open_with_link.app_id = iter.key(); | 78 open_with_link.app_id = iter.key(); |
86 open_with_link.open_url = GURL(string_value); | 79 open_with_link.open_url = GURL(string_value); |
87 result->push_back(open_with_link); | 80 result->push_back(open_with_link); |
88 } | 81 } |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 bool ImageMediaMetadata::Parse(const base::Value& value) { | 696 bool ImageMediaMetadata::Parse(const base::Value& value) { |
704 base::JSONValueConverter<ImageMediaMetadata> converter; | 697 base::JSONValueConverter<ImageMediaMetadata> converter; |
705 if (!converter.Convert(value, this)) { | 698 if (!converter.Convert(value, this)) { |
706 LOG(ERROR) << "Unable to parse: Invalid ImageMediaMetadata."; | 699 LOG(ERROR) << "Unable to parse: Invalid ImageMediaMetadata."; |
707 return false; | 700 return false; |
708 } | 701 } |
709 return true; | 702 return true; |
710 } | 703 } |
711 | 704 |
712 } // namespace google_apis | 705 } // namespace google_apis |
OLD | NEW |