• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
5 #ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_
6 #define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_
7 
8 #include <string>
9 
10 #include "base/callback.h"
11 
12 namespace base {
13 class DictionaryValue;
14 class ListValue;
15 }
16 
17 namespace cloud_devices {
18 
19 // Provides parsing, serialization and validation Cloud Device Description or
20 // Cloud Job Ticket.
21 // https://developers.google.com/cloud-print/docs/cdd
22 class CloudDeviceDescription {
23  public:
24   CloudDeviceDescription();
25   ~CloudDeviceDescription();
26 
27   void Reset();
28 
29   bool InitFromDictionary(scoped_ptr<base::DictionaryValue> root);
30   bool InitFromString(const std::string& json);
31 
32   std::string ToString() const;
33 
root()34   const base::DictionaryValue& root() const { return *root_; }
35 
36   // Returns dictionary with capability/option.
37   // Returns NULL if missing.
38   const base::DictionaryValue* GetItem(const std::string& path) const;
39 
40   // Create dictionary for capability/option.
41   // Never returns NULL.
42   base::DictionaryValue* CreateItem(const std::string& path);
43 
44   // Returns list with capability/option.
45   // Returns NULL if missing.
46   const base::ListValue* GetListItem(const std::string& path) const;
47 
48   // Create list for capability/option.
49   // Never returns NULL.
50   base::ListValue* CreateListItem(const std::string& path);
51 
52  private:
53   scoped_ptr<base::DictionaryValue> root_;
54 
55   DISALLOW_COPY_AND_ASSIGN(CloudDeviceDescription);
56 };
57 
58 }  // namespace cloud_devices
59 
60 #endif  // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_
61