| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_ | 5 #ifndef IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_ |
| 6 #define IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_ | 6 #define IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_ |
| 7 | 7 |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #import "ios/web/public/serializable_user_data_manager.h" | 9 #import "ios/web/public/serializable_user_data_manager.h" |
| 10 | 10 |
| 11 namespace web { | 11 namespace web { |
| 12 | 12 |
| 13 class SerializableUserDataImpl : public SerializableUserData { | 13 class SerializableUserDataImpl : public SerializableUserData { |
| 14 public: | 14 public: |
| 15 SerializableUserDataImpl(); | 15 SerializableUserDataImpl(); |
| 16 ~SerializableUserDataImpl(); | 16 ~SerializableUserDataImpl(); |
| 17 | 17 |
| 18 // Constructor taking the NSDictionary holding the serializable data. | 18 // Constructor taking the NSDictionary holding the serializable data. |
| 19 explicit SerializableUserDataImpl(NSDictionary* data); | 19 explicit SerializableUserDataImpl(NSDictionary* data); |
| 20 | 20 |
| 21 // SerializableUserData: | 21 // SerializableUserData: |
| 22 void Encode(NSCoder* coder) override; | 22 void Encode(NSCoder* coder) override; |
| 23 void Decode(NSCoder* coder) override; | 23 void Decode(NSCoder* coder) override; |
| 24 | 24 |
| 25 // Returns the serializable data. | 25 // Returns the serializable data. |
| 26 NSDictionary* data() { return data_; }; | 26 NSDictionary* data() { return data_; }; |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 // Decodes the values that were previously encoded using CRWSessionStorage's |
| 30 // NSCoding implementation and returns an NSDictionary using the new |
| 31 // serialization keys. |
| 32 // TODO(crbug.com/691800): Remove legacy support. |
| 33 NSDictionary* GetDecodedLegacyValues(NSCoder* coder); |
| 34 |
| 29 // The dictionary passed on initialization. After calling Decode(), this will | 35 // The dictionary passed on initialization. After calling Decode(), this will |
| 30 // contain the data that is decoded from the NSCoder. | 36 // contain the data that is decoded from the NSCoder. |
| 31 base::scoped_nsobject<NSDictionary> data_; | 37 base::scoped_nsobject<NSDictionary> data_; |
| 38 // Some values that were previously persisted directly in CRWSessionStorage |
| 39 // are now serialized using SerializableUserData, and this dictionary is used |
| 40 // to decode these values. The keys are the legacy encoding keys, and the |
| 41 // values are their corresponding serializable user data keys. |
| 42 base::scoped_nsobject<NSDictionary> legacy_key_conversions_; |
| 32 }; | 43 }; |
| 33 | 44 |
| 34 class SerializableUserDataManagerImpl : public SerializableUserDataManager { | 45 class SerializableUserDataManagerImpl : public SerializableUserDataManager { |
| 35 public: | 46 public: |
| 36 SerializableUserDataManagerImpl(); | 47 SerializableUserDataManagerImpl(); |
| 37 ~SerializableUserDataManagerImpl(); | 48 ~SerializableUserDataManagerImpl(); |
| 38 | 49 |
| 39 // SerializableUserDataManager: | 50 // SerializableUserDataManager: |
| 40 void AddSerializableData(id<NSCoding> data, NSString* key) override; | 51 void AddSerializableData(id<NSCoding> data, NSString* key) override; |
| 41 id<NSCoding> GetValueForSerializationKey(NSString* key) override; | 52 id<NSCoding> GetValueForSerializationKey(NSString* key) override; |
| 42 std::unique_ptr<SerializableUserData> CreateSerializableUserData() | 53 std::unique_ptr<SerializableUserData> CreateSerializableUserData() |
| 43 const override; | 54 const override; |
| 44 void AddSerializableUserData(SerializableUserData* data) override; | 55 void AddSerializableUserData(SerializableUserData* data) override; |
| 45 | 56 |
| 46 private: | 57 private: |
| 47 // The dictionary that stores serializable user data. | 58 // The dictionary that stores serializable user data. |
| 48 base::scoped_nsobject<NSMutableDictionary> data_; | 59 base::scoped_nsobject<NSMutableDictionary> data_; |
| 49 }; | 60 }; |
| 50 | 61 |
| 51 } // namespace web | 62 } // namespace web |
| 52 | 63 |
| 53 #endif // IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_ | 64 #endif // IOS_WEB_NAVIGATION_SERIALIZABLE_USER_DATA_MANAGER_IMPL_H_ |
| OLD | NEW |