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