| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 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 // Keep this file in sync with the .proto files in this directory. | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_ | |
| 8 #define CHROME_BROWSER_SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_ | |
| 9 #pragma once | |
| 10 | |
| 11 namespace base { | |
| 12 class DictionaryValue; | |
| 13 } | |
| 14 | |
| 15 namespace sync_pb { | |
| 16 class AppNotification; | |
| 17 class AppNotificationSettings; | |
| 18 class AppSettingSpecifics; | |
| 19 class AppSpecifics; | |
| 20 class AutofillProfileSpecifics; | |
| 21 class AutofillSpecifics; | |
| 22 class BookmarkSpecifics; | |
| 23 class DeviceInformation; | |
| 24 class EncryptedData; | |
| 25 class EntitySpecifics; | |
| 26 class ExtensionSettingSpecifics; | |
| 27 class ExtensionSpecifics; | |
| 28 class NigoriSpecifics; | |
| 29 class PasswordSpecifics; | |
| 30 class PasswordSpecificsData; | |
| 31 class PreferenceSpecifics; | |
| 32 class SearchEngineSpecifics; | |
| 33 class SessionHeader; | |
| 34 class SessionSpecifics; | |
| 35 class SessionTab; | |
| 36 class SessionWindow; | |
| 37 class TabNavigation; | |
| 38 class ThemeSpecifics; | |
| 39 class TypedUrlSpecifics; | |
| 40 } // namespace sync_pb | |
| 41 | |
| 42 // Utility functions to convert sync protocol buffers to dictionaries. | |
| 43 // Each protocol field is mapped to a key of the same name. Repeated | |
| 44 // fields are mapped to array values and sub-messages are mapped to | |
| 45 // sub-dictionary values. | |
| 46 // | |
| 47 // TODO(akalin): Add has_* information. | |
| 48 // | |
| 49 // TODO(akalin): Improve enum support. | |
| 50 | |
| 51 namespace browser_sync { | |
| 52 | |
| 53 // Ownership of all returned DictionaryValues are transferred to the | |
| 54 // caller. | |
| 55 | |
| 56 // TODO(akalin): Perhaps extend this to decrypt? | |
| 57 base::DictionaryValue* EncryptedDataToValue( | |
| 58 const sync_pb::EncryptedData& encrypted_data); | |
| 59 | |
| 60 // Sub-protocol of AppSpecifics. | |
| 61 base::DictionaryValue* AppSettingsToValue( | |
| 62 const sync_pb::AppNotificationSettings& app_notification_settings); | |
| 63 | |
| 64 // Sub-protocols of SessionSpecifics. | |
| 65 | |
| 66 base::DictionaryValue* SessionHeaderToValue( | |
| 67 const sync_pb::SessionHeader& session_header); | |
| 68 | |
| 69 base::DictionaryValue* SessionTabToValue( | |
| 70 const sync_pb::SessionTab& session_tab); | |
| 71 | |
| 72 base::DictionaryValue* SessionWindowToValue( | |
| 73 const sync_pb::SessionWindow& session_window); | |
| 74 | |
| 75 base::DictionaryValue* TabNavigationToValue( | |
| 76 const sync_pb::TabNavigation& tab_navigation); | |
| 77 | |
| 78 // Sub-protocol of PasswordSpecifics. | |
| 79 | |
| 80 base::DictionaryValue* PasswordSpecificsDataToValue( | |
| 81 const sync_pb::PasswordSpecificsData& password_specifics_data); | |
| 82 | |
| 83 // Sub-protocol of NigoriSpecifics. | |
| 84 | |
| 85 base::DictionaryValue* DeviceInformationToValue( | |
| 86 const sync_pb::DeviceInformation& device_information); | |
| 87 | |
| 88 // Main *SpecificsToValue functions. | |
| 89 | |
| 90 base::DictionaryValue* AppNotificationToValue( | |
| 91 const sync_pb::AppNotification& app_notification_specifics); | |
| 92 | |
| 93 base::DictionaryValue* AppSettingSpecificsToValue( | |
| 94 const sync_pb::AppSettingSpecifics& app_setting_specifics); | |
| 95 | |
| 96 base::DictionaryValue* AppSpecificsToValue( | |
| 97 const sync_pb::AppSpecifics& app_specifics); | |
| 98 | |
| 99 base::DictionaryValue* AutofillSpecificsToValue( | |
| 100 const sync_pb::AutofillSpecifics& autofill_specifics); | |
| 101 | |
| 102 base::DictionaryValue* AutofillProfileSpecificsToValue( | |
| 103 const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics); | |
| 104 | |
| 105 base::DictionaryValue* BookmarkSpecificsToValue( | |
| 106 const sync_pb::BookmarkSpecifics& bookmark_specifics); | |
| 107 | |
| 108 base::DictionaryValue* ExtensionSettingSpecificsToValue( | |
| 109 const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics); | |
| 110 | |
| 111 base::DictionaryValue* ExtensionSpecificsToValue( | |
| 112 const sync_pb::ExtensionSpecifics& extension_specifics); | |
| 113 | |
| 114 base::DictionaryValue* NigoriSpecificsToValue( | |
| 115 const sync_pb::NigoriSpecifics& nigori_specifics); | |
| 116 | |
| 117 base::DictionaryValue* PasswordSpecificsToValue( | |
| 118 const sync_pb::PasswordSpecifics& password_specifics); | |
| 119 | |
| 120 base::DictionaryValue* PreferenceSpecificsToValue( | |
| 121 const sync_pb::PreferenceSpecifics& password_specifics); | |
| 122 | |
| 123 base::DictionaryValue* SearchEngineSpecificsToValue( | |
| 124 const sync_pb::SearchEngineSpecifics& search_engine_specifics); | |
| 125 | |
| 126 base::DictionaryValue* SessionSpecificsToValue( | |
| 127 const sync_pb::SessionSpecifics& session_specifics); | |
| 128 | |
| 129 base::DictionaryValue* ThemeSpecificsToValue( | |
| 130 const sync_pb::ThemeSpecifics& theme_specifics); | |
| 131 | |
| 132 base::DictionaryValue* TypedUrlSpecificsToValue( | |
| 133 const sync_pb::TypedUrlSpecifics& typed_url_specifics); | |
| 134 | |
| 135 // Any present extensions are mapped to sub-dictionary values with the | |
| 136 // key equal to the extension name. | |
| 137 base::DictionaryValue* EntitySpecificsToValue( | |
| 138 const sync_pb::EntitySpecifics& specifics); | |
| 139 | |
| 140 } // namespace browser_sync | |
| 141 | |
| 142 #endif // CHROME_BROWSER_SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_ | |
| OLD | NEW |