Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_ | |
| 6 #define IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_ | |
| 7 | |
| 8 #import <Foundation/Foundation.h> | |
| 9 #include <memory> | |
| 10 | |
| 11 namespace web { | |
| 12 | |
| 13 class WebState; | |
| 14 | |
| 15 // Class used to serialize values added to SerializableUserDataManager. | |
| 16 class SerializableUserData { | |
| 17 public: | |
| 18 // Factory method. | |
| 19 static std::unique_ptr<SerializableUserData> Create(); | |
| 20 | |
| 21 // Encodes the data with |coder|. | |
| 22 virtual void Encode(NSCoder* coder) = 0; | |
| 23 | |
| 24 // Decodes the data from |coder|. | |
| 25 virtual void Decode(NSCoder* coder) = 0; | |
| 26 }; | |
| 27 | |
| 28 // Class that can be used to add serializable user data to a WebState. | |
| 29 class SerializableUserDataManager { | |
| 30 public: | |
| 31 // Returns the SerializableUserDataManager instance associated with | |
| 32 // |web_state|, instantiating one if necessary. | |
| 33 static SerializableUserDataManager* FromWebState(web::WebState* web_state); | |
| 34 | |
| 35 // Adds |data| to the user data, allowing it to be encoded under |key|. | |
| 36 // |data| is expected to be non-nil. If |key| has already been used | |
|
Eugene But (OOO till 7-30)
2017/02/11 02:46:48
Do you need to finish this sentence?
kkhorimoto
2017/02/11 03:19:49
whoops! yes I did!
| |
| 37 virtual void AddSerializableData(id<NSCoding> data, NSString* key) = 0; | |
| 38 | |
| 39 // Returns the value that has been stored under |key|. | |
| 40 virtual id<NSCoding> GetValueForSerializationKey(NSString* key) = 0; | |
| 41 | |
| 42 // Creates a SerializableUserData that can be used to encode the values added | |
| 43 // to the manager. | |
| 44 virtual std::unique_ptr<SerializableUserData> CreateSerializableUserData() | |
| 45 const = 0; | |
| 46 | |
| 47 // Adds the values decoded from |data| to the manager. | |
| 48 virtual void AddSerializableUserData(SerializableUserData* data) = 0; | |
| 49 }; | |
| 50 | |
| 51 } // namespace web | |
| 52 | |
| 53 #endif // IOS_WEB_PUBLIC_SERIALIZABLE_USER_DATA_MANAGER_H_ | |
| OLD | NEW |