Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(103)

Side by Side Diff: ios/web/public/crw_session_storage.mm

Issue 2687353003: Created SerializableUserDataManager. (Closed)
Patch Set: Eugene's comments Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ios/web/public/crw_session_storage.h ('k') | ios/web/public/serializable_user_data_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 #import "ios/web/public/crw_navigation_manager_storage.h" 5 #import "ios/web/public/crw_session_storage.h"
6 6
7 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" 7 #import "ios/web/navigation/crw_session_certificate_policy_manager.h"
8 #import "ios/web/public/serializable_user_data_manager.h"
8 9
9 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
10 #error "This file requires ARC support." 11 #error "This file requires ARC support."
11 #endif 12 #endif
12 13
13 namespace { 14 namespace {
14 // Serialization keys used in NSCoding functions. 15 // Serialization keys used in NSCoding functions.
15 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager"; 16 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager";
16 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex"; 17 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex";
17 NSString* const kItemStoragesKey = @"entries"; 18 NSString* const kItemStoragesKey = @"entries";
18 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp"; 19 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp";
19 NSString* const kOpenerIDKey = @"openerId"; 20 NSString* const kOpenerIDKey = @"openerId";
20 NSString* const kOpenedByDOMKey = @"openedByDOM"; 21 NSString* const kOpenedByDOMKey = @"openedByDOM";
21 NSString* const kOpenerNavigationIndexKey = @"openerNavigationIndex"; 22 NSString* const kOpenerNavigationIndexKey = @"openerNavigationIndex";
22 NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex"; 23 NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex";
23 NSString* const kTabIDKey = @"tabId"; 24 NSString* const kTabIDKey = @"tabId";
24 NSString* const kWindowNameKey = @"windowName"; 25 NSString* const kWindowNameKey = @"windowName";
25 } 26 }
26 27
27 @implementation CRWNavigationManagerStorage 28 @interface CRWSessionStorage () {
29 // Backing object for property of same name.
30 std::unique_ptr<web::SerializableUserData> _userData;
31 }
32
33 @end
34
35 @implementation CRWSessionStorage
28 36
29 @synthesize tabID = _tabID; 37 @synthesize tabID = _tabID;
30 @synthesize openerID = _openerID; 38 @synthesize openerID = _openerID;
31 @synthesize openedByDOM = _openedByDOM; 39 @synthesize openedByDOM = _openedByDOM;
32 @synthesize openerNavigationIndex = _openerNavigationIndex; 40 @synthesize openerNavigationIndex = _openerNavigationIndex;
33 @synthesize windowName = _windowName; 41 @synthesize windowName = _windowName;
34 @synthesize currentNavigationIndex = _currentNavigationIndex; 42 @synthesize currentNavigationIndex = _currentNavigationIndex;
35 @synthesize previousNavigationIndex = _previousNavigationIndex; 43 @synthesize previousNavigationIndex = _previousNavigationIndex;
36 @synthesize lastVisitedTimestamp = _lastVisitedTimestamp; 44 @synthesize lastVisitedTimestamp = _lastVisitedTimestamp;
37 @synthesize itemStorages = _itemStorages; 45 @synthesize itemStorages = _itemStorages;
38 @synthesize sessionCertificatePolicyManager = _sessionCertificatePolicyManager; 46 @synthesize sessionCertificatePolicyManager = _sessionCertificatePolicyManager;
39 47
48 #pragma mark - Accessors
49
50 - (web::SerializableUserData*)userData {
51 return _userData.get();
52 }
53
54 - (void)setSerializableUserData:
55 (std::unique_ptr<web::SerializableUserData>)userData {
56 _userData = std::move(userData);
57 }
58
59 #pragma mark - NSCoding
60
40 - (instancetype)initWithCoder:(nonnull NSCoder*)decoder { 61 - (instancetype)initWithCoder:(nonnull NSCoder*)decoder {
41 self = [super init]; 62 self = [super init];
42 if (self) { 63 if (self) {
43 _tabID = [[decoder decodeObjectForKey:kTabIDKey] copy]; 64 _tabID = [[decoder decodeObjectForKey:kTabIDKey] copy];
44 _windowName = [[decoder decodeObjectForKey:kWindowNameKey] copy]; 65 _windowName = [[decoder decodeObjectForKey:kWindowNameKey] copy];
45 _openerID = [[decoder decodeObjectForKey:kOpenerIDKey] copy]; 66 _openerID = [[decoder decodeObjectForKey:kOpenerIDKey] copy];
46 _openedByDOM = [decoder decodeBoolForKey:kOpenedByDOMKey]; 67 _openedByDOM = [decoder decodeBoolForKey:kOpenedByDOMKey];
47 _openerNavigationIndex = 68 _openerNavigationIndex =
48 [decoder decodeIntForKey:kOpenerNavigationIndexKey]; 69 [decoder decodeIntForKey:kOpenerNavigationIndexKey];
49 _currentNavigationIndex = 70 _currentNavigationIndex =
50 [decoder decodeIntForKey:kCurrentNavigationIndexKey]; 71 [decoder decodeIntForKey:kCurrentNavigationIndexKey];
51 _previousNavigationIndex = 72 _previousNavigationIndex =
52 [decoder decodeIntForKey:kPreviousNavigationIndexKey]; 73 [decoder decodeIntForKey:kPreviousNavigationIndexKey];
53 _lastVisitedTimestamp = 74 _lastVisitedTimestamp =
54 [decoder decodeDoubleForKey:kLastVisitedTimestampKey]; 75 [decoder decodeDoubleForKey:kLastVisitedTimestampKey];
55 _itemStorages = [[NSMutableArray alloc] 76 _itemStorages = [[NSMutableArray alloc]
56 initWithArray:[decoder decodeObjectForKey:kItemStoragesKey]]; 77 initWithArray:[decoder decodeObjectForKey:kItemStoragesKey]];
57 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. 78 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that.
58 if (!_itemStorages.count) 79 if (!_itemStorages.count)
59 _currentNavigationIndex = -1; 80 _currentNavigationIndex = -1;
60 _sessionCertificatePolicyManager = 81 _sessionCertificatePolicyManager =
61 [decoder decodeObjectForKey:kCertificatePolicyManagerKey]; 82 [decoder decodeObjectForKey:kCertificatePolicyManagerKey];
62 if (!_sessionCertificatePolicyManager) { 83 if (!_sessionCertificatePolicyManager) {
63 _sessionCertificatePolicyManager = 84 _sessionCertificatePolicyManager =
64 [[CRWSessionCertificatePolicyManager alloc] init]; 85 [[CRWSessionCertificatePolicyManager alloc] init];
65 } 86 }
87 _userData = web::SerializableUserData::Create();
88 _userData->Decode(decoder);
66 } 89 }
67 return self; 90 return self;
68 } 91 }
69 92
70 - (void)encodeWithCoder:(NSCoder*)coder { 93 - (void)encodeWithCoder:(NSCoder*)coder {
71 [coder encodeObject:self.tabID forKey:kTabIDKey]; 94 [coder encodeObject:self.tabID forKey:kTabIDKey];
72 [coder encodeObject:self.openerID forKey:kOpenerIDKey]; 95 [coder encodeObject:self.openerID forKey:kOpenerIDKey];
73 [coder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey]; 96 [coder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey];
74 [coder encodeInt:self.openerNavigationIndex forKey:kOpenerNavigationIndexKey]; 97 [coder encodeInt:self.openerNavigationIndex forKey:kOpenerNavigationIndexKey];
75 [coder encodeObject:self.windowName forKey:kWindowNameKey]; 98 [coder encodeObject:self.windowName forKey:kWindowNameKey];
76 [coder encodeInt:self.currentNavigationIndex 99 [coder encodeInt:self.currentNavigationIndex
77 forKey:kCurrentNavigationIndexKey]; 100 forKey:kCurrentNavigationIndexKey];
78 [coder encodeInt:self.previousNavigationIndex 101 [coder encodeInt:self.previousNavigationIndex
79 forKey:kPreviousNavigationIndexKey]; 102 forKey:kPreviousNavigationIndexKey];
80 [coder encodeDouble:self.lastVisitedTimestamp 103 [coder encodeDouble:self.lastVisitedTimestamp
81 forKey:kLastVisitedTimestampKey]; 104 forKey:kLastVisitedTimestampKey];
82 [coder encodeObject:self.itemStorages forKey:kItemStoragesKey]; 105 [coder encodeObject:self.itemStorages forKey:kItemStoragesKey];
83 [coder encodeObject:self.sessionCertificatePolicyManager 106 [coder encodeObject:self.sessionCertificatePolicyManager
84 forKey:kCertificatePolicyManagerKey]; 107 forKey:kCertificatePolicyManagerKey];
108 if (_userData)
109 _userData->Encode(coder);
85 // rendererInitiated is deliberately not preserved, as upstream. 110 // rendererInitiated is deliberately not preserved, as upstream.
86 } 111 }
87 112
88 @end 113 @end
OLDNEW
« no previous file with comments | « ios/web/public/crw_session_storage.h ('k') | ios/web/public/serializable_user_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698