| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // Keep this file in sync with the .proto files in this directory. | 5 // Keep this file in sync with the .proto files in this directory. |
| 6 | 6 |
| 7 #include "sync/protocol/proto_value_conversions.h" | 7 #include "sync/protocol/proto_value_conversions.h" |
| 8 | 8 |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/base64.h" | 14 #include "base/base64.h" |
| 15 #include "base/i18n/time_formatting.h" | 15 #include "base/i18n/time_formatting.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/ptr_util.h" |
| 17 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "base/values.h" | 20 #include "base/values.h" |
| 20 #include "sync/internal_api/public/base/unique_position.h" | 21 #include "sync/internal_api/public/base/unique_position.h" |
| 21 #include "sync/protocol/app_list_specifics.pb.h" | 22 #include "sync/protocol/app_list_specifics.pb.h" |
| 22 #include "sync/protocol/app_notification_specifics.pb.h" | 23 #include "sync/protocol/app_notification_specifics.pb.h" |
| 23 #include "sync/protocol/app_setting_specifics.pb.h" | 24 #include "sync/protocol/app_setting_specifics.pb.h" |
| 24 #include "sync/protocol/app_specifics.pb.h" | 25 #include "sync/protocol/app_specifics.pb.h" |
| 25 #include "sync/protocol/autofill_specifics.pb.h" | 26 #include "sync/protocol/autofill_specifics.pb.h" |
| 26 #include "sync/protocol/bookmark_specifics.pb.h" | 27 #include "sync/protocol/bookmark_specifics.pb.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 44 #include "sync/protocol/typed_url_specifics.pb.h" | 45 #include "sync/protocol/typed_url_specifics.pb.h" |
| 45 #include "sync/protocol/unique_position.pb.h" | 46 #include "sync/protocol/unique_position.pb.h" |
| 46 #include "sync/util/time.h" | 47 #include "sync/util/time.h" |
| 47 | 48 |
| 48 namespace syncer { | 49 namespace syncer { |
| 49 | 50 |
| 50 namespace { | 51 namespace { |
| 51 | 52 |
| 52 // Basic Type -> Value functions. | 53 // Basic Type -> Value functions. |
| 53 | 54 |
| 54 scoped_ptr<base::StringValue> MakeInt64Value(int64_t x) { | 55 std::unique_ptr<base::StringValue> MakeInt64Value(int64_t x) { |
| 55 return make_scoped_ptr(new base::StringValue(base::Int64ToString(x))); | 56 return base::WrapUnique(new base::StringValue(base::Int64ToString(x))); |
| 56 } | 57 } |
| 57 | 58 |
| 58 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use | 59 // TODO(akalin): Perhaps make JSONWriter support BinaryValue and use |
| 59 // that instead of a StringValue. | 60 // that instead of a StringValue. |
| 60 std::string Base64EncodeString(const std::string& bytes) { | 61 std::string Base64EncodeString(const std::string& bytes) { |
| 61 std::string bytes_base64; | 62 std::string bytes_base64; |
| 62 base::Base64Encode(bytes, &bytes_base64); | 63 base::Base64Encode(bytes, &bytes_base64); |
| 63 return bytes_base64; | 64 return bytes_base64; |
| 64 } | 65 } |
| 65 | 66 |
| 66 scoped_ptr<base::StringValue> MakeStringValue(const std::string& str) { | 67 std::unique_ptr<base::StringValue> MakeStringValue(const std::string& str) { |
| 67 return make_scoped_ptr(new base::StringValue(str)); | 68 return base::WrapUnique(new base::StringValue(str)); |
| 68 } | 69 } |
| 69 | 70 |
| 70 // T is the field type, F is either RepeatedField or RepeatedPtrField, | 71 // T is the field type, F is either RepeatedField or RepeatedPtrField, |
| 71 // and V is a subclass of Value. | 72 // and V is a subclass of Value. |
| 72 template <class T, class F, class V> | 73 template <class T, class F, class V> |
| 73 scoped_ptr<base::ListValue> MakeRepeatedValue(const F& fields, | 74 std::unique_ptr<base::ListValue> MakeRepeatedValue(const F& fields, |
| 74 V (*converter_fn)(T)) { | 75 V (*converter_fn)(T)) { |
| 75 scoped_ptr<base::ListValue> list(new base::ListValue()); | 76 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
| 76 for (typename F::const_iterator it = fields.begin(); it != fields.end(); | 77 for (typename F::const_iterator it = fields.begin(); it != fields.end(); |
| 77 ++it) { | 78 ++it) { |
| 78 list->Append(converter_fn(*it)); | 79 list->Append(converter_fn(*it)); |
| 79 } | 80 } |
| 80 return list; | 81 return list; |
| 81 } | 82 } |
| 82 | 83 |
| 83 } // namespace | 84 } // namespace |
| 84 | 85 |
| 85 // Helper macros to reduce the amount of boilerplate. | 86 // Helper macros to reduce the amount of boilerplate. |
| 86 | 87 |
| 87 #define SET_TYPE(field, set_fn, transform) \ | 88 #define SET_TYPE(field, set_fn, transform) \ |
| 88 if (proto.has_##field()) { \ | 89 if (proto.has_##field()) { \ |
| 89 value->set_fn(#field, transform(proto.field())); \ | 90 value->set_fn(#field, transform(proto.field())); \ |
| 90 } | 91 } |
| 91 #define SET(field, fn) SET_TYPE(field, Set, fn) | 92 #define SET(field, fn) SET_TYPE(field, Set, fn) |
| 92 #define SET_REP(field, fn) \ | 93 #define SET_REP(field, fn) \ |
| 93 value->Set(#field, MakeRepeatedValue(proto.field(), fn)) | 94 value->Set(#field, MakeRepeatedValue(proto.field(), fn)) |
| 94 #define SET_ENUM(field, fn) SET_TYPE(field, SetString, fn) | 95 #define SET_ENUM(field, fn) SET_TYPE(field, SetString, fn) |
| 95 | 96 |
| 96 #define SET_BOOL(field) SET_TYPE(field, SetBoolean, ) | 97 #define SET_BOOL(field) SET_TYPE(field, SetBoolean, ) |
| 97 #define SET_BYTES(field) SET_TYPE(field, SetString, Base64EncodeString) | 98 #define SET_BYTES(field) SET_TYPE(field, SetString, Base64EncodeString) |
| 98 #define SET_INT32(field) SET_TYPE(field, SetString, base::Int64ToString) | 99 #define SET_INT32(field) SET_TYPE(field, SetString, base::Int64ToString) |
| 99 #define SET_INT32_REP(field) SET_REP(field, MakeInt64Value) | 100 #define SET_INT32_REP(field) SET_REP(field, MakeInt64Value) |
| 100 #define SET_INT64(field) SET_TYPE(field, SetString, base::Int64ToString) | 101 #define SET_INT64(field) SET_TYPE(field, SetString, base::Int64ToString) |
| 101 #define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) | 102 #define SET_INT64_REP(field) SET_REP(field, MakeInt64Value) |
| 102 #define SET_STR(field) SET_TYPE(field, SetString, ) | 103 #define SET_STR(field) SET_TYPE(field, SetString, ) |
| 103 #define SET_TIME_STR(field) SET_TYPE(field, SetString, TimestampToString) | 104 #define SET_TIME_STR(field) SET_TYPE(field, SetString, TimestampToString) |
| 104 #define SET_STR_REP(field) \ | 105 #define SET_STR_REP(field) \ |
| 105 value->Set( \ | 106 value->Set( \ |
| 106 #field, \ | 107 #field, \ |
| 107 MakeRepeatedValue<const std::string&, \ | 108 MakeRepeatedValue<const std::string&, \ |
| 108 google::protobuf::RepeatedPtrField<std::string>, \ | 109 google::protobuf::RepeatedPtrField<std::string>, \ |
| 109 scoped_ptr<base::StringValue>>(proto.field(), \ | 110 std::unique_ptr<base::StringValue>>(proto.field(), \ |
| 110 MakeStringValue)) | 111 MakeStringValue)) |
| 111 #define SET_EXPERIMENT_ENABLED_FIELD(field) \ | 112 #define SET_EXPERIMENT_ENABLED_FIELD(field) \ |
| 112 do { \ | 113 do { \ |
| 113 if (proto.has_##field() && \ | 114 if (proto.has_##field() && \ |
| 114 proto.field().has_enabled()) { \ | 115 proto.field().has_enabled()) { \ |
| 115 value->Set(#field, \ | 116 value->Set(#field, \ |
| 116 new base::FundamentalValue( \ | 117 new base::FundamentalValue( \ |
| 117 proto.field().enabled())); \ | 118 proto.field().enabled())); \ |
| 118 } \ | 119 } \ |
| 119 } while (0) | 120 } while (0) |
| 120 | 121 |
| 121 #define SET_FIELD(field, fn) \ | 122 #define SET_FIELD(field, fn) \ |
| 122 do { \ | 123 do { \ |
| 123 if (specifics.has_##field()) { \ | 124 if (specifics.has_##field()) { \ |
| 124 value->Set(#field, fn(specifics.field())); \ | 125 value->Set(#field, fn(specifics.field())); \ |
| 125 } \ | 126 } \ |
| 126 } while (0) | 127 } while (0) |
| 127 | 128 |
| 128 // If you add another macro, don't forget to add an #undef at the end | 129 // If you add another macro, don't forget to add an #undef at the end |
| 129 // of this file, too. | 130 // of this file, too. |
| 130 | 131 |
| 131 scoped_ptr<base::DictionaryValue> EncryptedDataToValue( | 132 std::unique_ptr<base::DictionaryValue> EncryptedDataToValue( |
| 132 const sync_pb::EncryptedData& proto) { | 133 const sync_pb::EncryptedData& proto) { |
| 133 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 134 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 134 SET_STR(key_name); | 135 SET_STR(key_name); |
| 135 // TODO(akalin): Shouldn't blob be of type bytes instead of string? | 136 // TODO(akalin): Shouldn't blob be of type bytes instead of string? |
| 136 SET_BYTES(blob); | 137 SET_BYTES(blob); |
| 137 return value; | 138 return value; |
| 138 } | 139 } |
| 139 | 140 |
| 140 scoped_ptr<base::DictionaryValue> AppSettingsToValue( | 141 std::unique_ptr<base::DictionaryValue> AppSettingsToValue( |
| 141 const sync_pb::AppNotificationSettings& proto) { | 142 const sync_pb::AppNotificationSettings& proto) { |
| 142 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 143 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 143 SET_BOOL(initial_setup_done); | 144 SET_BOOL(initial_setup_done); |
| 144 SET_BOOL(disabled); | 145 SET_BOOL(disabled); |
| 145 SET_STR(oauth_client_id); | 146 SET_STR(oauth_client_id); |
| 146 return value; | 147 return value; |
| 147 } | 148 } |
| 148 | 149 |
| 149 scoped_ptr<base::DictionaryValue> SessionHeaderToValue( | 150 std::unique_ptr<base::DictionaryValue> SessionHeaderToValue( |
| 150 const sync_pb::SessionHeader& proto) { | 151 const sync_pb::SessionHeader& proto) { |
| 151 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 152 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 152 SET_REP(window, SessionWindowToValue); | 153 SET_REP(window, SessionWindowToValue); |
| 153 SET_STR(client_name); | 154 SET_STR(client_name); |
| 154 SET_ENUM(device_type, GetDeviceTypeString); | 155 SET_ENUM(device_type, GetDeviceTypeString); |
| 155 return value; | 156 return value; |
| 156 } | 157 } |
| 157 | 158 |
| 158 scoped_ptr<base::DictionaryValue> SessionTabToValue( | 159 std::unique_ptr<base::DictionaryValue> SessionTabToValue( |
| 159 const sync_pb::SessionTab& proto) { | 160 const sync_pb::SessionTab& proto) { |
| 160 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 161 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 161 SET_INT32(tab_id); | 162 SET_INT32(tab_id); |
| 162 SET_INT32(window_id); | 163 SET_INT32(window_id); |
| 163 SET_INT32(tab_visual_index); | 164 SET_INT32(tab_visual_index); |
| 164 SET_INT32(current_navigation_index); | 165 SET_INT32(current_navigation_index); |
| 165 SET_BOOL(pinned); | 166 SET_BOOL(pinned); |
| 166 SET_STR(extension_app_id); | 167 SET_STR(extension_app_id); |
| 167 SET_REP(navigation, TabNavigationToValue); | 168 SET_REP(navigation, TabNavigationToValue); |
| 168 SET_BYTES(favicon); | 169 SET_BYTES(favicon); |
| 169 SET_ENUM(favicon_type, GetFaviconTypeString); | 170 SET_ENUM(favicon_type, GetFaviconTypeString); |
| 170 SET_STR(favicon_source); | 171 SET_STR(favicon_source); |
| 171 SET_REP(variation_id, MakeInt64Value); | 172 SET_REP(variation_id, MakeInt64Value); |
| 172 return value; | 173 return value; |
| 173 } | 174 } |
| 174 | 175 |
| 175 scoped_ptr<base::DictionaryValue> SessionWindowToValue( | 176 std::unique_ptr<base::DictionaryValue> SessionWindowToValue( |
| 176 const sync_pb::SessionWindow& proto) { | 177 const sync_pb::SessionWindow& proto) { |
| 177 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 178 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 178 SET_INT32(window_id); | 179 SET_INT32(window_id); |
| 179 SET_INT32(selected_tab_index); | 180 SET_INT32(selected_tab_index); |
| 180 SET_INT32_REP(tab); | 181 SET_INT32_REP(tab); |
| 181 SET_ENUM(browser_type, GetBrowserTypeString); | 182 SET_ENUM(browser_type, GetBrowserTypeString); |
| 182 return value; | 183 return value; |
| 183 } | 184 } |
| 184 | 185 |
| 185 scoped_ptr<base::DictionaryValue> TabNavigationToValue( | 186 std::unique_ptr<base::DictionaryValue> TabNavigationToValue( |
| 186 const sync_pb::TabNavigation& proto) { | 187 const sync_pb::TabNavigation& proto) { |
| 187 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 188 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 188 SET_STR(virtual_url); | 189 SET_STR(virtual_url); |
| 189 SET_STR(referrer); | 190 SET_STR(referrer); |
| 190 SET_STR(title); | 191 SET_STR(title); |
| 191 SET_ENUM(page_transition, GetPageTransitionString); | 192 SET_ENUM(page_transition, GetPageTransitionString); |
| 192 SET_ENUM(redirect_type, GetPageTransitionRedirectTypeString); | 193 SET_ENUM(redirect_type, GetPageTransitionRedirectTypeString); |
| 193 SET_INT32(unique_id); | 194 SET_INT32(unique_id); |
| 194 SET_INT64(timestamp_msec); | 195 SET_INT64(timestamp_msec); |
| 195 SET_BOOL(navigation_forward_back); | 196 SET_BOOL(navigation_forward_back); |
| 196 SET_BOOL(navigation_from_address_bar); | 197 SET_BOOL(navigation_from_address_bar); |
| 197 SET_BOOL(navigation_home_page); | 198 SET_BOOL(navigation_home_page); |
| 198 SET_BOOL(navigation_chain_start); | 199 SET_BOOL(navigation_chain_start); |
| 199 SET_BOOL(navigation_chain_end); | 200 SET_BOOL(navigation_chain_end); |
| 200 SET_INT64(global_id); | 201 SET_INT64(global_id); |
| 201 SET_STR(search_terms); | 202 SET_STR(search_terms); |
| 202 SET_STR(favicon_url); | 203 SET_STR(favicon_url); |
| 203 SET_ENUM(blocked_state, GetBlockedStateString); | 204 SET_ENUM(blocked_state, GetBlockedStateString); |
| 204 SET_STR_REP(content_pack_categories); | 205 SET_STR_REP(content_pack_categories); |
| 205 SET_INT32(http_status_code); | 206 SET_INT32(http_status_code); |
| 206 SET_INT32(obsolete_referrer_policy); | 207 SET_INT32(obsolete_referrer_policy); |
| 207 SET_BOOL(is_restored); | 208 SET_BOOL(is_restored); |
| 208 SET_REP(navigation_redirect, NavigationRedirectToValue); | 209 SET_REP(navigation_redirect, NavigationRedirectToValue); |
| 209 SET_STR(last_navigation_redirect_url); | 210 SET_STR(last_navigation_redirect_url); |
| 210 SET_INT32(correct_referrer_policy); | 211 SET_INT32(correct_referrer_policy); |
| 211 return value; | 212 return value; |
| 212 } | 213 } |
| 213 | 214 |
| 214 scoped_ptr<base::DictionaryValue> NavigationRedirectToValue( | 215 std::unique_ptr<base::DictionaryValue> NavigationRedirectToValue( |
| 215 const sync_pb::NavigationRedirect& proto) { | 216 const sync_pb::NavigationRedirect& proto) { |
| 216 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 217 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 217 SET_STR(url); | 218 SET_STR(url); |
| 218 return value; | 219 return value; |
| 219 } | 220 } |
| 220 | 221 |
| 221 scoped_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( | 222 std::unique_ptr<base::DictionaryValue> PasswordSpecificsDataToValue( |
| 222 const sync_pb::PasswordSpecificsData& proto) { | 223 const sync_pb::PasswordSpecificsData& proto) { |
| 223 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 224 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 224 SET_INT32(scheme); | 225 SET_INT32(scheme); |
| 225 SET_STR(signon_realm); | 226 SET_STR(signon_realm); |
| 226 SET_STR(origin); | 227 SET_STR(origin); |
| 227 SET_STR(action); | 228 SET_STR(action); |
| 228 SET_STR(username_element); | 229 SET_STR(username_element); |
| 229 SET_STR(username_value); | 230 SET_STR(username_value); |
| 230 SET_STR(password_element); | 231 SET_STR(password_element); |
| 231 value->SetString("password_value", "<redacted>"); | 232 value->SetString("password_value", "<redacted>"); |
| 232 SET_BOOL(ssl_valid); | 233 SET_BOOL(ssl_valid); |
| 233 SET_BOOL(preferred); | 234 SET_BOOL(preferred); |
| 234 SET_INT64(date_created); | 235 SET_INT64(date_created); |
| 235 SET_BOOL(blacklisted); | 236 SET_BOOL(blacklisted); |
| 236 SET_INT32(type); | 237 SET_INT32(type); |
| 237 SET_INT32(times_used); | 238 SET_INT32(times_used); |
| 238 SET_STR(display_name); | 239 SET_STR(display_name); |
| 239 SET_STR(avatar_url); | 240 SET_STR(avatar_url); |
| 240 SET_STR(federation_url); | 241 SET_STR(federation_url); |
| 241 return value; | 242 return value; |
| 242 } | 243 } |
| 243 | 244 |
| 244 scoped_ptr<base::DictionaryValue> GlobalIdDirectiveToValue( | 245 std::unique_ptr<base::DictionaryValue> GlobalIdDirectiveToValue( |
| 245 const sync_pb::GlobalIdDirective& proto) { | 246 const sync_pb::GlobalIdDirective& proto) { |
| 246 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 247 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 247 SET_INT64_REP(global_id); | 248 SET_INT64_REP(global_id); |
| 248 SET_INT64(start_time_usec); | 249 SET_INT64(start_time_usec); |
| 249 SET_INT64(end_time_usec); | 250 SET_INT64(end_time_usec); |
| 250 return value; | 251 return value; |
| 251 } | 252 } |
| 252 | 253 |
| 253 scoped_ptr<base::DictionaryValue> TimeRangeDirectiveToValue( | 254 std::unique_ptr<base::DictionaryValue> TimeRangeDirectiveToValue( |
| 254 const sync_pb::TimeRangeDirective& proto) { | 255 const sync_pb::TimeRangeDirective& proto) { |
| 255 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 256 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 256 SET_INT64(start_time_usec); | 257 SET_INT64(start_time_usec); |
| 257 SET_INT64(end_time_usec); | 258 SET_INT64(end_time_usec); |
| 258 return value; | 259 return value; |
| 259 } | 260 } |
| 260 | 261 |
| 261 scoped_ptr<base::DictionaryValue> AppListSpecificsToValue( | 262 std::unique_ptr<base::DictionaryValue> AppListSpecificsToValue( |
| 262 const sync_pb::AppListSpecifics& proto) { | 263 const sync_pb::AppListSpecifics& proto) { |
| 263 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 264 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 264 SET_STR(item_id); | 265 SET_STR(item_id); |
| 265 SET_ENUM(item_type, GetAppListItemTypeString); | 266 SET_ENUM(item_type, GetAppListItemTypeString); |
| 266 SET_STR(item_name); | 267 SET_STR(item_name); |
| 267 SET_STR(parent_id); | 268 SET_STR(parent_id); |
| 268 SET_STR(item_ordinal); | 269 SET_STR(item_ordinal); |
| 269 | 270 |
| 270 return value; | 271 return value; |
| 271 } | 272 } |
| 272 | 273 |
| 273 scoped_ptr<base::DictionaryValue> AppNotificationToValue( | 274 std::unique_ptr<base::DictionaryValue> AppNotificationToValue( |
| 274 const sync_pb::AppNotification& proto) { | 275 const sync_pb::AppNotification& proto) { |
| 275 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 276 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 276 SET_STR(guid); | 277 SET_STR(guid); |
| 277 SET_STR(app_id); | 278 SET_STR(app_id); |
| 278 SET_INT64(creation_timestamp_ms); | 279 SET_INT64(creation_timestamp_ms); |
| 279 SET_STR(title); | 280 SET_STR(title); |
| 280 SET_STR(body_text); | 281 SET_STR(body_text); |
| 281 SET_STR(link_url); | 282 SET_STR(link_url); |
| 282 SET_STR(link_text); | 283 SET_STR(link_text); |
| 283 return value; | 284 return value; |
| 284 } | 285 } |
| 285 | 286 |
| 286 scoped_ptr<base::DictionaryValue> AppSettingSpecificsToValue( | 287 std::unique_ptr<base::DictionaryValue> AppSettingSpecificsToValue( |
| 287 const sync_pb::AppSettingSpecifics& proto) { | 288 const sync_pb::AppSettingSpecifics& proto) { |
| 288 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 289 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 289 SET(extension_setting, ExtensionSettingSpecificsToValue); | 290 SET(extension_setting, ExtensionSettingSpecificsToValue); |
| 290 return value; | 291 return value; |
| 291 } | 292 } |
| 292 | 293 |
| 293 scoped_ptr<base::DictionaryValue> LinkedAppIconInfoToValue( | 294 std::unique_ptr<base::DictionaryValue> LinkedAppIconInfoToValue( |
| 294 const sync_pb::LinkedAppIconInfo& proto) { | 295 const sync_pb::LinkedAppIconInfo& proto) { |
| 295 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 296 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 296 SET_STR(url); | 297 SET_STR(url); |
| 297 SET_INT32(size); | 298 SET_INT32(size); |
| 298 return value; | 299 return value; |
| 299 } | 300 } |
| 300 | 301 |
| 301 scoped_ptr<base::DictionaryValue> AppSpecificsToValue( | 302 std::unique_ptr<base::DictionaryValue> AppSpecificsToValue( |
| 302 const sync_pb::AppSpecifics& proto) { | 303 const sync_pb::AppSpecifics& proto) { |
| 303 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 304 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 304 SET(extension, ExtensionSpecificsToValue); | 305 SET(extension, ExtensionSpecificsToValue); |
| 305 SET(notification_settings, AppSettingsToValue); | 306 SET(notification_settings, AppSettingsToValue); |
| 306 SET_STR(app_launch_ordinal); | 307 SET_STR(app_launch_ordinal); |
| 307 SET_STR(page_ordinal); | 308 SET_STR(page_ordinal); |
| 308 SET_ENUM(launch_type, GetLaunchTypeString); | 309 SET_ENUM(launch_type, GetLaunchTypeString); |
| 309 SET_STR(bookmark_app_url); | 310 SET_STR(bookmark_app_url); |
| 310 SET_STR(bookmark_app_description); | 311 SET_STR(bookmark_app_description); |
| 311 SET_STR(bookmark_app_icon_color); | 312 SET_STR(bookmark_app_icon_color); |
| 312 SET_REP(linked_app_icons, LinkedAppIconInfoToValue); | 313 SET_REP(linked_app_icons, LinkedAppIconInfoToValue); |
| 313 | 314 |
| 314 return value; | 315 return value; |
| 315 } | 316 } |
| 316 | 317 |
| 317 scoped_ptr<base::DictionaryValue> AutofillSpecificsToValue( | 318 std::unique_ptr<base::DictionaryValue> AutofillSpecificsToValue( |
| 318 const sync_pb::AutofillSpecifics& proto) { | 319 const sync_pb::AutofillSpecifics& proto) { |
| 319 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 320 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 320 SET_STR(name); | 321 SET_STR(name); |
| 321 SET_STR(value); | 322 SET_STR(value); |
| 322 SET_INT64_REP(usage_timestamp); | 323 SET_INT64_REP(usage_timestamp); |
| 323 SET(profile, AutofillProfileSpecificsToValue); | 324 SET(profile, AutofillProfileSpecificsToValue); |
| 324 return value; | 325 return value; |
| 325 } | 326 } |
| 326 | 327 |
| 327 scoped_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( | 328 std::unique_ptr<base::DictionaryValue> AutofillProfileSpecificsToValue( |
| 328 const sync_pb::AutofillProfileSpecifics& proto) { | 329 const sync_pb::AutofillProfileSpecifics& proto) { |
| 329 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 330 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 330 SET_STR(guid); | 331 SET_STR(guid); |
| 331 SET_STR(origin); | 332 SET_STR(origin); |
| 332 SET_INT64(use_count); | 333 SET_INT64(use_count); |
| 333 SET_INT64(use_date); | 334 SET_INT64(use_date); |
| 334 | 335 |
| 335 SET_STR_REP(name_first); | 336 SET_STR_REP(name_first); |
| 336 SET_STR_REP(name_middle); | 337 SET_STR_REP(name_middle); |
| 337 SET_STR_REP(name_last); | 338 SET_STR_REP(name_last); |
| 338 SET_STR_REP(name_full); | 339 SET_STR_REP(name_full); |
| 339 SET_STR_REP(email_address); | 340 SET_STR_REP(email_address); |
| 340 SET_STR(company_name); | 341 SET_STR(company_name); |
| 341 | 342 |
| 342 SET_STR(address_home_line1); | 343 SET_STR(address_home_line1); |
| 343 SET_STR(address_home_line2); | 344 SET_STR(address_home_line2); |
| 344 SET_STR(address_home_city); | 345 SET_STR(address_home_city); |
| 345 SET_STR(address_home_state); | 346 SET_STR(address_home_state); |
| 346 SET_STR(address_home_zip); | 347 SET_STR(address_home_zip); |
| 347 SET_STR(address_home_country); | 348 SET_STR(address_home_country); |
| 348 | 349 |
| 349 SET_STR(address_home_street_address); | 350 SET_STR(address_home_street_address); |
| 350 SET_STR(address_home_sorting_code); | 351 SET_STR(address_home_sorting_code); |
| 351 SET_STR(address_home_dependent_locality); | 352 SET_STR(address_home_dependent_locality); |
| 352 SET_STR(address_home_language_code); | 353 SET_STR(address_home_language_code); |
| 353 | 354 |
| 354 SET_STR_REP(phone_home_whole_number); | 355 SET_STR_REP(phone_home_whole_number); |
| 355 return value; | 356 return value; |
| 356 } | 357 } |
| 357 | 358 |
| 358 scoped_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue( | 359 std::unique_ptr<base::DictionaryValue> WalletMetadataSpecificsToValue( |
| 359 const sync_pb::WalletMetadataSpecifics& proto) { | 360 const sync_pb::WalletMetadataSpecifics& proto) { |
| 360 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 361 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 361 SET_ENUM(type, GetWalletMetadataTypeString); | 362 SET_ENUM(type, GetWalletMetadataTypeString); |
| 362 SET_STR(id); | 363 SET_STR(id); |
| 363 SET_INT64(use_count); | 364 SET_INT64(use_count); |
| 364 SET_INT64(use_date); | 365 SET_INT64(use_date); |
| 365 return value; | 366 return value; |
| 366 } | 367 } |
| 367 | 368 |
| 368 scoped_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( | 369 std::unique_ptr<base::DictionaryValue> AutofillWalletSpecificsToValue( |
| 369 const sync_pb::AutofillWalletSpecifics& proto) { | 370 const sync_pb::AutofillWalletSpecifics& proto) { |
| 370 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 371 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 371 | 372 |
| 372 SET_ENUM(type, GetWalletInfoTypeString); | 373 SET_ENUM(type, GetWalletInfoTypeString); |
| 373 if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { | 374 if (proto.type() == sync_pb::AutofillWalletSpecifics::MASKED_CREDIT_CARD) { |
| 374 value->Set("masked_card", | 375 value->Set("masked_card", |
| 375 WalletMaskedCreditCardToValue(proto.masked_card())); | 376 WalletMaskedCreditCardToValue(proto.masked_card())); |
| 376 } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) { | 377 } else if (proto.type() == sync_pb::AutofillWalletSpecifics::POSTAL_ADDRESS) { |
| 377 value->Set("address", | 378 value->Set("address", |
| 378 WalletPostalAddressToValue(proto.address())); | 379 WalletPostalAddressToValue(proto.address())); |
| 379 } | 380 } |
| 380 return value; | 381 return value; |
| 381 } | 382 } |
| 382 | 383 |
| 383 scoped_ptr<base::DictionaryValue> MetaInfoToValue( | 384 std::unique_ptr<base::DictionaryValue> MetaInfoToValue( |
| 384 const sync_pb::MetaInfo& proto) { | 385 const sync_pb::MetaInfo& proto) { |
| 385 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 386 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 386 SET_STR(key); | 387 SET_STR(key); |
| 387 SET_STR(value); | 388 SET_STR(value); |
| 388 return value; | 389 return value; |
| 389 } | 390 } |
| 390 | 391 |
| 391 scoped_ptr<base::DictionaryValue> BookmarkSpecificsToValue( | 392 std::unique_ptr<base::DictionaryValue> BookmarkSpecificsToValue( |
| 392 const sync_pb::BookmarkSpecifics& proto) { | 393 const sync_pb::BookmarkSpecifics& proto) { |
| 393 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 394 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 394 SET_STR(url); | 395 SET_STR(url); |
| 395 SET_BYTES(favicon); | 396 SET_BYTES(favicon); |
| 396 SET_STR(title); | 397 SET_STR(title); |
| 397 SET_INT64(creation_time_us); | 398 SET_INT64(creation_time_us); |
| 398 SET_STR(icon_url); | 399 SET_STR(icon_url); |
| 399 SET_REP(meta_info, &MetaInfoToValue); | 400 SET_REP(meta_info, &MetaInfoToValue); |
| 400 return value; | 401 return value; |
| 401 } | 402 } |
| 402 | 403 |
| 403 scoped_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue( | 404 std::unique_ptr<base::DictionaryValue> DeviceInfoSpecificsToValue( |
| 404 const sync_pb::DeviceInfoSpecifics& proto) { | 405 const sync_pb::DeviceInfoSpecifics& proto) { |
| 405 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 406 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 406 SET_STR(cache_guid); | 407 SET_STR(cache_guid); |
| 407 SET_STR(client_name); | 408 SET_STR(client_name); |
| 408 SET_ENUM(device_type, GetDeviceTypeString); | 409 SET_ENUM(device_type, GetDeviceTypeString); |
| 409 SET_STR(sync_user_agent); | 410 SET_STR(sync_user_agent); |
| 410 SET_STR(chrome_version); | 411 SET_STR(chrome_version); |
| 411 SET_STR(signin_scoped_device_id); | 412 SET_STR(signin_scoped_device_id); |
| 412 return value; | 413 return value; |
| 413 } | 414 } |
| 414 | 415 |
| 415 scoped_ptr<base::DictionaryValue> DictionarySpecificsToValue( | 416 std::unique_ptr<base::DictionaryValue> DictionarySpecificsToValue( |
| 416 const sync_pb::DictionarySpecifics& proto) { | 417 const sync_pb::DictionarySpecifics& proto) { |
| 417 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 418 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 418 SET_STR(word); | 419 SET_STR(word); |
| 419 return value; | 420 return value; |
| 420 } | 421 } |
| 421 | 422 |
| 422 namespace { | 423 namespace { |
| 423 | 424 |
| 424 scoped_ptr<base::DictionaryValue> FaviconSyncFlagsToValue( | 425 std::unique_ptr<base::DictionaryValue> FaviconSyncFlagsToValue( |
| 425 const sync_pb::FaviconSyncFlags& proto) { | 426 const sync_pb::FaviconSyncFlags& proto) { |
| 426 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 427 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 427 SET_BOOL(enabled); | 428 SET_BOOL(enabled); |
| 428 SET_INT32(favicon_sync_limit); | 429 SET_INT32(favicon_sync_limit); |
| 429 return value; | 430 return value; |
| 430 } | 431 } |
| 431 | 432 |
| 432 } // namespace | 433 } // namespace |
| 433 | 434 |
| 434 scoped_ptr<base::DictionaryValue> ExperimentsSpecificsToValue( | 435 std::unique_ptr<base::DictionaryValue> ExperimentsSpecificsToValue( |
| 435 const sync_pb::ExperimentsSpecifics& proto) { | 436 const sync_pb::ExperimentsSpecifics& proto) { |
| 436 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 437 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 437 SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption); | 438 SET_EXPERIMENT_ENABLED_FIELD(keystore_encryption); |
| 438 SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives); | 439 SET_EXPERIMENT_ENABLED_FIELD(history_delete_directives); |
| 439 SET_EXPERIMENT_ENABLED_FIELD(autofill_culling); | 440 SET_EXPERIMENT_ENABLED_FIELD(autofill_culling); |
| 440 SET_EXPERIMENT_ENABLED_FIELD(pre_commit_update_avoidance); | 441 SET_EXPERIMENT_ENABLED_FIELD(pre_commit_update_avoidance); |
| 441 SET(favicon_sync, FaviconSyncFlagsToValue); | 442 SET(favicon_sync, FaviconSyncFlagsToValue); |
| 442 SET_EXPERIMENT_ENABLED_FIELD(gcm_channel); | 443 SET_EXPERIMENT_ENABLED_FIELD(gcm_channel); |
| 443 SET_EXPERIMENT_ENABLED_FIELD(gcm_invalidations); | 444 SET_EXPERIMENT_ENABLED_FIELD(gcm_invalidations); |
| 444 return value; | 445 return value; |
| 445 } | 446 } |
| 446 | 447 |
| 447 scoped_ptr<base::DictionaryValue> ExtensionSettingSpecificsToValue( | 448 std::unique_ptr<base::DictionaryValue> ExtensionSettingSpecificsToValue( |
| 448 const sync_pb::ExtensionSettingSpecifics& proto) { | 449 const sync_pb::ExtensionSettingSpecifics& proto) { |
| 449 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 450 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 450 SET_STR(extension_id); | 451 SET_STR(extension_id); |
| 451 SET_STR(key); | 452 SET_STR(key); |
| 452 SET_STR(value); | 453 SET_STR(value); |
| 453 return value; | 454 return value; |
| 454 } | 455 } |
| 455 | 456 |
| 456 scoped_ptr<base::DictionaryValue> ExtensionSpecificsToValue( | 457 std::unique_ptr<base::DictionaryValue> ExtensionSpecificsToValue( |
| 457 const sync_pb::ExtensionSpecifics& proto) { | 458 const sync_pb::ExtensionSpecifics& proto) { |
| 458 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 459 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 459 SET_STR(id); | 460 SET_STR(id); |
| 460 SET_STR(version); | 461 SET_STR(version); |
| 461 SET_STR(update_url); | 462 SET_STR(update_url); |
| 462 SET_BOOL(enabled); | 463 SET_BOOL(enabled); |
| 463 SET_BOOL(incognito_enabled); | 464 SET_BOOL(incognito_enabled); |
| 464 SET_STR(name); | 465 SET_STR(name); |
| 465 SET_BOOL(remote_install); | 466 SET_BOOL(remote_install); |
| 466 SET_BOOL(installed_by_custodian); | 467 SET_BOOL(installed_by_custodian); |
| 467 SET_BOOL(all_urls_enabled); | 468 SET_BOOL(all_urls_enabled); |
| 468 SET_INT32(disable_reasons); | 469 SET_INT32(disable_reasons); |
| 469 return value; | 470 return value; |
| 470 } | 471 } |
| 471 | 472 |
| 472 namespace { | 473 namespace { |
| 473 scoped_ptr<base::DictionaryValue> FaviconDataToValue( | 474 std::unique_ptr<base::DictionaryValue> FaviconDataToValue( |
| 474 const sync_pb::FaviconData& proto) { | 475 const sync_pb::FaviconData& proto) { |
| 475 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 476 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 476 SET_BYTES(favicon); | 477 SET_BYTES(favicon); |
| 477 SET_INT32(width); | 478 SET_INT32(width); |
| 478 SET_INT32(height); | 479 SET_INT32(height); |
| 479 return value; | 480 return value; |
| 480 } | 481 } |
| 481 } // namespace | 482 } // namespace |
| 482 | 483 |
| 483 scoped_ptr<base::DictionaryValue> FaviconImageSpecificsToValue( | 484 std::unique_ptr<base::DictionaryValue> FaviconImageSpecificsToValue( |
| 484 const sync_pb::FaviconImageSpecifics& proto) { | 485 const sync_pb::FaviconImageSpecifics& proto) { |
| 485 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 486 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 486 SET_STR(favicon_url); | 487 SET_STR(favicon_url); |
| 487 SET(favicon_web, FaviconDataToValue); | 488 SET(favicon_web, FaviconDataToValue); |
| 488 SET(favicon_web_32, FaviconDataToValue); | 489 SET(favicon_web_32, FaviconDataToValue); |
| 489 SET(favicon_touch_64, FaviconDataToValue); | 490 SET(favicon_touch_64, FaviconDataToValue); |
| 490 SET(favicon_touch_precomposed_64, FaviconDataToValue); | 491 SET(favicon_touch_precomposed_64, FaviconDataToValue); |
| 491 return value; | 492 return value; |
| 492 } | 493 } |
| 493 | 494 |
| 494 scoped_ptr<base::DictionaryValue> FaviconTrackingSpecificsToValue( | 495 std::unique_ptr<base::DictionaryValue> FaviconTrackingSpecificsToValue( |
| 495 const sync_pb::FaviconTrackingSpecifics& proto) { | 496 const sync_pb::FaviconTrackingSpecifics& proto) { |
| 496 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 497 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 497 SET_STR(favicon_url); | 498 SET_STR(favicon_url); |
| 498 SET_INT64(last_visit_time_ms) | 499 SET_INT64(last_visit_time_ms) |
| 499 SET_BOOL(is_bookmarked); | 500 SET_BOOL(is_bookmarked); |
| 500 return value; | 501 return value; |
| 501 } | 502 } |
| 502 | 503 |
| 503 scoped_ptr<base::DictionaryValue> HistoryDeleteDirectiveSpecificsToValue( | 504 std::unique_ptr<base::DictionaryValue> HistoryDeleteDirectiveSpecificsToValue( |
| 504 const sync_pb::HistoryDeleteDirectiveSpecifics& proto) { | 505 const sync_pb::HistoryDeleteDirectiveSpecifics& proto) { |
| 505 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 506 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 506 SET(global_id_directive, GlobalIdDirectiveToValue); | 507 SET(global_id_directive, GlobalIdDirectiveToValue); |
| 507 SET(time_range_directive, TimeRangeDirectiveToValue); | 508 SET(time_range_directive, TimeRangeDirectiveToValue); |
| 508 return value; | 509 return value; |
| 509 } | 510 } |
| 510 | 511 |
| 511 scoped_ptr<base::DictionaryValue> ManagedUserSettingSpecificsToValue( | 512 std::unique_ptr<base::DictionaryValue> ManagedUserSettingSpecificsToValue( |
| 512 const sync_pb::ManagedUserSettingSpecifics& proto) { | 513 const sync_pb::ManagedUserSettingSpecifics& proto) { |
| 513 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 514 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 514 SET_STR(name); | 515 SET_STR(name); |
| 515 SET_STR(value); | 516 SET_STR(value); |
| 516 return value; | 517 return value; |
| 517 } | 518 } |
| 518 | 519 |
| 519 scoped_ptr<base::DictionaryValue> ManagedUserSpecificsToValue( | 520 std::unique_ptr<base::DictionaryValue> ManagedUserSpecificsToValue( |
| 520 const sync_pb::ManagedUserSpecifics& proto) { | 521 const sync_pb::ManagedUserSpecifics& proto) { |
| 521 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 522 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 522 SET_STR(id); | 523 SET_STR(id); |
| 523 SET_STR(name); | 524 SET_STR(name); |
| 524 SET_BOOL(acknowledged); | 525 SET_BOOL(acknowledged); |
| 525 SET_STR(master_key); | 526 SET_STR(master_key); |
| 526 SET_STR(chrome_avatar); | 527 SET_STR(chrome_avatar); |
| 527 SET_STR(chromeos_avatar); | 528 SET_STR(chromeos_avatar); |
| 528 return value; | 529 return value; |
| 529 } | 530 } |
| 530 | 531 |
| 531 scoped_ptr<base::DictionaryValue> ManagedUserSharedSettingSpecificsToValue( | 532 std::unique_ptr<base::DictionaryValue> ManagedUserSharedSettingSpecificsToValue( |
| 532 const sync_pb::ManagedUserSharedSettingSpecifics& proto) { | 533 const sync_pb::ManagedUserSharedSettingSpecifics& proto) { |
| 533 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 534 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 534 SET_STR(mu_id); | 535 SET_STR(mu_id); |
| 535 SET_STR(key); | 536 SET_STR(key); |
| 536 SET_STR(value); | 537 SET_STR(value); |
| 537 SET_BOOL(acknowledged); | 538 SET_BOOL(acknowledged); |
| 538 return value; | 539 return value; |
| 539 } | 540 } |
| 540 | 541 |
| 541 scoped_ptr<base::DictionaryValue> ManagedUserWhitelistSpecificsToValue( | 542 std::unique_ptr<base::DictionaryValue> ManagedUserWhitelistSpecificsToValue( |
| 542 const sync_pb::ManagedUserWhitelistSpecifics& proto) { | 543 const sync_pb::ManagedUserWhitelistSpecifics& proto) { |
| 543 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 544 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 544 SET_STR(id); | 545 SET_STR(id); |
| 545 SET_STR(name); | 546 SET_STR(name); |
| 546 return value; | 547 return value; |
| 547 } | 548 } |
| 548 | 549 |
| 549 scoped_ptr<base::DictionaryValue> NigoriSpecificsToValue( | 550 std::unique_ptr<base::DictionaryValue> NigoriSpecificsToValue( |
| 550 const sync_pb::NigoriSpecifics& proto) { | 551 const sync_pb::NigoriSpecifics& proto) { |
| 551 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 552 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 552 SET(encryption_keybag, EncryptedDataToValue); | 553 SET(encryption_keybag, EncryptedDataToValue); |
| 553 SET_BOOL(keybag_is_frozen); | 554 SET_BOOL(keybag_is_frozen); |
| 554 SET_BOOL(encrypt_bookmarks); | 555 SET_BOOL(encrypt_bookmarks); |
| 555 SET_BOOL(encrypt_preferences); | 556 SET_BOOL(encrypt_preferences); |
| 556 SET_BOOL(encrypt_autofill_profile); | 557 SET_BOOL(encrypt_autofill_profile); |
| 557 SET_BOOL(encrypt_autofill); | 558 SET_BOOL(encrypt_autofill); |
| 558 SET_BOOL(encrypt_themes); | 559 SET_BOOL(encrypt_themes); |
| 559 SET_BOOL(encrypt_typed_urls); | 560 SET_BOOL(encrypt_typed_urls); |
| 560 SET_BOOL(encrypt_extension_settings); | 561 SET_BOOL(encrypt_extension_settings); |
| 561 SET_BOOL(encrypt_extensions); | 562 SET_BOOL(encrypt_extensions); |
| 562 SET_BOOL(encrypt_sessions); | 563 SET_BOOL(encrypt_sessions); |
| 563 SET_BOOL(encrypt_app_settings); | 564 SET_BOOL(encrypt_app_settings); |
| 564 SET_BOOL(encrypt_apps); | 565 SET_BOOL(encrypt_apps); |
| 565 SET_BOOL(encrypt_search_engines); | 566 SET_BOOL(encrypt_search_engines); |
| 566 SET_BOOL(encrypt_dictionary); | 567 SET_BOOL(encrypt_dictionary); |
| 567 SET_BOOL(encrypt_articles); | 568 SET_BOOL(encrypt_articles); |
| 568 SET_BOOL(encrypt_app_list); | 569 SET_BOOL(encrypt_app_list); |
| 569 SET_BOOL(encrypt_everything); | 570 SET_BOOL(encrypt_everything); |
| 570 SET_BOOL(server_only_was_missing_keystore_migration_time); | 571 SET_BOOL(server_only_was_missing_keystore_migration_time); |
| 571 SET_BOOL(sync_tab_favicons); | 572 SET_BOOL(sync_tab_favicons); |
| 572 SET_ENUM(passphrase_type, PassphraseTypeString); | 573 SET_ENUM(passphrase_type, PassphraseTypeString); |
| 573 SET(keystore_decryptor_token, EncryptedDataToValue); | 574 SET(keystore_decryptor_token, EncryptedDataToValue); |
| 574 SET_INT64(keystore_migration_time); | 575 SET_INT64(keystore_migration_time); |
| 575 SET_INT64(custom_passphrase_time); | 576 SET_INT64(custom_passphrase_time); |
| 576 return value; | 577 return value; |
| 577 } | 578 } |
| 578 | 579 |
| 579 scoped_ptr<base::DictionaryValue> ArticlePageToValue( | 580 std::unique_ptr<base::DictionaryValue> ArticlePageToValue( |
| 580 const sync_pb::ArticlePage& proto) { | 581 const sync_pb::ArticlePage& proto) { |
| 581 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 582 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 582 SET_STR(url); | 583 SET_STR(url); |
| 583 return value; | 584 return value; |
| 584 } | 585 } |
| 585 | 586 |
| 586 scoped_ptr<base::DictionaryValue> ArticleSpecificsToValue( | 587 std::unique_ptr<base::DictionaryValue> ArticleSpecificsToValue( |
| 587 const sync_pb::ArticleSpecifics& proto) { | 588 const sync_pb::ArticleSpecifics& proto) { |
| 588 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 589 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 589 SET_STR(entry_id); | 590 SET_STR(entry_id); |
| 590 SET_STR(title); | 591 SET_STR(title); |
| 591 SET_REP(pages, ArticlePageToValue); | 592 SET_REP(pages, ArticlePageToValue); |
| 592 return value; | 593 return value; |
| 593 } | 594 } |
| 594 | 595 |
| 595 scoped_ptr<base::DictionaryValue> PasswordSpecificsToValue( | 596 std::unique_ptr<base::DictionaryValue> PasswordSpecificsToValue( |
| 596 const sync_pb::PasswordSpecifics& proto) { | 597 const sync_pb::PasswordSpecifics& proto) { |
| 597 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 598 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 598 SET(encrypted, EncryptedDataToValue); | 599 SET(encrypted, EncryptedDataToValue); |
| 599 return value; | 600 return value; |
| 600 } | 601 } |
| 601 | 602 |
| 602 scoped_ptr<base::DictionaryValue> PreferenceSpecificsToValue( | 603 std::unique_ptr<base::DictionaryValue> PreferenceSpecificsToValue( |
| 603 const sync_pb::PreferenceSpecifics& proto) { | 604 const sync_pb::PreferenceSpecifics& proto) { |
| 604 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 605 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 605 SET_STR(name); | 606 SET_STR(name); |
| 606 SET_STR(value); | 607 SET_STR(value); |
| 607 return value; | 608 return value; |
| 608 } | 609 } |
| 609 | 610 |
| 610 scoped_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue( | 611 std::unique_ptr<base::DictionaryValue> PriorityPreferenceSpecificsToValue( |
| 611 const sync_pb::PriorityPreferenceSpecifics& specifics) { | 612 const sync_pb::PriorityPreferenceSpecifics& specifics) { |
| 612 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 613 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 613 SET_FIELD(preference, PreferenceSpecificsToValue); | 614 SET_FIELD(preference, PreferenceSpecificsToValue); |
| 614 return value; | 615 return value; |
| 615 } | 616 } |
| 616 | 617 |
| 617 scoped_ptr<base::DictionaryValue> SyncedNotificationAppInfoSpecificsToValue( | 618 std::unique_ptr<base::DictionaryValue> |
| 619 SyncedNotificationAppInfoSpecificsToValue( |
| 618 const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { | 620 const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { |
| 619 return make_scoped_ptr(new base::DictionaryValue()); | 621 return base::WrapUnique(new base::DictionaryValue()); |
| 620 } | 622 } |
| 621 | 623 |
| 622 scoped_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue( | 624 std::unique_ptr<base::DictionaryValue> SyncedNotificationSpecificsToValue( |
| 623 const sync_pb::SyncedNotificationSpecifics& proto) { | 625 const sync_pb::SyncedNotificationSpecifics& proto) { |
| 624 return make_scoped_ptr(new base::DictionaryValue()); | 626 return base::WrapUnique(new base::DictionaryValue()); |
| 625 } | 627 } |
| 626 | 628 |
| 627 scoped_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( | 629 std::unique_ptr<base::DictionaryValue> SearchEngineSpecificsToValue( |
| 628 const sync_pb::SearchEngineSpecifics& proto) { | 630 const sync_pb::SearchEngineSpecifics& proto) { |
| 629 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 631 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 630 SET_STR(short_name); | 632 SET_STR(short_name); |
| 631 SET_STR(keyword); | 633 SET_STR(keyword); |
| 632 SET_STR(favicon_url); | 634 SET_STR(favicon_url); |
| 633 SET_STR(url); | 635 SET_STR(url); |
| 634 SET_BOOL(safe_for_autoreplace); | 636 SET_BOOL(safe_for_autoreplace); |
| 635 SET_STR(originating_url); | 637 SET_STR(originating_url); |
| 636 SET_INT64(date_created); | 638 SET_INT64(date_created); |
| 637 SET_STR(input_encodings); | 639 SET_STR(input_encodings); |
| 638 SET_BOOL(show_in_default_list); | 640 SET_BOOL(show_in_default_list); |
| 639 SET_STR(suggestions_url); | 641 SET_STR(suggestions_url); |
| 640 SET_INT32(prepopulate_id); | 642 SET_INT32(prepopulate_id); |
| 641 SET_BOOL(autogenerate_keyword); | 643 SET_BOOL(autogenerate_keyword); |
| 642 SET_STR(instant_url); | 644 SET_STR(instant_url); |
| 643 SET_INT64(last_modified); | 645 SET_INT64(last_modified); |
| 644 SET_STR(sync_guid); | 646 SET_STR(sync_guid); |
| 645 SET_STR_REP(alternate_urls); | 647 SET_STR_REP(alternate_urls); |
| 646 SET_STR(search_terms_replacement_key); | 648 SET_STR(search_terms_replacement_key); |
| 647 SET_STR(image_url); | 649 SET_STR(image_url); |
| 648 SET_STR(search_url_post_params); | 650 SET_STR(search_url_post_params); |
| 649 SET_STR(suggestions_url_post_params); | 651 SET_STR(suggestions_url_post_params); |
| 650 SET_STR(instant_url_post_params); | 652 SET_STR(instant_url_post_params); |
| 651 SET_STR(image_url_post_params); | 653 SET_STR(image_url_post_params); |
| 652 SET_STR(new_tab_url); | 654 SET_STR(new_tab_url); |
| 653 return value; | 655 return value; |
| 654 } | 656 } |
| 655 | 657 |
| 656 scoped_ptr<base::DictionaryValue> SessionSpecificsToValue( | 658 std::unique_ptr<base::DictionaryValue> SessionSpecificsToValue( |
| 657 const sync_pb::SessionSpecifics& proto) { | 659 const sync_pb::SessionSpecifics& proto) { |
| 658 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 660 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 659 SET_STR(session_tag); | 661 SET_STR(session_tag); |
| 660 SET(header, SessionHeaderToValue); | 662 SET(header, SessionHeaderToValue); |
| 661 SET(tab, SessionTabToValue); | 663 SET(tab, SessionTabToValue); |
| 662 SET_INT32(tab_node_id); | 664 SET_INT32(tab_node_id); |
| 663 return value; | 665 return value; |
| 664 } | 666 } |
| 665 | 667 |
| 666 scoped_ptr<base::DictionaryValue> ThemeSpecificsToValue( | 668 std::unique_ptr<base::DictionaryValue> ThemeSpecificsToValue( |
| 667 const sync_pb::ThemeSpecifics& proto) { | 669 const sync_pb::ThemeSpecifics& proto) { |
| 668 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 670 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 669 SET_BOOL(use_custom_theme); | 671 SET_BOOL(use_custom_theme); |
| 670 SET_BOOL(use_system_theme_by_default); | 672 SET_BOOL(use_system_theme_by_default); |
| 671 SET_STR(custom_theme_name); | 673 SET_STR(custom_theme_name); |
| 672 SET_STR(custom_theme_id); | 674 SET_STR(custom_theme_id); |
| 673 SET_STR(custom_theme_update_url); | 675 SET_STR(custom_theme_update_url); |
| 674 return value; | 676 return value; |
| 675 } | 677 } |
| 676 | 678 |
| 677 scoped_ptr<base::DictionaryValue> TypedUrlSpecificsToValue( | 679 std::unique_ptr<base::DictionaryValue> TypedUrlSpecificsToValue( |
| 678 const sync_pb::TypedUrlSpecifics& proto) { | 680 const sync_pb::TypedUrlSpecifics& proto) { |
| 679 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 681 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 680 SET_STR(url); | 682 SET_STR(url); |
| 681 SET_STR(title); | 683 SET_STR(title); |
| 682 SET_BOOL(hidden); | 684 SET_BOOL(hidden); |
| 683 SET_INT64_REP(visits); | 685 SET_INT64_REP(visits); |
| 684 SET_INT32_REP(visit_transitions); | 686 SET_INT32_REP(visit_transitions); |
| 685 return value; | 687 return value; |
| 686 } | 688 } |
| 687 | 689 |
| 688 scoped_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( | 690 std::unique_ptr<base::DictionaryValue> WalletMaskedCreditCardToValue( |
| 689 const sync_pb::WalletMaskedCreditCard& proto) { | 691 const sync_pb::WalletMaskedCreditCard& proto) { |
| 690 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 692 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 691 SET_STR(id); | 693 SET_STR(id); |
| 692 SET_ENUM(status, GetWalletCardStatusString); | 694 SET_ENUM(status, GetWalletCardStatusString); |
| 693 SET_STR(name_on_card); | 695 SET_STR(name_on_card); |
| 694 SET_ENUM(type, GetWalletCardTypeString); | 696 SET_ENUM(type, GetWalletCardTypeString); |
| 695 SET_STR(last_four); | 697 SET_STR(last_four); |
| 696 SET_INT32(exp_month); | 698 SET_INT32(exp_month); |
| 697 SET_INT32(exp_year); | 699 SET_INT32(exp_year); |
| 698 return value; | 700 return value; |
| 699 } | 701 } |
| 700 | 702 |
| 701 scoped_ptr<base::DictionaryValue> WalletPostalAddressToValue( | 703 std::unique_ptr<base::DictionaryValue> WalletPostalAddressToValue( |
| 702 const sync_pb::WalletPostalAddress& proto) { | 704 const sync_pb::WalletPostalAddress& proto) { |
| 703 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 705 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 704 SET_STR(recipient_name); | 706 SET_STR(recipient_name); |
| 705 SET_STR(company_name); | 707 SET_STR(company_name); |
| 706 SET_STR_REP(street_address); | 708 SET_STR_REP(street_address); |
| 707 SET_STR(address_1); | 709 SET_STR(address_1); |
| 708 SET_STR(address_2); | 710 SET_STR(address_2); |
| 709 SET_STR(address_3); | 711 SET_STR(address_3); |
| 710 SET_STR(address_4); | 712 SET_STR(address_4); |
| 711 SET_STR(postal_code); | 713 SET_STR(postal_code); |
| 712 SET_STR(sorting_code); | 714 SET_STR(sorting_code); |
| 713 SET_STR(country_code); | 715 SET_STR(country_code); |
| 714 SET_STR(phone_number); | 716 SET_STR(phone_number); |
| 715 SET_STR(language_code); | 717 SET_STR(language_code); |
| 716 return value; | 718 return value; |
| 717 } | 719 } |
| 718 | 720 |
| 719 scoped_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue( | 721 std::unique_ptr<base::DictionaryValue> WifiCredentialSpecificsToValue( |
| 720 const sync_pb::WifiCredentialSpecifics& proto) { | 722 const sync_pb::WifiCredentialSpecifics& proto) { |
| 721 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 723 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 722 SET_BYTES(ssid); | 724 SET_BYTES(ssid); |
| 723 SET_ENUM(security_class, GetWifiCredentialSecurityClassString); | 725 SET_ENUM(security_class, GetWifiCredentialSecurityClassString); |
| 724 SET_BYTES(passphrase); | 726 SET_BYTES(passphrase); |
| 725 return value; | 727 return value; |
| 726 } | 728 } |
| 727 | 729 |
| 728 scoped_ptr<base::DictionaryValue> EntitySpecificsToValue( | 730 std::unique_ptr<base::DictionaryValue> EntitySpecificsToValue( |
| 729 const sync_pb::EntitySpecifics& specifics) { | 731 const sync_pb::EntitySpecifics& specifics) { |
| 730 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 732 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 731 SET_FIELD(app, AppSpecificsToValue); | 733 SET_FIELD(app, AppSpecificsToValue); |
| 732 SET_FIELD(app_list, AppListSpecificsToValue); | 734 SET_FIELD(app_list, AppListSpecificsToValue); |
| 733 SET_FIELD(app_notification, AppNotificationToValue); | 735 SET_FIELD(app_notification, AppNotificationToValue); |
| 734 SET_FIELD(app_setting, AppSettingSpecificsToValue); | 736 SET_FIELD(app_setting, AppSettingSpecificsToValue); |
| 735 SET_FIELD(article, ArticleSpecificsToValue); | 737 SET_FIELD(article, ArticleSpecificsToValue); |
| 736 SET_FIELD(autofill, AutofillSpecificsToValue); | 738 SET_FIELD(autofill, AutofillSpecificsToValue); |
| 737 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); | 739 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); |
| 738 SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue); | 740 SET_FIELD(autofill_wallet, AutofillWalletSpecificsToValue); |
| 739 SET_FIELD(wallet_metadata, WalletMetadataSpecificsToValue); | 741 SET_FIELD(wallet_metadata, WalletMetadataSpecificsToValue); |
| 740 SET_FIELD(bookmark, BookmarkSpecificsToValue); | 742 SET_FIELD(bookmark, BookmarkSpecificsToValue); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 769 namespace { | 771 namespace { |
| 770 | 772 |
| 771 base::StringValue* UniquePositionToStringValue( | 773 base::StringValue* UniquePositionToStringValue( |
| 772 const sync_pb::UniquePosition& proto) { | 774 const sync_pb::UniquePosition& proto) { |
| 773 UniquePosition pos = UniquePosition::FromProto(proto); | 775 UniquePosition pos = UniquePosition::FromProto(proto); |
| 774 return new base::StringValue(pos.ToDebugString()); | 776 return new base::StringValue(pos.ToDebugString()); |
| 775 } | 777 } |
| 776 | 778 |
| 777 } // namespace | 779 } // namespace |
| 778 | 780 |
| 779 scoped_ptr<base::DictionaryValue> SyncEntityToValue( | 781 std::unique_ptr<base::DictionaryValue> SyncEntityToValue( |
| 780 const sync_pb::SyncEntity& proto, | 782 const sync_pb::SyncEntity& proto, |
| 781 bool include_specifics) { | 783 bool include_specifics) { |
| 782 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 784 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 783 SET_STR(id_string); | 785 SET_STR(id_string); |
| 784 SET_STR(parent_id_string); | 786 SET_STR(parent_id_string); |
| 785 SET_STR(old_parent_id); | 787 SET_STR(old_parent_id); |
| 786 SET_INT64(version); | 788 SET_INT64(version); |
| 787 SET_INT64(mtime); | 789 SET_INT64(mtime); |
| 788 SET_INT64(ctime); | 790 SET_INT64(ctime); |
| 789 SET_STR(name); | 791 SET_STR(name); |
| 790 SET_STR(non_unique_name); | 792 SET_STR(non_unique_name); |
| 791 SET_INT64(sync_timestamp); | 793 SET_INT64(sync_timestamp); |
| 792 SET_STR(server_defined_unique_tag); | 794 SET_STR(server_defined_unique_tag); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 811 bool include_specifics) { | 813 bool include_specifics) { |
| 812 base::ListValue* list = new base::ListValue(); | 814 base::ListValue* list = new base::ListValue(); |
| 813 ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it; | 815 ::google::protobuf::RepeatedPtrField<sync_pb::SyncEntity>::const_iterator it; |
| 814 for (it = entities.begin(); it != entities.end(); ++it) { | 816 for (it = entities.begin(); it != entities.end(); ++it) { |
| 815 list->Append(SyncEntityToValue(*it, include_specifics)); | 817 list->Append(SyncEntityToValue(*it, include_specifics)); |
| 816 } | 818 } |
| 817 | 819 |
| 818 return list; | 820 return list; |
| 819 } | 821 } |
| 820 | 822 |
| 821 scoped_ptr<base::DictionaryValue> ChromiumExtensionActivityToValue( | 823 std::unique_ptr<base::DictionaryValue> ChromiumExtensionActivityToValue( |
| 822 const sync_pb::ChromiumExtensionsActivity& proto) { | 824 const sync_pb::ChromiumExtensionsActivity& proto) { |
| 823 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 825 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 824 SET_STR(extension_id); | 826 SET_STR(extension_id); |
| 825 SET_INT32(bookmark_writes_since_last_commit); | 827 SET_INT32(bookmark_writes_since_last_commit); |
| 826 return value; | 828 return value; |
| 827 } | 829 } |
| 828 | 830 |
| 829 scoped_ptr<base::DictionaryValue> CommitMessageToValue( | 831 std::unique_ptr<base::DictionaryValue> CommitMessageToValue( |
| 830 const sync_pb::CommitMessage& proto, | 832 const sync_pb::CommitMessage& proto, |
| 831 bool include_specifics) { | 833 bool include_specifics) { |
| 832 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 834 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 833 value->Set("entries", | 835 value->Set("entries", |
| 834 SyncEntitiesToValue(proto.entries(), include_specifics)); | 836 SyncEntitiesToValue(proto.entries(), include_specifics)); |
| 835 SET_STR(cache_guid); | 837 SET_STR(cache_guid); |
| 836 SET_REP(extensions_activity, ChromiumExtensionActivityToValue); | 838 SET_REP(extensions_activity, ChromiumExtensionActivityToValue); |
| 837 SET(config_params, ClientConfigParamsToValue); | 839 SET(config_params, ClientConfigParamsToValue); |
| 838 return value; | 840 return value; |
| 839 } | 841 } |
| 840 | 842 |
| 841 scoped_ptr<base::DictionaryValue> GetUpdateTriggersToValue( | 843 std::unique_ptr<base::DictionaryValue> GetUpdateTriggersToValue( |
| 842 const sync_pb::GetUpdateTriggers& proto) { | 844 const sync_pb::GetUpdateTriggers& proto) { |
| 843 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 845 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 844 SET_STR_REP(notification_hint); | 846 SET_STR_REP(notification_hint); |
| 845 SET_BOOL(client_dropped_hints); | 847 SET_BOOL(client_dropped_hints); |
| 846 SET_BOOL(invalidations_out_of_sync); | 848 SET_BOOL(invalidations_out_of_sync); |
| 847 SET_INT64(local_modification_nudges); | 849 SET_INT64(local_modification_nudges); |
| 848 SET_INT64(datatype_refresh_nudges); | 850 SET_INT64(datatype_refresh_nudges); |
| 849 return value; | 851 return value; |
| 850 } | 852 } |
| 851 | 853 |
| 852 scoped_ptr<base::DictionaryValue> DataTypeProgressMarkerToValue( | 854 std::unique_ptr<base::DictionaryValue> DataTypeProgressMarkerToValue( |
| 853 const sync_pb::DataTypeProgressMarker& proto) { | 855 const sync_pb::DataTypeProgressMarker& proto) { |
| 854 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 856 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 855 SET_INT32(data_type_id); | 857 SET_INT32(data_type_id); |
| 856 SET_BYTES(token); | 858 SET_BYTES(token); |
| 857 SET_INT64(timestamp_token_for_migration); | 859 SET_INT64(timestamp_token_for_migration); |
| 858 SET_STR(notification_hint); | 860 SET_STR(notification_hint); |
| 859 SET(get_update_triggers, GetUpdateTriggersToValue); | 861 SET(get_update_triggers, GetUpdateTriggersToValue); |
| 860 return value; | 862 return value; |
| 861 } | 863 } |
| 862 | 864 |
| 863 scoped_ptr<base::DictionaryValue> DataTypeContextToValue( | 865 std::unique_ptr<base::DictionaryValue> DataTypeContextToValue( |
| 864 const sync_pb::DataTypeContext& proto) { | 866 const sync_pb::DataTypeContext& proto) { |
| 865 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 867 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 866 SET_INT32(data_type_id); | 868 SET_INT32(data_type_id); |
| 867 SET_STR(context); | 869 SET_STR(context); |
| 868 SET_INT64(version); | 870 SET_INT64(version); |
| 869 return value; | 871 return value; |
| 870 } | 872 } |
| 871 | 873 |
| 872 scoped_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue( | 874 std::unique_ptr<base::DictionaryValue> GetUpdatesCallerInfoToValue( |
| 873 const sync_pb::GetUpdatesCallerInfo& proto) { | 875 const sync_pb::GetUpdatesCallerInfo& proto) { |
| 874 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 876 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 875 SET_ENUM(source, GetUpdatesSourceString); | 877 SET_ENUM(source, GetUpdatesSourceString); |
| 876 SET_BOOL(notifications_enabled); | 878 SET_BOOL(notifications_enabled); |
| 877 return value; | 879 return value; |
| 878 } | 880 } |
| 879 | 881 |
| 880 scoped_ptr<base::DictionaryValue> GetUpdatesMessageToValue( | 882 std::unique_ptr<base::DictionaryValue> GetUpdatesMessageToValue( |
| 881 const sync_pb::GetUpdatesMessage& proto) { | 883 const sync_pb::GetUpdatesMessage& proto) { |
| 882 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 884 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 883 SET(caller_info, GetUpdatesCallerInfoToValue); | 885 SET(caller_info, GetUpdatesCallerInfoToValue); |
| 884 SET_BOOL(fetch_folders); | 886 SET_BOOL(fetch_folders); |
| 885 SET_INT32(batch_size); | 887 SET_INT32(batch_size); |
| 886 SET_REP(from_progress_marker, DataTypeProgressMarkerToValue); | 888 SET_REP(from_progress_marker, DataTypeProgressMarkerToValue); |
| 887 SET_BOOL(streaming); | 889 SET_BOOL(streaming); |
| 888 SET_BOOL(need_encryption_key); | 890 SET_BOOL(need_encryption_key); |
| 889 SET_BOOL(create_mobile_bookmarks_folder); | 891 SET_BOOL(create_mobile_bookmarks_folder); |
| 890 SET_ENUM(get_updates_origin, GetUpdatesOriginString); | 892 SET_ENUM(get_updates_origin, GetUpdatesOriginString); |
| 891 SET_REP(client_contexts, DataTypeContextToValue); | 893 SET_REP(client_contexts, DataTypeContextToValue); |
| 892 return value; | 894 return value; |
| 893 } | 895 } |
| 894 | 896 |
| 895 scoped_ptr<base::DictionaryValue> ClientStatusToValue( | 897 std::unique_ptr<base::DictionaryValue> ClientStatusToValue( |
| 896 const sync_pb::ClientStatus& proto) { | 898 const sync_pb::ClientStatus& proto) { |
| 897 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 899 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 898 SET_BOOL(hierarchy_conflict_detected); | 900 SET_BOOL(hierarchy_conflict_detected); |
| 899 return value; | 901 return value; |
| 900 } | 902 } |
| 901 | 903 |
| 902 scoped_ptr<base::DictionaryValue> EntryResponseToValue( | 904 std::unique_ptr<base::DictionaryValue> EntryResponseToValue( |
| 903 const sync_pb::CommitResponse::EntryResponse& proto) { | 905 const sync_pb::CommitResponse::EntryResponse& proto) { |
| 904 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 906 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 905 SET_ENUM(response_type, GetResponseTypeString); | 907 SET_ENUM(response_type, GetResponseTypeString); |
| 906 SET_STR(id_string); | 908 SET_STR(id_string); |
| 907 SET_STR(parent_id_string); | 909 SET_STR(parent_id_string); |
| 908 SET_INT64(position_in_parent); | 910 SET_INT64(position_in_parent); |
| 909 SET_INT64(version); | 911 SET_INT64(version); |
| 910 SET_STR(name); | 912 SET_STR(name); |
| 911 SET_STR(error_message); | 913 SET_STR(error_message); |
| 912 SET_INT64(mtime); | 914 SET_INT64(mtime); |
| 913 return value; | 915 return value; |
| 914 } | 916 } |
| 915 | 917 |
| 916 scoped_ptr<base::DictionaryValue> CommitResponseToValue( | 918 std::unique_ptr<base::DictionaryValue> CommitResponseToValue( |
| 917 const sync_pb::CommitResponse& proto) { | 919 const sync_pb::CommitResponse& proto) { |
| 918 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 920 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 919 SET_REP(entryresponse, EntryResponseToValue); | 921 SET_REP(entryresponse, EntryResponseToValue); |
| 920 return value; | 922 return value; |
| 921 } | 923 } |
| 922 | 924 |
| 923 scoped_ptr<base::DictionaryValue> GetUpdatesResponseToValue( | 925 std::unique_ptr<base::DictionaryValue> GetUpdatesResponseToValue( |
| 924 const sync_pb::GetUpdatesResponse& proto, | 926 const sync_pb::GetUpdatesResponse& proto, |
| 925 bool include_specifics) { | 927 bool include_specifics) { |
| 926 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 928 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 927 value->Set("entries", | 929 value->Set("entries", |
| 928 SyncEntitiesToValue(proto.entries(), include_specifics)); | 930 SyncEntitiesToValue(proto.entries(), include_specifics)); |
| 929 SET_INT64(changes_remaining); | 931 SET_INT64(changes_remaining); |
| 930 SET_REP(new_progress_marker, DataTypeProgressMarkerToValue); | 932 SET_REP(new_progress_marker, DataTypeProgressMarkerToValue); |
| 931 SET_REP(context_mutations, DataTypeContextToValue); | 933 SET_REP(context_mutations, DataTypeContextToValue); |
| 932 return value; | 934 return value; |
| 933 } | 935 } |
| 934 | 936 |
| 935 scoped_ptr<base::DictionaryValue> ClientCommandToValue( | 937 std::unique_ptr<base::DictionaryValue> ClientCommandToValue( |
| 936 const sync_pb::ClientCommand& proto) { | 938 const sync_pb::ClientCommand& proto) { |
| 937 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 939 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 938 SET_INT32(set_sync_poll_interval); | 940 SET_INT32(set_sync_poll_interval); |
| 939 SET_INT32(set_sync_long_poll_interval); | 941 SET_INT32(set_sync_long_poll_interval); |
| 940 SET_INT32(max_commit_batch_size); | 942 SET_INT32(max_commit_batch_size); |
| 941 SET_INT32(sessions_commit_delay_seconds); | 943 SET_INT32(sessions_commit_delay_seconds); |
| 942 SET_INT32(throttle_delay_seconds); | 944 SET_INT32(throttle_delay_seconds); |
| 943 SET_INT32(client_invalidation_hint_buffer_size); | 945 SET_INT32(client_invalidation_hint_buffer_size); |
| 944 return value; | 946 return value; |
| 945 } | 947 } |
| 946 | 948 |
| 947 scoped_ptr<base::DictionaryValue> ErrorToValue( | 949 std::unique_ptr<base::DictionaryValue> ErrorToValue( |
| 948 const sync_pb::ClientToServerResponse::Error& proto) { | 950 const sync_pb::ClientToServerResponse::Error& proto) { |
| 949 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 951 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 950 SET_ENUM(error_type, GetErrorTypeString); | 952 SET_ENUM(error_type, GetErrorTypeString); |
| 951 SET_STR(error_description); | 953 SET_STR(error_description); |
| 952 SET_STR(url); | 954 SET_STR(url); |
| 953 SET_ENUM(action, GetActionString); | 955 SET_ENUM(action, GetActionString); |
| 954 return value; | 956 return value; |
| 955 } | 957 } |
| 956 | 958 |
| 957 } // namespace | 959 } // namespace |
| 958 | 960 |
| 959 scoped_ptr<base::DictionaryValue> ClientToServerResponseToValue( | 961 std::unique_ptr<base::DictionaryValue> ClientToServerResponseToValue( |
| 960 const sync_pb::ClientToServerResponse& proto, | 962 const sync_pb::ClientToServerResponse& proto, |
| 961 bool include_specifics) { | 963 bool include_specifics) { |
| 962 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 964 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 963 SET(commit, CommitResponseToValue); | 965 SET(commit, CommitResponseToValue); |
| 964 if (proto.has_get_updates()) { | 966 if (proto.has_get_updates()) { |
| 965 value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(), | 967 value->Set("get_updates", GetUpdatesResponseToValue(proto.get_updates(), |
| 966 include_specifics)); | 968 include_specifics)); |
| 967 } | 969 } |
| 968 | 970 |
| 969 SET(error, ErrorToValue); | 971 SET(error, ErrorToValue); |
| 970 SET_ENUM(error_code, GetErrorTypeString); | 972 SET_ENUM(error_code, GetErrorTypeString); |
| 971 SET_STR(error_message); | 973 SET_STR(error_message); |
| 972 SET_STR(store_birthday); | 974 SET_STR(store_birthday); |
| 973 SET(client_command, ClientCommandToValue); | 975 SET(client_command, ClientCommandToValue); |
| 974 SET_INT32_REP(migrated_data_type_id); | 976 SET_INT32_REP(migrated_data_type_id); |
| 975 return value; | 977 return value; |
| 976 } | 978 } |
| 977 | 979 |
| 978 scoped_ptr<base::DictionaryValue> ClientToServerMessageToValue( | 980 std::unique_ptr<base::DictionaryValue> ClientToServerMessageToValue( |
| 979 const sync_pb::ClientToServerMessage& proto, | 981 const sync_pb::ClientToServerMessage& proto, |
| 980 bool include_specifics) { | 982 bool include_specifics) { |
| 981 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 983 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 982 SET_STR(share); | 984 SET_STR(share); |
| 983 SET_INT32(protocol_version); | 985 SET_INT32(protocol_version); |
| 984 if (proto.has_commit()) { | 986 if (proto.has_commit()) { |
| 985 value->Set("commit", | 987 value->Set("commit", |
| 986 CommitMessageToValue(proto.commit(), include_specifics)); | 988 CommitMessageToValue(proto.commit(), include_specifics)); |
| 987 } | 989 } |
| 988 | 990 |
| 989 SET(get_updates, GetUpdatesMessageToValue); | 991 SET(get_updates, GetUpdatesMessageToValue); |
| 990 SET_STR(store_birthday); | 992 SET_STR(store_birthday); |
| 991 SET_BOOL(sync_problem_detected); | 993 SET_BOOL(sync_problem_detected); |
| 992 SET(debug_info, DebugInfoToValue); | 994 SET(debug_info, DebugInfoToValue); |
| 993 SET(client_status, ClientStatusToValue); | 995 SET(client_status, ClientStatusToValue); |
| 994 return value; | 996 return value; |
| 995 } | 997 } |
| 996 | 998 |
| 997 scoped_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue( | 999 std::unique_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue( |
| 998 const sync_pb::DatatypeAssociationStats& proto) { | 1000 const sync_pb::DatatypeAssociationStats& proto) { |
| 999 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1001 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 1000 SET_INT32(data_type_id); | 1002 SET_INT32(data_type_id); |
| 1001 SET_INT32(num_local_items_before_association); | 1003 SET_INT32(num_local_items_before_association); |
| 1002 SET_INT32(num_sync_items_before_association); | 1004 SET_INT32(num_sync_items_before_association); |
| 1003 SET_INT32(num_local_items_after_association); | 1005 SET_INT32(num_local_items_after_association); |
| 1004 SET_INT32(num_sync_items_after_association); | 1006 SET_INT32(num_sync_items_after_association); |
| 1005 SET_INT32(num_local_items_added); | 1007 SET_INT32(num_local_items_added); |
| 1006 SET_INT32(num_local_items_deleted); | 1008 SET_INT32(num_local_items_deleted); |
| 1007 SET_INT32(num_local_items_modified); | 1009 SET_INT32(num_local_items_modified); |
| 1008 SET_INT32(num_sync_items_added); | 1010 SET_INT32(num_sync_items_added); |
| 1009 SET_INT32(num_sync_items_deleted); | 1011 SET_INT32(num_sync_items_deleted); |
| 1010 SET_INT32(num_sync_items_modified); | 1012 SET_INT32(num_sync_items_modified); |
| 1011 SET_INT64(local_version_pre_association); | 1013 SET_INT64(local_version_pre_association); |
| 1012 SET_INT64(sync_version_pre_association) | 1014 SET_INT64(sync_version_pre_association) |
| 1013 SET_BOOL(had_error); | 1015 SET_BOOL(had_error); |
| 1014 SET_INT64(download_wait_time_us); | 1016 SET_INT64(download_wait_time_us); |
| 1015 SET_INT64(download_time_us); | 1017 SET_INT64(download_time_us); |
| 1016 SET_INT64(association_wait_time_for_high_priority_us); | 1018 SET_INT64(association_wait_time_for_high_priority_us); |
| 1017 SET_INT64(association_wait_time_for_same_priority_us); | 1019 SET_INT64(association_wait_time_for_same_priority_us); |
| 1018 return value; | 1020 return value; |
| 1019 } | 1021 } |
| 1020 | 1022 |
| 1021 scoped_ptr<base::DictionaryValue> DebugEventInfoToValue( | 1023 std::unique_ptr<base::DictionaryValue> DebugEventInfoToValue( |
| 1022 const sync_pb::DebugEventInfo& proto) { | 1024 const sync_pb::DebugEventInfo& proto) { |
| 1023 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1025 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 1024 SET_ENUM(singleton_event, SingletonDebugEventTypeString); | 1026 SET_ENUM(singleton_event, SingletonDebugEventTypeString); |
| 1025 SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue); | 1027 SET(sync_cycle_completed_event_info, SyncCycleCompletedEventInfoToValue); |
| 1026 SET_INT32(nudging_datatype); | 1028 SET_INT32(nudging_datatype); |
| 1027 SET_INT32_REP(datatypes_notified_from_server); | 1029 SET_INT32_REP(datatypes_notified_from_server); |
| 1028 SET(datatype_association_stats, DatatypeAssociationStatsToValue); | 1030 SET(datatype_association_stats, DatatypeAssociationStatsToValue); |
| 1029 return value; | 1031 return value; |
| 1030 } | 1032 } |
| 1031 | 1033 |
| 1032 scoped_ptr<base::DictionaryValue> DebugInfoToValue( | 1034 std::unique_ptr<base::DictionaryValue> DebugInfoToValue( |
| 1033 const sync_pb::DebugInfo& proto) { | 1035 const sync_pb::DebugInfo& proto) { |
| 1034 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1036 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 1035 SET_REP(events, DebugEventInfoToValue); | 1037 SET_REP(events, DebugEventInfoToValue); |
| 1036 SET_BOOL(cryptographer_ready); | 1038 SET_BOOL(cryptographer_ready); |
| 1037 SET_BOOL(cryptographer_has_pending_keys); | 1039 SET_BOOL(cryptographer_has_pending_keys); |
| 1038 SET_BOOL(events_dropped); | 1040 SET_BOOL(events_dropped); |
| 1039 return value; | 1041 return value; |
| 1040 } | 1042 } |
| 1041 | 1043 |
| 1042 scoped_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue( | 1044 std::unique_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue( |
| 1043 const sync_pb::SyncCycleCompletedEventInfo& proto) { | 1045 const sync_pb::SyncCycleCompletedEventInfo& proto) { |
| 1044 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1046 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 1045 SET_INT32(num_encryption_conflicts); | 1047 SET_INT32(num_encryption_conflicts); |
| 1046 SET_INT32(num_hierarchy_conflicts); | 1048 SET_INT32(num_hierarchy_conflicts); |
| 1047 SET_INT32(num_server_conflicts); | 1049 SET_INT32(num_server_conflicts); |
| 1048 SET_INT32(num_updates_downloaded); | 1050 SET_INT32(num_updates_downloaded); |
| 1049 SET_INT32(num_reflected_updates_downloaded); | 1051 SET_INT32(num_reflected_updates_downloaded); |
| 1050 SET(caller_info, GetUpdatesCallerInfoToValue); | 1052 SET(caller_info, GetUpdatesCallerInfoToValue); |
| 1051 return value; | 1053 return value; |
| 1052 } | 1054 } |
| 1053 | 1055 |
| 1054 scoped_ptr<base::DictionaryValue> ClientConfigParamsToValue( | 1056 std::unique_ptr<base::DictionaryValue> ClientConfigParamsToValue( |
| 1055 const sync_pb::ClientConfigParams& proto) { | 1057 const sync_pb::ClientConfigParams& proto) { |
| 1056 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1058 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 1057 SET_INT32_REP(enabled_type_ids); | 1059 SET_INT32_REP(enabled_type_ids); |
| 1058 SET_BOOL(tabs_datatype_enabled); | 1060 SET_BOOL(tabs_datatype_enabled); |
| 1059 SET_BOOL(cookie_jar_mismatch); | 1061 SET_BOOL(cookie_jar_mismatch); |
| 1060 return value; | 1062 return value; |
| 1061 } | 1063 } |
| 1062 | 1064 |
| 1063 scoped_ptr<base::DictionaryValue> AttachmentIdProtoToValue( | 1065 std::unique_ptr<base::DictionaryValue> AttachmentIdProtoToValue( |
| 1064 const sync_pb::AttachmentIdProto& proto) { | 1066 const sync_pb::AttachmentIdProto& proto) { |
| 1065 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); | 1067 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| 1066 SET_STR(unique_id); | 1068 SET_STR(unique_id); |
| 1067 return value; | 1069 return value; |
| 1068 } | 1070 } |
| 1069 | 1071 |
| 1070 #undef SET_TYPE | 1072 #undef SET_TYPE |
| 1071 #undef SET | 1073 #undef SET |
| 1072 #undef SET_REP | 1074 #undef SET_REP |
| 1073 | 1075 |
| 1074 #undef SET_BOOL | 1076 #undef SET_BOOL |
| 1075 #undef SET_BYTES | 1077 #undef SET_BYTES |
| 1076 #undef SET_INT32 | 1078 #undef SET_INT32 |
| 1077 #undef SET_INT64 | 1079 #undef SET_INT64 |
| 1078 #undef SET_INT64_REP | 1080 #undef SET_INT64_REP |
| 1079 #undef SET_STR | 1081 #undef SET_STR |
| 1080 #undef SET_STR_REP | 1082 #undef SET_STR_REP |
| 1081 | 1083 |
| 1082 #undef SET_FIELD | 1084 #undef SET_FIELD |
| 1083 | 1085 |
| 1084 } // namespace syncer | 1086 } // namespace syncer |
| OLD | NEW |