1// Copyright (c) 2011 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
11class DictionaryValue;
12
13namespace sync_pb {
14class AppSpecifics;
15class AutofillCreditCardSpecifics;
16class AutofillProfileSpecifics;
17class AutofillSpecifics;
18class BookmarkSpecifics;
19class EncryptedData;
20class EntitySpecifics;
21class ExtensionSpecifics;
22class NigoriSpecifics;
23class PasswordSpecifics;
24class PasswordSpecificsData;
25class PreferenceSpecifics;
26class SessionHeader;
27class SessionSpecifics;
28class SessionTab;
29class SessionWindow;
30class TabNavigation;
31class ThemeSpecifics;
32class TypedUrlSpecifics;
33}  // namespace sync_pb
34
35// Utility functions to convert sync protocol buffers to dictionaries.
36// Each protocol field is mapped to a key of the same name.  Repeated
37// fields are mapped to array values and sub-messages are mapped to
38// sub-dictionary values.
39//
40// TODO(akalin): Add has_* information.
41//
42// TODO(akalin): Improve enum support.
43
44namespace browser_sync {
45
46// Ownership of all returned DictionaryValues are transferred to the
47// caller.
48
49// TODO(akalin): Perhaps extend this to decrypt?
50DictionaryValue* EncryptedDataToValue(
51    const sync_pb::EncryptedData& encrypted_data);
52
53// Sub-protocols of SessionSpecifics.
54
55DictionaryValue* SessionHeaderToValue(
56    const sync_pb::SessionHeader& session_header);
57
58DictionaryValue* SessionTabToValue(
59    const sync_pb::SessionTab& session_tab);
60
61DictionaryValue* SessionWindowToValue(
62    const sync_pb::SessionWindow& session_window);
63
64DictionaryValue* TabNavigationToValue(
65    const sync_pb::TabNavigation& tab_navigation);
66
67// Sub-protocol of PasswordSpecifics.
68
69DictionaryValue* PasswordSpecificsDataToValue(
70    const sync_pb::PasswordSpecificsData& password_specifics_data);
71
72// Main *SpecificsToValue functions.
73
74DictionaryValue* AppSpecificsToValue(
75    const sync_pb::AppSpecifics& app_specifics);
76
77DictionaryValue* AutofillSpecificsToValue(
78    const sync_pb::AutofillSpecifics& autofill_specifics);
79
80DictionaryValue* AutofillCreditCardSpecificsToValue(
81    const sync_pb::AutofillCreditCardSpecifics&
82        autofill_credit_card_specifics);
83
84DictionaryValue* AutofillProfileSpecificsToValue(
85    const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
86
87DictionaryValue* BookmarkSpecificsToValue(
88    const sync_pb::BookmarkSpecifics& bookmark_specifics);
89
90DictionaryValue* ExtensionSpecificsToValue(
91    const sync_pb::ExtensionSpecifics& extension_specifics);
92
93DictionaryValue* NigoriSpecificsToValue(
94    const sync_pb::NigoriSpecifics& nigori_specifics);
95
96DictionaryValue* PasswordSpecificsToValue(
97    const sync_pb::PasswordSpecifics& password_specifics);
98
99DictionaryValue* PreferenceSpecificsToValue(
100    const sync_pb::PreferenceSpecifics& password_specifics);
101
102DictionaryValue* SessionSpecificsToValue(
103    const sync_pb::SessionSpecifics& session_specifics);
104
105DictionaryValue* ThemeSpecificsToValue(
106    const sync_pb::ThemeSpecifics& theme_specifics);
107
108DictionaryValue* TypedUrlSpecificsToValue(
109    const sync_pb::TypedUrlSpecifics& typed_url_specifics);
110
111// Any present extensions are mapped to sub-dictionary values with the
112// key equal to the extension name.
113DictionaryValue* EntitySpecificsToValue(
114    const sync_pb::EntitySpecifics& entity_specifics);
115
116}  // namespace browser_sync
117
118#endif  // CHROME_BROWSER_SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_
119