blob: f29dc1fb2d2edcb458d16b2d9af5ba2e2a70a052 [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "base/mac/scoped_nsobject.h"
#import "ios/web/public/serializable_user_data_manager.h"
namespace web {
class SerializableUserDataImpl : public SerializableUserData {
// Constructor taking the NSDictionary holding the serializable data.
explicit SerializableUserDataImpl(NSDictionary* data);
// SerializableUserData:
void Encode(NSCoder* coder) override;
void Decode(NSCoder* coder) override;
// Returns the serializable data.
NSDictionary* data() { return data_; };
// Decodes the values that were previously encoded using CRWSessionStorage's
// NSCoding implementation and returns an NSDictionary using the new
// serialization keys.
// TODO( Remove legacy support.
NSDictionary* GetDecodedLegacyValues(NSCoder* coder);
// The dictionary passed on initialization. After calling Decode(), this will
// contain the data that is decoded from the NSCoder.
base::scoped_nsobject<NSDictionary> data_;
// Some values that were previously persisted directly in CRWSessionStorage
// are now serialized using SerializableUserData, and this dictionary is used
// to decode these values. The keys are the legacy encoding keys, and the
// values are their corresponding serializable user data keys.
base::scoped_nsobject<NSDictionary> legacy_key_conversions_;
class SerializableUserDataManagerImpl : public SerializableUserDataManager {
// SerializableUserDataManager:
void AddSerializableData(id<NSCoding> data, NSString* key) override;
id<NSCoding> GetValueForSerializationKey(NSString* key) override;
std::unique_ptr<SerializableUserData> CreateSerializableUserData()
const override;
void AddSerializableUserData(SerializableUserData* data) override;
// The dictionary that stores serializable user data.
base::scoped_nsobject<NSMutableDictionary> data_;
} // namespace web