Home | History | Annotate | Download | only in protocol
      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 
     11 class DictionaryValue;
     12 
     13 namespace sync_pb {
     14 class AppSpecifics;
     15 class AutofillCreditCardSpecifics;
     16 class AutofillProfileSpecifics;
     17 class AutofillSpecifics;
     18 class BookmarkSpecifics;
     19 class EncryptedData;
     20 class EntitySpecifics;
     21 class ExtensionSpecifics;
     22 class NigoriSpecifics;
     23 class PasswordSpecifics;
     24 class PasswordSpecificsData;
     25 class PreferenceSpecifics;
     26 class SessionHeader;
     27 class SessionSpecifics;
     28 class SessionTab;
     29 class SessionWindow;
     30 class TabNavigation;
     31 class ThemeSpecifics;
     32 class 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 
     44 namespace browser_sync {
     45 
     46 // Ownership of all returned DictionaryValues are transferred to the
     47 // caller.
     48 
     49 // TODO(akalin): Perhaps extend this to decrypt?
     50 DictionaryValue* EncryptedDataToValue(
     51     const sync_pb::EncryptedData& encrypted_data);
     52 
     53 // Sub-protocols of SessionSpecifics.
     54 
     55 DictionaryValue* SessionHeaderToValue(
     56     const sync_pb::SessionHeader& session_header);
     57 
     58 DictionaryValue* SessionTabToValue(
     59     const sync_pb::SessionTab& session_tab);
     60 
     61 DictionaryValue* SessionWindowToValue(
     62     const sync_pb::SessionWindow& session_window);
     63 
     64 DictionaryValue* TabNavigationToValue(
     65     const sync_pb::TabNavigation& tab_navigation);
     66 
     67 // Sub-protocol of PasswordSpecifics.
     68 
     69 DictionaryValue* PasswordSpecificsDataToValue(
     70     const sync_pb::PasswordSpecificsData& password_specifics_data);
     71 
     72 // Main *SpecificsToValue functions.
     73 
     74 DictionaryValue* AppSpecificsToValue(
     75     const sync_pb::AppSpecifics& app_specifics);
     76 
     77 DictionaryValue* AutofillSpecificsToValue(
     78     const sync_pb::AutofillSpecifics& autofill_specifics);
     79 
     80 DictionaryValue* AutofillCreditCardSpecificsToValue(
     81     const sync_pb::AutofillCreditCardSpecifics&
     82         autofill_credit_card_specifics);
     83 
     84 DictionaryValue* AutofillProfileSpecificsToValue(
     85     const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
     86 
     87 DictionaryValue* BookmarkSpecificsToValue(
     88     const sync_pb::BookmarkSpecifics& bookmark_specifics);
     89 
     90 DictionaryValue* ExtensionSpecificsToValue(
     91     const sync_pb::ExtensionSpecifics& extension_specifics);
     92 
     93 DictionaryValue* NigoriSpecificsToValue(
     94     const sync_pb::NigoriSpecifics& nigori_specifics);
     95 
     96 DictionaryValue* PasswordSpecificsToValue(
     97     const sync_pb::PasswordSpecifics& password_specifics);
     98 
     99 DictionaryValue* PreferenceSpecificsToValue(
    100     const sync_pb::PreferenceSpecifics& password_specifics);
    101 
    102 DictionaryValue* SessionSpecificsToValue(
    103     const sync_pb::SessionSpecifics& session_specifics);
    104 
    105 DictionaryValue* ThemeSpecificsToValue(
    106     const sync_pb::ThemeSpecifics& theme_specifics);
    107 
    108 DictionaryValue* 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.
    113 DictionaryValue* 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