Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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_SERIALIZED_USER_DATA_MANAGER_H_ | |
| 6 #define IOS_WEB_PUBLIC_SERIALIZED_USER_DATA_MANAGER_H_ | |
| 7 | |
| 8 #include "base/supports_user_data.h" | |
| 9 | |
| 10 #if defined(__OBJC__) | |
| 11 @protocol NSCoding; | |
| 12 @class NSDictionary; | |
| 13 @class NSString; | |
| 14 typedef id<NSCoding> SerializedUserDataType; | |
| 15 #else | |
| 16 class NSDictionary; | |
| 17 class NSString; | |
| 18 typedef void* SerializedUserDataType; | |
| 19 #endif // defined(__OBJC__) | |
| 20 | |
| 21 namespace web { | |
| 22 | |
| 23 class WebState; | |
| 24 | |
| 25 // Class that manages arbitrary persistent data that can be added to a | |
| 26 // NavigationManager. | |
| 27 class SerializedUserDataManager { | |
| 28 public: | |
| 29 virtual ~SerializedUserDataManager() {} | |
| 30 | |
| 31 // Returns a SerializedUserDataManager for |web_state|, lazily instantiating | |
| 32 // one if necessary. |web_state| must be non-null. | |
| 33 static SerializedUserDataManager* FromWebState(WebState* web_state); | |
| 34 | |
| 35 // Associates |data| with the NavigationManager under |serialization_key|. | |
| 36 // |data| is retained by the manager, and |serialization_key| is copied. If | |
| 37 // |data| is nil, the value previously stored under |serialization_key| is | |
| 38 // removed. |serialization_key| must be non-empty. | |
| 39 virtual void SetValueForSerializationKey(SerializedUserDataType data, | |
| 40 NSString* serialization_key) = 0; | |
| 41 | |
| 42 // Returns the value associated with |serialization_key|. |serialization_key| | |
| 43 // must be non-empty. | |
| 44 virtual SerializedUserDataType GetValueForSerializationKey( | |
| 45 NSString* serialization_key) const = 0; | |
| 46 | |
| 47 // Returns an NSDictionary containing copies of the serializable key value | |
| 48 // pairs. | |
| 49 virtual NSDictionary* GetSerializationDictionary() const = 0; | |
| 50 | |
| 51 // Adds values and serialization keys from |dictionary| to the manager. | |
| 52 // |dictionary| must be non-nil. | |
| 53 virtual void AddValuesFromDictionary(NSDictionary* dictionary) = 0; | |
| 54 }; | |
| 55 } | |
|
Eugene But (OOO till 7-30)
2015/09/24 21:39:25
NIT: // namespace web
| |
| 56 | |
| 57 #endif // IOS_WEB_PUBLIC_SERIALIZED_USER_DATA_MANAGER_H_ | |
| OLD | NEW |