proto_value_conversions.cc revision ba5b9a6411cb1792fd21f0a078d7a25cd1ceec16
15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// found in the LICENSE file. 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Keep this file in sync with the .proto files in this directory. 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/proto_value_conversions.h" 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include <string> 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/base64.h" 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/basictypes.h" 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/logging.h" 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/strings/string_number_conversions.h" 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "base/values.h" 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/internal_api/public/base/unique_position.h" 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/app_notification_specifics.pb.h" 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/app_setting_specifics.pb.h" 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/app_specifics.pb.h" 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/autofill_specifics.pb.h" 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/bookmark_specifics.pb.h" 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/dictionary_specifics.pb.h" 2353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/encryption.pb.h" 2453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/experiments_specifics.pb.h" 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#include "sync/protocol/extension_setting_specifics.pb.h" 2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "sync/protocol/extension_specifics.pb.h" 2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)#include "sync/protocol/favicon_image_specifics.pb.h" 2853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/favicon_tracking_specifics.pb.h" 29521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)#include "sync/protocol/history_delete_directive_specifics.pb.h" 30e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)#include "sync/protocol/nigori_specifics.pb.h" 3153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/password_specifics.pb.h" 3253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/preference_specifics.pb.h" 3353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/priority_preference_specifics.pb.h" 3453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/proto_enum_conversions.h" 3553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/search_engine_specifics.pb.h" 3653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/session_specifics.pb.h" 3753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/sync.pb.h" 3853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/synced_notification_specifics.pb.h" 3953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/theme_specifics.pb.h" 4053e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/typed_url_specifics.pb.h" 4153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "sync/protocol/unique_position.pb.h" 4253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace syncer { 445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace { 465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Basic Type -> Value functions. 48926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)base::StringValue* MakeInt64Value(int64 x) { 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return new base::StringValue(base::Int64ToString(x)); 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 53926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)// TODO(akalin): Perhaps make JSONWriter support BinaryValue and use 54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)// that instead of a StringValue. 55926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)base::StringValue* MakeBytesValue(const std::string& bytes) { 565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) std::string bytes_base64; 575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (!base::Base64Encode(bytes, &bytes_base64)) { 585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) NOTREACHED(); 595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return new base::StringValue(bytes_base64); 61926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 62926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::StringValue* MakeStringValue(const std::string& str) { 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return new base::StringValue(str); 655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// T is the enum type. 68926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)template <class T> 69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)base::StringValue* MakeEnumValue(T t, const char* (*converter_fn)(T)) { 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return new base::StringValue(converter_fn(t)); 715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// T is the field type, F is either RepeatedField or RepeatedPtrField, 745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// and V is a subclass of Value. 75926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)template <class T, class F, class V> 765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::ListValue* MakeRepeatedValue(const F& fields, V* (*converter_fn)(T)) { 775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::ListValue* list = new base::ListValue(); 78926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) for (typename F::const_iterator it = fields.begin(); it != fields.end(); 795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) ++it) { 805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) list->Append(converter_fn(*it)); 815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return list; 835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace 865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)// Helper macros to reduce the amount of boilerplate. 885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET(field, fn) \ 905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (proto.has_##field()) { \ 915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) value->Set(#field, fn(proto.field())); \ 925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_REP(field, fn) \ 94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) value->Set(#field, MakeRepeatedValue(proto.field(), fn)) 955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_ENUM(field, fn) \ 965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) value->Set(#field, MakeEnumValue(proto.field(), fn)) 97926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_BOOL(field) SET(field, new base::FundamentalValue) 995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_BYTES(field) SET(field, MakeBytesValue) 1005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_INT32(field) SET(field, MakeInt64Value) 1015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_INT32_REP(field) SET_REP(field, MakeInt64Value) 1025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_INT64(field) SET(field, MakeInt64Value) 1035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) 1045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_STR(field) SET(field, new base::StringValue) 1055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define SET_STR_REP(field) \ 1065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) value->Set(#field, \ 1075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) MakeRepeatedValue<const std::string&, \ 1085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) google::protobuf::RepeatedPtrField< \ 109e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) std::string >, \ 1105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::StringValue>(proto.field(), \ 111e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) MakeStringValue)) 112926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#define SET_EXPERIMENT_ENABLED_FIELD(field) \ 113e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) do { \ 114e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) if (proto.has_##field() && \ 115e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) proto.field().has_enabled()) { \ 116e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) value->Set(#field, \ 117926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) new base::FundamentalValue( \ 118e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) proto.field().enabled())); \ 119e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) } \ 120e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) } while (0) 121e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) 122e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)#define SET_FIELD(field, fn) \ 123e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) do { \ 124e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) if (specifics.has_##field()) { \ 125e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) value->Set(#field, fn(specifics.field())); \ 126e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) } \ 127e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) } while (0) 128e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) 129e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)// If you add another macro, don't forget to add an #undef at the end 130e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)// of this file, too. 131e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) 132e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles)base::DictionaryValue* EncryptedDataToValue( 133e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) const sync_pb::EncryptedData& proto) { 134e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 135e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) SET_STR(key_name); 136e52495584422c5edb5b2944981473a2e208da323Torne (Richard Coles) // TODO(akalin): Shouldn't blob be of type bytes instead of string? 1375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BYTES(blob); 1385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 1395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 141926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)base::DictionaryValue* AppSettingsToValue( 142926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) const sync_pb::AppNotificationSettings& proto) { 1435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 1445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(initial_setup_done); 1455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(disabled); 1465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(oauth_client_id); 1475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 148926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 149926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 1505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* SessionHeaderToValue( 1515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::SessionHeader& proto) { 1525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 1535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_REP(window, SessionWindowToValue); 1545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(client_name); 1555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_ENUM(device_type, GetDeviceTypeString); 1565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 1575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* SessionTabToValue(const sync_pb::SessionTab& proto) { 1605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 1615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(tab_id); 1625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(window_id); 163926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_INT32(tab_visual_index); 164926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_INT32(current_navigation_index); 165926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_BOOL(pinned); 166926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_STR(extension_app_id); 167926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_REP(navigation, TabNavigationToValue); 168926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_BYTES(favicon); 169926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_ENUM(favicon_type, GetFaviconTypeString); 170926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_STR(favicon_source); 171926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return value; 1725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* SessionWindowToValue( 1755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::SessionWindow& proto) { 1765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 1775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(window_id); 1785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(selected_tab_index); 1795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32_REP(tab); 1805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_ENUM(browser_type, GetBrowserTypeString); 1815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 1825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 1835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 1845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* TabNavigationToValue( 1855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::TabNavigation& proto) { 1865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 1875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(virtual_url); 1885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(referrer); 1895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(title); 1905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(state); 1915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_ENUM(page_transition, GetPageTransitionString); 1925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_ENUM(redirect_type, GetPageTransitionRedirectTypeString); 193926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_INT32(unique_id); 1945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(timestamp_msec); 1955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(navigation_forward_back); 1965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(navigation_from_address_bar); 1975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(navigation_home_page); 1985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(navigation_chain_start); 1995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(navigation_chain_end); 2005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(global_id); 2015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(search_terms); 2025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(favicon_url); 2035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_ENUM(blocked_state, GetBlockedStateString); 204926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_STR_REP(content_pack_categories); 2055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* PasswordSpecificsDataToValue( 2095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::PasswordSpecificsData& proto) { 2105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(scheme); 2125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(signon_realm); 2135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(origin); 2145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(action); 2155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(username_element); 2165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(username_value); 2175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(password_element); 2185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) value->SetString("password_value", "<redacted>"); 2195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(ssl_valid); 220926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_BOOL(preferred); 2215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(date_created); 2225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(blacklisted); 2235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* GlobalIdDirectiveToValue( 2275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::GlobalIdDirective& proto) { 2285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64_REP(global_id); 2305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(start_time_usec); 2315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(end_time_usec); 2325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* TimeRangeDirectiveToValue( 2365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::TimeRangeDirective& proto) { 2375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(start_time_usec); 2395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(end_time_usec); 2405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* SimpleCollapsedLayoutToValue( 244521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) const sync_pb::SimpleCollapsedLayout& proto) { 2455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(heading); 2475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(description); 2485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2495267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} 2505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* CollapsedInfoToValue( 2525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::CollapsedInfo& proto) { 2535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(simple_collapsed_layout, SimpleCollapsedLayoutToValue); 2555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* RenderInfoToValue( 2595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::SyncedNotificationRenderInfo& proto) { 2605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(collapsed_info, CollapsedInfoToValue); 2625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* CoalescedNotificationToValue( 2665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::CoalescedSyncedNotification& proto) { 2675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(key); 2695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(read_state); 2705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(render_info, RenderInfoToValue); 2715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* AppNotificationToValue( 2755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::AppNotification& proto) { 2765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(guid); 2785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(app_id); 2795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(creation_timestamp_ms); 2805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(title); 2815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(body_text); 2825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(link_url); 2835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(link_text); 2845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 2865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 2875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* AppSettingSpecificsToValue( 2885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::AppSettingSpecifics& proto) { 2895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2905c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(extension_setting, ExtensionSettingSpecificsToValue); 2915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 2925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 293926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 294926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)base::DictionaryValue* AppSpecificsToValue( 2955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::AppSpecifics& proto) { 2965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 2975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(extension, ExtensionSpecificsToValue); 2985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(notification_settings, AppSettingsToValue); 2995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(app_launch_ordinal); 3005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(page_ordinal); 3015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* AutofillSpecificsToValue( 3065c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::AutofillSpecifics& proto) { 3075c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(name); 3095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(value); 3105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64_REP(usage_timestamp); 3115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(profile, AutofillProfileSpecificsToValue); 3125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* AutofillProfileSpecificsToValue( 3165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::AutofillProfileSpecifics& proto) { 3175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(guid); 3195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(origin); 3205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR_REP(name_first); 3225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR_REP(name_middle); 3235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR_REP(name_last); 3245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR_REP(email_address); 3255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(company_name); 3265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(address_home_line1); 3285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(address_home_line2); 3295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(address_home_city); 3305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(address_home_state); 3315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(address_home_zip); 3325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(address_home_country); 3335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR_REP(phone_home_whole_number); 3355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* BookmarkSpecificsToValue( 3395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::BookmarkSpecifics& proto) { 3405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(url); 3425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BYTES(favicon); 3435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(title); 34493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) SET_INT64(creation_time_us); 3455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(icon_url); 3465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* DeviceInfoSpecificsToValue( 3505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::DeviceInfoSpecifics& proto) { 3515267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3525267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) SET_STR(cache_guid); 3535267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) SET_STR(client_name); 3545267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) SET_ENUM(device_type, GetDeviceTypeString); 3555267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) SET_STR(sync_user_agent); 3565267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) SET_STR(chrome_version); 3575267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) return value; 3585267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)} 3595267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 3605267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)base::DictionaryValue* DictionarySpecificsToValue( 3615267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) const sync_pb::DictionarySpecifics& proto) { 3625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(word); 3645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace { 3685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* FaviconSyncFlagsToValue( 3705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::FaviconSyncFlags& proto) { 3715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(enabled); 3735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(favicon_sync_limit); 3745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace 3785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* ExperimentsSpecificsToValue( 3805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::ExperimentsSpecifics& proto) { 3815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption); 3835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives); 3845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_EXPERIMENT_ENABLED_FIELD(autofill_culling); 3855c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_EXPERIMENT_ENABLED_FIELD(pre_commit_update_avoidance); 3865c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) if (proto.has_favicon_sync()) 3875c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(favicon_sync, FaviconSyncFlagsToValue); 3885c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3895c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3905267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 3915c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* ExtensionSettingSpecificsToValue( 3925c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::ExtensionSettingSpecifics& proto) { 3935c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 3945c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(extension_id); 3955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(key); 3965c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(value); 3975c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 3985c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 3995c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4005c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* ExtensionSpecificsToValue( 4015c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::ExtensionSpecifics& proto) { 4025c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 4035c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(id); 4045c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(version); 4055c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(update_url); 40653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) SET_BOOL(enabled); 407926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_BOOL(incognito_enabled); 4085c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(name); 4095c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 4105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)namespace { 4135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* FaviconDataToValue( 4145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::FaviconData& proto) { 4155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 4165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BYTES(favicon); 4175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(width); 4185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT32(height); 4195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 4205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} // namespace 4225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* FaviconImageSpecificsToValue( 4245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::FaviconImageSpecifics& proto) { 4255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 42653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) SET_STR(favicon_url); 427926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET(favicon_web, FaviconDataToValue); 4285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(favicon_web_32, FaviconDataToValue); 4295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(favicon_touch_64, FaviconDataToValue); 4305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(favicon_touch_precomposed_64, FaviconDataToValue); 4315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 4325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4345c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* FaviconTrackingSpecificsToValue( 4355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::FaviconTrackingSpecifics& proto) { 4365c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 4375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(favicon_url); 4385c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_INT64(last_visit_time_ms) 4395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(is_bookmarked); 4405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 4415c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4425c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 443926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue( 4445c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::HistoryDeleteDirectiveSpecifics& proto) { 4455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 4465c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(global_id_directive, GlobalIdDirectiveToValue); 4475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(time_range_directive, TimeRangeDirectiveToValue); 4485c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 4495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* ManagedUserSettingSpecificsToValue( 4525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::ManagedUserSettingSpecifics& proto) { 4535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 4545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(name); 4555c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(value); 4565c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 4575c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4585c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4595c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* ManagedUserSpecificsToValue( 4605c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::ManagedUserSpecifics& proto) { 4615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 4625c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(id); 4635c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_STR(name); 4645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(acknowledged); 4655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) return value; 4665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)} 4675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 4685c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* NigoriSpecificsToValue( 4695c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) const sync_pb::NigoriSpecifics& proto) { 4705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) base::DictionaryValue* value = new base::DictionaryValue(); 4715c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET(encryption_keybag, EncryptedDataToValue); 4725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(keybag_is_frozen); 4735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_bookmarks); 4745c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_preferences); 4755c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_autofill_profile); 4765c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_autofill); 4775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_themes); 4785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_typed_urls); 4795c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_extension_settings); 4805c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_extensions); 4815c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_sessions); 4825c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_app_settings); 4835c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_apps); 4845c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) SET_BOOL(encrypt_search_engines); 485926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_BOOL(encrypt_dictionary); 486926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_BOOL(encrypt_everything); 487521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) SET_BOOL(sync_tab_favicons); 488521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) SET_ENUM(passphrase_type, PassphraseTypeString); 489926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET(keystore_decryptor_token, EncryptedDataToValue); 490926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_INT64(keystore_migration_time); 491926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) SET_INT64(custom_passphrase_time); 492926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) return value; 493926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)} 494926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 4955c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)base::DictionaryValue* PasswordSpecificsToValue( 496 const sync_pb::PasswordSpecifics& proto) { 497 base::DictionaryValue* value = new base::DictionaryValue(); 498 SET(encrypted, EncryptedDataToValue); 499 return value; 500} 501 502base::DictionaryValue* PreferenceSpecificsToValue( 503 const sync_pb::PreferenceSpecifics& proto) { 504 base::DictionaryValue* value = new base::DictionaryValue(); 505 SET_STR(name); 506 SET_STR(value); 507 return value; 508} 509 510base::DictionaryValue* PriorityPreferenceSpecificsToValue( 511 const sync_pb::PriorityPreferenceSpecifics& specifics) { 512 base::DictionaryValue* value = new base::DictionaryValue(); 513 SET_FIELD(preference, PreferenceSpecificsToValue); 514 return value; 515} 516 517base::DictionaryValue* SyncedNotificationSpecificsToValue( 518 const sync_pb::SyncedNotificationSpecifics& proto) { 519 // There is a lot of data, for now just use heading, description, key, and 520 // the read state. 521 // TODO(petewil): Eventually add more data here. 522 base::DictionaryValue* value = new base::DictionaryValue(); 523 SET(coalesced_notification, CoalescedNotificationToValue); 524 return value; 525} 526 527base::DictionaryValue* SearchEngineSpecificsToValue( 528 const sync_pb::SearchEngineSpecifics& proto) { 529 base::DictionaryValue* value = new base::DictionaryValue(); 530 SET_STR(short_name); 531 SET_STR(keyword); 532 SET_STR(favicon_url); 533 SET_STR(url); 534 SET_BOOL(safe_for_autoreplace); 535 SET_STR(originating_url); 536 SET_INT64(date_created); 537 SET_STR(input_encodings); 538 SET_BOOL(show_in_default_list); 539 SET_STR(suggestions_url); 540 SET_INT32(prepopulate_id); 541 SET_BOOL(autogenerate_keyword); 542 SET_STR(instant_url); 543 SET_INT64(last_modified); 544 SET_STR(sync_guid); 545 SET_STR_REP(alternate_urls); 546 SET_STR(search_terms_replacement_key); 547 SET_STR(image_url); 548 SET_STR(search_url_post_params); 549 SET_STR(suggestions_url_post_params); 550 SET_STR(instant_url_post_params); 551 SET_STR(image_url_post_params); 552 return value; 553} 554 555base::DictionaryValue* SessionSpecificsToValue( 556 const sync_pb::SessionSpecifics& proto) { 557 base::DictionaryValue* value = new base::DictionaryValue(); 558 SET_STR(session_tag); 559 SET(header, SessionHeaderToValue); 560 SET(tab, SessionTabToValue); 561 SET_INT32(tab_node_id); 562 return value; 563} 564 565base::DictionaryValue* ThemeSpecificsToValue( 566 const sync_pb::ThemeSpecifics& proto) { 567 base::DictionaryValue* value = new base::DictionaryValue(); 568 SET_BOOL(use_custom_theme); 569 SET_BOOL(use_system_theme_by_default); 570 SET_STR(custom_theme_name); 571 SET_STR(custom_theme_id); 572 SET_STR(custom_theme_update_url); 573 return value; 574} 575 576base::DictionaryValue* TypedUrlSpecificsToValue( 577 const sync_pb::TypedUrlSpecifics& proto) { 578 base::DictionaryValue* value = new base::DictionaryValue(); 579 SET_STR(url); 580 SET_STR(title); 581 SET_BOOL(hidden); 582 SET_INT64_REP(visits); 583 SET_INT32_REP(visit_transitions); 584 return value; 585} 586 587base::DictionaryValue* EntitySpecificsToValue( 588 const sync_pb::EntitySpecifics& specifics) { 589 base::DictionaryValue* value = new base::DictionaryValue(); 590 SET_FIELD(app, AppSpecificsToValue); 591 SET_FIELD(app_notification, AppNotificationToValue); 592 SET_FIELD(app_setting, AppSettingSpecificsToValue); 593 SET_FIELD(autofill, AutofillSpecificsToValue); 594 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); 595 SET_FIELD(bookmark, BookmarkSpecificsToValue); 596 SET_FIELD(device_info, DeviceInfoSpecificsToValue); 597 SET_FIELD(dictionary, DictionarySpecificsToValue); 598 SET_FIELD(experiments, ExperimentsSpecificsToValue); 599 SET_FIELD(extension, ExtensionSpecificsToValue); 600 SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); 601 SET_FIELD(favicon_image, FaviconImageSpecificsToValue); 602 SET_FIELD(favicon_tracking, FaviconTrackingSpecificsToValue); 603 SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); 604 SET_FIELD(managed_user_setting, ManagedUserSettingSpecificsToValue); 605 SET_FIELD(managed_user, ManagedUserSpecificsToValue); 606 SET_FIELD(nigori, NigoriSpecificsToValue); 607 SET_FIELD(password, PasswordSpecificsToValue); 608 SET_FIELD(preference, PreferenceSpecificsToValue); 609 SET_FIELD(priority_preference, PriorityPreferenceSpecificsToValue); 610 SET_FIELD(search_engine, SearchEngineSpecificsToValue); 611 SET_FIELD(session, SessionSpecificsToValue); 612 SET_FIELD(synced_notification, SyncedNotificationSpecificsToValue); 613 SET_FIELD(theme, ThemeSpecificsToValue); 614 SET_FIELD(typed_url, TypedUrlSpecificsToValue); 615 return value; 616} 617 618namespace { 619 620base::StringValue* UniquePositionToStringValue( 621 const sync_pb::UniquePosition& proto) { 622 UniquePosition pos = UniquePosition::FromProto(proto); 623 return new base::StringValue(pos.ToDebugString()); 624} 625 626base::DictionaryValue* SyncEntityToValue(const sync_pb::SyncEntity& proto, 627 bool include_specifics) { 628 base::DictionaryValue* value = new base::DictionaryValue(); 629 SET_STR(id_string); 630 SET_STR(parent_id_string); 631 SET_STR(old_parent_id); 632 SET_INT64(version); 633 SET_INT64(mtime); 634 SET_INT64(ctime); 635 SET_STR(name); 636 SET_STR(non_unique_name); 637 SET_INT64(sync_timestamp); 638 SET_STR(server_defined_unique_tag); 639 SET_INT64(position_in_parent); 640 SET(unique_position, UniquePositionToStringValue); 641 SET_STR(insert_after_item_id); 642 SET_BOOL(deleted); 643 SET_STR(originator_cache_guid); 644 SET_STR(originator_client_item_id); 645 if (include_specifics) 646 SET(specifics, EntitySpecificsToValue); 647 SET_BOOL(folder); 648 SET_STR(client_defined_unique_tag); 649 return value; 650} 651 652base::ListValue* SyncEntitiesToValue( 653 const ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>& entities, 654 bool include_specifics) { 655 base::ListValue* list = new base::ListValue(); 656 ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it; 657 for (it = entities.begin(); it != entities.end(); ++it) { 658 list->Append(SyncEntityToValue(*it, include_specifics)); 659 } 660 661 return list; 662} 663 664base::DictionaryValue* ChromiumExtensionActivityToValue( 665 const sync_pb::ChromiumExtensionsActivity& proto) { 666 base::DictionaryValue* value = new base::DictionaryValue(); 667 SET_STR(extension_id); 668 SET_INT32(bookmark_writes_since_last_commit); 669 return value; 670} 671 672base::DictionaryValue* CommitMessageToValue( 673 const sync_pb::CommitMessage& proto, 674 bool include_specifics) { 675 base::DictionaryValue* value = new base::DictionaryValue(); 676 value->Set("entries", 677 SyncEntitiesToValue(proto.entries(), include_specifics)); 678 SET_STR(cache_guid); 679 SET_REP(extensions_activity, ChromiumExtensionActivityToValue); 680 SET(config_params, ClientConfigParamsToValue); 681 return value; 682} 683 684base::DictionaryValue* GetUpdateTriggersToValue( 685 const sync_pb::GetUpdateTriggers& proto) { 686 base::DictionaryValue* value = new base::DictionaryValue(); 687 SET_STR_REP(notification_hint); 688 SET_BOOL(client_dropped_hints); 689 SET_BOOL(invalidations_out_of_sync); 690 SET_INT64(local_modification_nudges); 691 SET_INT64(datatype_refresh_nudges); 692 return value; 693} 694 695base::DictionaryValue* DataTypeProgressMarkerToValue( 696 const sync_pb::DataTypeProgressMarker& proto) { 697 base::DictionaryValue* value = new base::DictionaryValue(); 698 SET_INT32(data_type_id); 699 SET_BYTES(token); 700 SET_INT64(timestamp_token_for_migration); 701 SET_STR(notification_hint); 702 SET(get_update_triggers, GetUpdateTriggersToValue); 703 return value; 704} 705 706base::DictionaryValue* GetUpdatesCallerInfoToValue( 707 const sync_pb::GetUpdatesCallerInfo& proto) { 708 base::DictionaryValue* value = new base::DictionaryValue(); 709 SET_ENUM(source, GetUpdatesSourceString); 710 SET_BOOL(notifications_enabled); 711 return value; 712} 713 714base::DictionaryValue* GetUpdatesMessageToValue( 715 const sync_pb::GetUpdatesMessage& proto) { 716 base::DictionaryValue* value = new base::DictionaryValue(); 717 SET(caller_info, GetUpdatesCallerInfoToValue); 718 SET_BOOL(fetch_folders); 719 SET_INT32(batch_size); 720 SET_REP(from_progress_marker, DataTypeProgressMarkerToValue); 721 SET_BOOL(streaming); 722 SET_BOOL(need_encryption_key); 723 SET_BOOL(create_mobile_bookmarks_folder); 724 SET_ENUM(get_updates_origin, GetUpdatesOriginString); 725 return value; 726} 727 728base::DictionaryValue* ClientStatusToValue(const sync_pb::ClientStatus& proto) { 729 base::DictionaryValue* value = new base::DictionaryValue(); 730 SET_BOOL(hierarchy_conflict_detected); 731 return value; 732} 733 734base::DictionaryValue* EntryResponseToValue( 735 const sync_pb::CommitResponse::EntryResponse& proto) { 736 base::DictionaryValue* value = new base::DictionaryValue(); 737 SET_ENUM(response_type, GetResponseTypeString); 738 SET_STR(id_string); 739 SET_STR(parent_id_string); 740 SET_INT64(position_in_parent); 741 SET_INT64(version); 742 SET_STR(name); 743 SET_STR(error_message); 744 SET_INT64(mtime); 745 return value; 746} 747 748base::DictionaryValue* CommitResponseToValue( 749 const sync_pb::CommitResponse& proto) { 750 base::DictionaryValue* value = new base::DictionaryValue(); 751 SET_REP(entryresponse, EntryResponseToValue); 752 return value; 753} 754 755base::DictionaryValue* GetUpdatesResponseToValue( 756 const sync_pb::GetUpdatesResponse& proto, 757 bool include_specifics) { 758 base::DictionaryValue* value = new base::DictionaryValue(); 759 value->Set("entries", 760 SyncEntitiesToValue(proto.entries(), include_specifics)); 761 SET_INT64(changes_remaining); 762 SET_REP(new_progress_marker, DataTypeProgressMarkerToValue); 763 return value; 764} 765 766base::DictionaryValue* ClientCommandToValue( 767 const sync_pb::ClientCommand& proto) { 768 base::DictionaryValue* value = new base::DictionaryValue(); 769 SET_INT32(set_sync_poll_interval); 770 SET_INT32(set_sync_long_poll_interval); 771 SET_INT32(max_commit_batch_size); 772 SET_INT32(sessions_commit_delay_seconds); 773 SET_INT32(throttle_delay_seconds); 774 SET_INT32(client_invalidation_hint_buffer_size); 775 return value; 776} 777 778base::DictionaryValue* ErrorToValue( 779 const sync_pb::ClientToServerResponse::Error& proto) { 780 base::DictionaryValue* value = new base::DictionaryValue(); 781 SET_ENUM(error_type, GetErrorTypeString); 782 SET_STR(error_description); 783 SET_STR(url); 784 SET_ENUM(action, GetActionString); 785 return value; 786} 787 788} // namespace 789 790base::DictionaryValue* ClientToServerResponseToValue( 791 const sync_pb::ClientToServerResponse& proto, 792 bool include_specifics) { 793 base::DictionaryValue* value = new base::DictionaryValue(); 794 SET(commit, CommitResponseToValue); 795 if (proto.has_get_updates()) { 796 value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(), 797 include_specifics)); 798 } 799 800 SET(error, ErrorToValue); 801 SET_ENUM(error_code, GetErrorTypeString); 802 SET_STR(error_message); 803 SET_STR(store_birthday); 804 SET(client_command, ClientCommandToValue); 805 SET_INT32_REP(migrated_data_type_id); 806 return value; 807} 808 809base::DictionaryValue* ClientToServerMessageToValue( 810 const sync_pb::ClientToServerMessage& proto, 811 bool include_specifics) { 812 base::DictionaryValue* value = new base::DictionaryValue(); 813 SET_STR(share); 814 SET_INT32(protocol_version); 815 if (proto.has_commit()) { 816 value->Set("commit", 817 CommitMessageToValue(proto.commit(), include_specifics)); 818 } 819 820 SET(get_updates, GetUpdatesMessageToValue); 821 SET_STR(store_birthday); 822 SET_BOOL(sync_problem_detected); 823 SET(debug_info, DebugInfoToValue); 824 SET(client_status, ClientStatusToValue); 825 return value; 826} 827 828base::DictionaryValue* DatatypeAssociationStatsToValue( 829 const sync_pb::DatatypeAssociationStats& proto) { 830 base::DictionaryValue* value = new base::DictionaryValue(); 831 SET_INT32(data_type_id); 832 SET_INT32(num_local_items_before_association); 833 SET_INT32(num_sync_items_before_association); 834 SET_INT32(num_local_items_after_association); 835 SET_INT32(num_sync_items_after_association); 836 SET_INT32(num_local_items_added); 837 SET_INT32(num_local_items_deleted); 838 SET_INT32(num_local_items_modified); 839 SET_INT32(num_sync_items_added); 840 SET_INT32(num_sync_items_deleted); 841 SET_INT32(num_sync_items_modified); 842 SET_INT64(local_version_pre_association); 843 SET_INT64(sync_version_pre_association) 844 SET_BOOL(had_error); 845 SET_INT64(download_wait_time_us); 846 SET_INT64(download_time_us); 847 SET_INT64(association_wait_time_for_high_priority_us); 848 SET_INT64(association_wait_time_for_same_priority_us); 849 return value; 850} 851 852base::DictionaryValue* DebugEventInfoToValue( 853 const sync_pb::DebugEventInfo& proto) { 854 base::DictionaryValue* value = new base::DictionaryValue(); 855 SET_ENUM(singleton_event, SingletonEventTypeString); 856 SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue); 857 SET_INT32(nudging_datatype); 858 SET_INT32_REP(datatypes_notified_from_server); 859 SET(datatype_association_stats, DatatypeAssociationStatsToValue); 860 return value; 861} 862 863base::DictionaryValue* DebugInfoToValue(const sync_pb::DebugInfo& proto) { 864 base::DictionaryValue* value = new base::DictionaryValue(); 865 SET_REP(events, DebugEventInfoToValue); 866 SET_BOOL(cryptographer_ready); 867 SET_BOOL(cryptographer_has_pending_keys); 868 SET_BOOL(events_dropped); 869 return value; 870} 871 872base::DictionaryValue* SyncCycleCompletedEventInfoToValue( 873 const sync_pb::SyncCycleCompletedEventInfo& proto) { 874 base::DictionaryValue* value = new base::DictionaryValue(); 875 SET_INT32(num_encryption_conflicts); 876 SET_INT32(num_hierarchy_conflicts); 877 SET_INT32(num_server_conflicts); 878 SET_INT32(num_updates_downloaded); 879 SET_INT32(num_reflected_updates_downloaded); 880 SET(caller_info, GetUpdatesCallerInfoToValue); 881 return value; 882} 883 884base::DictionaryValue* ClientConfigParamsToValue( 885 const sync_pb::ClientConfigParams& proto) { 886 base::DictionaryValue* value = new base::DictionaryValue(); 887 SET_INT32_REP(enabled_type_ids); 888 SET_BOOL(tabs_datatype_enabled); 889 return value; 890} 891 892#undef SET 893#undef SET_REP 894 895#undef SET_BOOL 896#undef SET_BYTES 897#undef SET_INT32 898#undef SET_INT64 899#undef SET_INT64_REP 900#undef SET_STR 901#undef SET_STR_REP 902 903#undef SET_FIELD 904 905} // namespace syncer 906