Chromium Code Reviews| Index: ios/web/navigation/serializable_user_data_manager_impl.mm |
| diff --git a/ios/web/navigation/serializable_user_data_manager_impl.mm b/ios/web/navigation/serializable_user_data_manager_impl.mm |
| index e3dd717716df7755fcb628e8ec66041f11b6f871..b35e6f7effb9644da760384518fd1e81eb690226 100644 |
| --- a/ios/web/navigation/serializable_user_data_manager_impl.mm |
| +++ b/ios/web/navigation/serializable_user_data_manager_impl.mm |
| @@ -59,7 +59,8 @@ |
| } |
| SerializableUserDataImpl::SerializableUserDataImpl() |
| - : data_([[NSDictionary alloc] init]) {} |
| + : data_([[NSDictionary alloc] init]), |
| + legacy_key_conversions_(@{@"tabId" : @"TabID"}) {} |
|
Eugene But (OOO till 7-30)
2017/02/13 17:37:57
Should we keep the old tabId name to avoid extra c
kkhorimoto
2017/02/13 23:41:18
Since we've set a milestone to remove the legacy c
|
| SerializableUserDataImpl::~SerializableUserDataImpl() {} |
| @@ -71,9 +72,20 @@ |
| } |
| void SerializableUserDataImpl::Decode(NSCoder* coder) { |
| - NSDictionary* data = base::mac::ObjCCastStrict<NSDictionary>( |
| - [coder decodeObjectForKey:kSerializedUserDataKey]); |
| - data_.reset([data mutableCopy]); |
| + NSMutableDictionary* data = |
| + [[coder decodeObjectForKey:kSerializedUserDataKey] mutableCopy]; |
| + [data addEntriesFromDictionary:GetDecodedLegacyValues(coder)]; |
| + data_.reset([data copy]); |
| +} |
| + |
| +NSDictionary* SerializableUserDataImpl::GetDecodedLegacyValues(NSCoder* coder) { |
| + NSMutableDictionary* legacy_values = [[NSMutableDictionary alloc] init]; |
| + for (NSString* legacy_key in [legacy_key_conversions_ allKeys]) { |
| + id<NSCoding> value = [coder decodeObjectForKey:legacy_key]; |
| + NSString* new_key = [legacy_key_conversions_ objectForKey:legacy_key]; |
| + legacy_values[new_key] = value; |
| + } |
| + return legacy_values; |
| } |
| // static |