OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ | 5 #ifndef COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ |
6 #define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ | 6 #define COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class DictionaryValue; | 15 class DictionaryValue; |
16 class ListValue; | 16 class ListValue; |
17 } | 17 } |
18 | 18 |
19 namespace cloud_devices { | 19 namespace cloud_devices { |
20 | 20 |
21 // Provides parsing, serialization and validation Cloud Device Description or | 21 // Provides parsing, serialization and validation Cloud Device Description or |
22 // Cloud Job Ticket. | 22 // Cloud Job Ticket. |
23 // https://developers.google.com/cloud-print/docs/cdd | 23 // https://developers.google.com/cloud-print/docs/cdd |
24 class CloudDeviceDescription { | 24 class CloudDeviceDescription { |
25 public: | 25 public: |
26 CloudDeviceDescription(); | 26 CloudDeviceDescription(); |
27 ~CloudDeviceDescription(); | 27 ~CloudDeviceDescription(); |
28 | 28 |
29 void Reset(); | 29 void Reset(); |
30 | 30 |
31 bool InitFromDictionary(scoped_ptr<base::DictionaryValue> root); | 31 bool InitFromDictionary(std::unique_ptr<base::DictionaryValue> root); |
32 bool InitFromString(const std::string& json); | 32 bool InitFromString(const std::string& json); |
33 | 33 |
34 std::string ToString() const; | 34 std::string ToString() const; |
35 | 35 |
36 const base::DictionaryValue& root() const { return *root_; } | 36 const base::DictionaryValue& root() const { return *root_; } |
37 | 37 |
38 // Returns dictionary with capability/option. | 38 // Returns dictionary with capability/option. |
39 // Returns NULL if missing. | 39 // Returns NULL if missing. |
40 const base::DictionaryValue* GetItem(const std::string& path) const; | 40 const base::DictionaryValue* GetItem(const std::string& path) const; |
41 | 41 |
42 // Create dictionary for capability/option. | 42 // Create dictionary for capability/option. |
43 // Never returns NULL. | 43 // Never returns NULL. |
44 base::DictionaryValue* CreateItem(const std::string& path); | 44 base::DictionaryValue* CreateItem(const std::string& path); |
45 | 45 |
46 // Returns list with capability/option. | 46 // Returns list with capability/option. |
47 // Returns NULL if missing. | 47 // Returns NULL if missing. |
48 const base::ListValue* GetListItem(const std::string& path) const; | 48 const base::ListValue* GetListItem(const std::string& path) const; |
49 | 49 |
50 // Create list for capability/option. | 50 // Create list for capability/option. |
51 // Never returns NULL. | 51 // Never returns NULL. |
52 base::ListValue* CreateListItem(const std::string& path); | 52 base::ListValue* CreateListItem(const std::string& path); |
53 | 53 |
54 private: | 54 private: |
55 scoped_ptr<base::DictionaryValue> root_; | 55 std::unique_ptr<base::DictionaryValue> root_; |
56 | 56 |
57 DISALLOW_COPY_AND_ASSIGN(CloudDeviceDescription); | 57 DISALLOW_COPY_AND_ASSIGN(CloudDeviceDescription); |
58 }; | 58 }; |
59 | 59 |
60 } // namespace cloud_devices | 60 } // namespace cloud_devices |
61 | 61 |
62 #endif // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ | 62 #endif // COMPONENTS_CLOUD_DEVICES_COMMON_CLOUD_DEVICE_DESCRIPTION_H_ |
OLD | NEW |