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

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

Issue 10810070: Add Drive API parser for About/Apps json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/drive_api_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
6 #define CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/string_piece.h"
16 #include "base/time.h"
17 #include "googleurl/src/gurl.h"
18
19 namespace base {
20 class Value;
21 template <class StructType>
22 class JSONValueConverter;
23
24 namespace internal {
25 template <class NestedType>
26 class RepeatedMessageConverter;
27 } // namespace internal
28 } // namespace base
29
30 // TODO(kochi): Rename to namespace drive. http://crbug.com/136371
31 namespace gdata {
32
33 // About resource represents the account information about the current user.
34 class AboutResource {
35 public:
36 ~AboutResource();
37
38 // Registers the mapping between JSON field names and the members in this
39 // class.
40 static void RegisterJSONConverter(
41 base::JSONValueConverter<AboutResource>* converter);
42
43 static scoped_ptr<AboutResource> CreateFrom(const base::Value& value);
satorux1 2012/07/24 16:15:26 function comment is missing. CreateFrom() and Pars
kochi 2012/07/25 06:24:04 Done.
44
45 // Parses and initializes data members from content of |value|.
46 // Return false if parsing fails.
47 bool Parse(const base::Value& value) OVERRIDE;
48
49 const std::string& root_folder_id() const { return root_folder_id_; }
satorux1 2012/07/24 16:15:26 please document this. with the old API, the root d
kochi 2012/07/25 06:24:04 The short answer is no, thus this field exists. I
50 int64 quota_bytes_total() const { return quota_bytes_total_; }
51 int64 quota_bytes_used() const { return quota_bytes_used_; }
52 int64 largest_change_id() const { return largest_change_id_; }
53
54 private:
55 friend class DriveAPIParserTest;
56 FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, AboutResourceParser);
57 AboutResource();
58
59 std::string root_folder_id_;
60 int64 quota_bytes_total_;
61 int64 quota_bytes_used_;
62 int64 largest_change_id_;
63
64 DISALLOW_COPY_AND_ASSIGN(AboutResource);
65 };
66
67 class DriveAppIcon {
satorux1 2012/07/24 16:15:26 class comment is missing.
kochi 2012/07/25 06:24:04 Done.
68 public:
69 enum IconCategory {
70 UNKNOWN, // Uninitialized state
71 DOCUMENT, // Document icon for various MIME types
72 APPLICATION, // Application icon for various MIME types
73 SHARED_DOCUMENT, // Icon for documents that are shared from other users.
74 };
75
76 ~DriveAppIcon();
77
78 static void RegisterJSONConverter(
79 base::JSONValueConverter<DriveAppIcon>* converter);
80 static scoped_ptr<DriveAppIcon> CreateFrom(const base::Value& value);
81
82 bool Parse(const base::Value& value);
83
84 // Category of the icon.
85 IconCategory category() const { return category_; }
86
87 // Size in pixels of one side of the icon (icons are always square).
88 int size() const { return size_; }
satorux1 2012/07/24 16:15:26 size -> side_length() ?
kochi 2012/07/25 06:24:04 I tried to use the same field name as JSON, but I
89
90 const GURL& icon_url() const { return icon_url_; }
91
92 private:
93 // Extracts the icon category from the given string. Returns false and does
94 // not change |result| when |scheme| has an unrecognizable value.
95 static bool GetIconCategory(const base::StringPiece& category,
96 IconCategory* result);
97
98 friend class base::internal::RepeatedMessageConverter<DriveAppIcon>;
99 friend class AppResource;
100 DriveAppIcon();
101
102 IconCategory category_;
103 int size_;
104 GURL icon_url_;
105
106 DISALLOW_COPY_AND_ASSIGN(DriveAppIcon);
107 };
108
109 class AppResource {
satorux1 2012/07/24 16:15:26 class comment
kochi 2012/07/25 06:24:05 Done.
110 public:
111 ~AppResource();
112
113 static void RegisterJSONConverter(
114 base::JSONValueConverter<AppResource>* converter);
115 static scoped_ptr<AppResource> CreateFrom(const base::Value& value);
116
117 bool Parse(const base::Value& value);
118
119 const std::string& id() const { return id_; }
120 const std::string& name() const { return name_; }
121 const std::string& object_type() const { return object_type_; }
122 bool supports_create() const { return supports_create_; }
123 bool supports_import() const { return supports_import_; }
124 bool installed() const { return installed_; }
125 bool authorized() const { return authorized_; }
126 const GURL& product_url() const { return product_url_; }
satorux1 2012/07/24 16:15:26 Please document these fields.
kochi 2012/07/25 06:24:05 Done.
127
128 // List of primary mime types supported by this WebApp. Primary status should
129 // trigger this WebApp becoming the default handler of file instances that
130 // have these mime types.
131 const ScopedVector<std::string>& primary_mimetypes() const {
132 return primary_mimetypes_;
133 }
134
135 // List of secondary mime types supported by this WebApp. Secondary status
136 // should make this WebApp show up in "Open with..." pop-up menu of the
137 // default action menu for file with matching mime types.
138 const ScopedVector<std::string>& secondary_mimetypes() const {
139 return secondary_mimetypes_;
140 }
141
142 // List of primary file extensions supported by this WebApp. Primary status
143 // should trigger this WebApp becoming the default handler of file instances
144 // that match these extensions.
145 const ScopedVector<std::string>& primary_file_extensions() const {
146 return primary_file_extensions_;
147 }
148
149 // List of secondary file extensions supported by this WebApp. Secondary
150 // status should make this WebApp show up in "Open with..." pop-up menu of the
151 // default action menu for file with matching extensions.
152 const ScopedVector<std::string>& secondary_file_extensions() const {
153 return secondary_file_extensions_;
154 }
155
156 const ScopedVector<DriveAppIcon>& icons() const {
157 return icons_;
158 }
159
160 private:
161 friend class base::internal::RepeatedMessageConverter<AppResource>;
162 friend class AppList;
163 AppResource();
164
165 std::string id_;
166 std::string name_;
167 std::string object_type_;
168 bool supports_create_;
169 bool supports_import_;
170 bool installed_;
171 bool authorized_;
172 GURL product_url_;
173 ScopedVector<std::string> primary_mimetypes_;
174 ScopedVector<std::string> secondary_mimetypes_;
175 ScopedVector<std::string> primary_file_extensions_;
176 ScopedVector<std::string> secondary_file_extensions_;
177 ScopedVector<DriveAppIcon> icons_;
178
179 DISALLOW_COPY_AND_ASSIGN(AppResource);
180 };
181
182 class AppList {
satorux1 2012/07/24 16:15:26 class comment.
kochi 2012/07/25 06:24:05 Done.
183 public:
184 ~AppList();
185
186 static void RegisterJSONConverter(
187 base::JSONValueConverter<AppList>* converter);
188 static scoped_ptr<AppList> CreateFrom(const base::Value& value);
189
190 bool Parse(const base::Value& value);
191
192 const std::string& etag() const { return etag_; }
193 const ScopedVector<AppResource>& items() const { return items_; }
194
195 private:
196 friend class DriveAPIParserTest;
197 FRIEND_TEST_ALL_PREFIXES(DriveAPIParserTest, AppListParser);
198 AppList();
199
200 std::string etag_;
201 ScopedVector<AppResource> items_;
202
203 DISALLOW_COPY_AND_ASSIGN(AppList);
204 };
205
206 } // namespace gdata
207
208 #endif // CHROME_BROWSER_CHROMEOS_GDATA_DRIVE_API_PARSER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/drive_api_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698