[email protected] | 89b80cc | 2014-02-04 01:01:52 | [diff] [blame] | 1 | // Copyright 2014 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 | |||||
[email protected] | 5b38caf | 2014-04-18 05:32:06 | [diff] [blame] | 5 | #ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ |
6 | #define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ | ||||
[email protected] | 89b80cc | 2014-02-04 01:01:52 | [diff] [blame] | 7 | |
dcheng | a0ee5fb | 2016-04-26 02:46:55 | [diff] [blame] | 8 | #include <memory> |
[email protected] | 89b80cc | 2014-02-04 01:01:52 | [diff] [blame] | 9 | #include <string> |
10 | |||||
avi | bc5337b | 2015-12-25 23:16:33 | [diff] [blame] | 11 | #include "base/macros.h" |
[email protected] | 89b80cc | 2014-02-04 01:01:52 | [diff] [blame] | 12 | |
13 | namespace base { | ||||
14 | class DictionaryValue; | ||||
15 | class ListValue; | ||||
16 | } | ||||
17 | |||||
18 | namespace cloud_devices { | ||||
19 | |||||
20 | // Provides parsing, serialization and validation Cloud Device Description or | ||||
21 | // Cloud Job Ticket. | ||||
22 | // https://developers.google.com/cloud-print/docs/cdd | ||||
23 | class CloudDeviceDescription { | ||||
24 | public: | ||||
25 | CloudDeviceDescription(); | ||||
26 | ~CloudDeviceDescription(); | ||||
27 | |||||
[email protected] | 89b80cc | 2014-02-04 01:01:52 | [diff] [blame] | 28 | bool InitFromString(const std::string& json); |
29 | |||||
30 | std::string ToString() const; | ||||
31 | |||||
[email protected] | 2dafb8b | 2014-05-29 16:32:48 | [diff] [blame] | 32 | const base::DictionaryValue& root() const { return *root_; } |
33 | |||||
[email protected] | 89b80cc | 2014-02-04 01:01:52 | [diff] [blame] | 34 | // Returns dictionary with capability/option. |
35 | // Returns NULL if missing. | ||||
36 | const base::DictionaryValue* GetItem(const std::string& path) const; | ||||
37 | |||||
38 | // Create dictionary for capability/option. | ||||
39 | // Never returns NULL. | ||||
40 | base::DictionaryValue* CreateItem(const std::string& path); | ||||
41 | |||||
42 | // Returns list with capability/option. | ||||
43 | // Returns NULL if missing. | ||||
44 | const base::ListValue* GetListItem(const std::string& path) const; | ||||
45 | |||||
46 | // Create list for capability/option. | ||||
47 | // Never returns NULL. | ||||
48 | base::ListValue* CreateListItem(const std::string& path); | ||||
49 | |||||
50 | private: | ||||
dcheng | a0ee5fb | 2016-04-26 02:46:55 | [diff] [blame] | 51 | std::unique_ptr<base::DictionaryValue> root_; |
[email protected] | 89b80cc | 2014-02-04 01:01:52 | [diff] [blame] | 52 | |
53 | DISALLOW_COPY_AND_ASSIGN(CloudDeviceDescription); | ||||
54 | }; | ||||
55 | |||||
56 | } // namespace cloud_devices | ||||
57 | |||||
[email protected] | 5b38caf | 2014-04-18 05:32:06 | [diff] [blame] | 58 | #endif // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ |