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.
5 #ifndef COMPONENTS_CLOUD_DEVICES_CLOUD_DEVICE_DESCRIPTION_H_
6 #define COMPONENTS_CLOUD_DEVICES_CLOUD_DEVICE_DESCRIPTION_H_
10 #include "base/callback.h"
13 class DictionaryValue
;
17 namespace cloud_devices
{
19 // Provides parsing, serialization and validation Cloud Device Description or
21 // https://developers.google.com/cloud-print/docs/cdd
22 class CloudDeviceDescription
{
24 CloudDeviceDescription();
25 ~CloudDeviceDescription();
29 bool InitFromDictionary(scoped_ptr
<base::DictionaryValue
> root
);
30 bool InitFromString(const std::string
& json
);
32 std::string
ToString() const;
34 // Returns dictionary with capability/option.
35 // Returns NULL if missing.
36 const base::DictionaryValue
* GetItem(const std::string
& path
) const;
38 // Create dictionary for capability/option.
39 // Never returns NULL.
40 base::DictionaryValue
* CreateItem(const std::string
& path
);
42 // Returns list with capability/option.
43 // Returns NULL if missing.
44 const base::ListValue
* GetListItem(const std::string
& path
) const;
46 // Create list for capability/option.
47 // Never returns NULL.
48 base::ListValue
* CreateListItem(const std::string
& path
);
51 scoped_ptr
<base::DictionaryValue
> root_
;
53 DISALLOW_COPY_AND_ASSIGN(CloudDeviceDescription
);
56 } // namespace cloud_devices
58 #endif // COMPONENTS_CLOUD_DEVICES_CLOUD_DEVICE_DESCRIPTION_H_