blob: c840424be20b35e7b695aef3b435682c9117d841 [file] [log] [blame]
[email protected]89b80cc2014-02-04 01:01:521// 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]5b38caf2014-04-18 05:32:065#ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_
6#define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_
[email protected]89b80cc2014-02-04 01:01:527
dchenga0ee5fb2016-04-26 02:46:558#include <memory>
[email protected]89b80cc2014-02-04 01:01:529#include <string>
10
avibc5337b2015-12-25 23:16:3311#include "base/macros.h"
[email protected]89b80cc2014-02-04 01:01:5212
13namespace base {
14class DictionaryValue;
15class ListValue;
16}
17
18namespace 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
23class CloudDeviceDescription {
24 public:
25 CloudDeviceDescription();
26 ~CloudDeviceDescription();
27
[email protected]89b80cc2014-02-04 01:01:5228 bool InitFromString(const std::string& json);
29
30 std::string ToString() const;
31
[email protected]2dafb8b2014-05-29 16:32:4832 const base::DictionaryValue& root() const { return *root_; }
33
[email protected]89b80cc2014-02-04 01:01:5234 // 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:
dchenga0ee5fb2016-04-26 02:46:5551 std::unique_ptr<base::DictionaryValue> root_;
[email protected]89b80cc2014-02-04 01:01:5252
53 DISALLOW_COPY_AND_ASSIGN(CloudDeviceDescription);
54};
55
56} // namespace cloud_devices
57
[email protected]5b38caf2014-04-18 05:32:0658#endif // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_