| 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 #import "ios/web/navigation/crw_serialized_navigation_manager.h" |
| 6 |
| 7 #include "base/mac/objc_property_releaser.h" |
| 8 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" |
| 9 |
| 10 namespace { |
| 11 // Serialization keys used in NSCoding functions. |
| 12 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager"; |
| 13 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex"; |
| 14 NSString* const kEntriesKey = @"entries"; |
| 15 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp"; |
| 16 NSString* const kOpenerIDKey = @"openerId"; |
| 17 NSString* const kOpenedByDOMKey = @"openedByDOM"; |
| 18 NSString* const kOpenerNavigationIndexKey = @"openerNavigationIndex"; |
| 19 NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex"; |
| 20 NSString* const kTabIDKey = @"tabId"; |
| 21 NSString* const kWindowNameKey = @"windowName"; |
| 22 NSString* const kXCallbackParametersKey = @"xCallbackParameters"; |
| 23 } |
| 24 |
| 25 @interface CRWSerializedNavigationManager () { |
| 26 base::mac::ObjCPropertyReleaser |
| 27 _propertyReleaser_CRWSerializedNavigationManager; |
| 28 } |
| 29 @end |
| 30 |
| 31 @implementation CRWSerializedNavigationManager |
| 32 |
| 33 @synthesize tabID = _tabID; |
| 34 @synthesize openerID = _openerID; |
| 35 @synthesize openedByDOM = _openedByDOM; |
| 36 @synthesize openerNavigationIndex = _openerNavigationIndex; |
| 37 @synthesize windowName = _windowName; |
| 38 @synthesize currentNavigationIndex = _currentNavigationIndex; |
| 39 @synthesize previousNavigationIndex = _previousNavigationIndex; |
| 40 @synthesize lastVisitedTimestamp = _lastVisitedTimestamp; |
| 41 @synthesize entries = _entries; |
| 42 @synthesize sessionCertificatePolicyManager = _sessionCertificatePolicyManager; |
| 43 @synthesize XCallbackParameters = _XCallbackParameters; |
| 44 |
| 45 - (instancetype)init { |
| 46 self = [super init]; |
| 47 if (self) { |
| 48 _propertyReleaser_CRWSerializedNavigationManager.Init( |
| 49 self, [CRWSerializedNavigationManager class]); |
| 50 } |
| 51 return self; |
| 52 } |
| 53 |
| 54 - (instancetype)initWithCoder:(nonnull NSCoder*)decoder { |
| 55 self = [super init]; |
| 56 if (self) { |
| 57 _tabID = [[decoder decodeObjectForKey:kTabIDKey] copy]; |
| 58 _windowName = [[decoder decodeObjectForKey:kWindowNameKey] copy]; |
| 59 _openerID = [[decoder decodeObjectForKey:kOpenerIDKey] copy]; |
| 60 _openedByDOM = [decoder decodeBoolForKey:kOpenedByDOMKey]; |
| 61 _openerNavigationIndex = |
| 62 [decoder decodeIntForKey:kOpenerNavigationIndexKey]; |
| 63 _currentNavigationIndex = |
| 64 [decoder decodeIntForKey:kCurrentNavigationIndexKey]; |
| 65 _previousNavigationIndex = |
| 66 [decoder decodeIntForKey:kPreviousNavigationIndexKey]; |
| 67 _lastVisitedTimestamp = |
| 68 [decoder decodeDoubleForKey:kLastVisitedTimestampKey]; |
| 69 _entries = [[NSMutableArray alloc] |
| 70 initWithArray:[decoder decodeObjectForKey:kEntriesKey]]; |
| 71 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. |
| 72 if (!_entries.count) |
| 73 _currentNavigationIndex = -1; |
| 74 _sessionCertificatePolicyManager = |
| 75 [[decoder decodeObjectForKey:kCertificatePolicyManagerKey] retain]; |
| 76 if (!_sessionCertificatePolicyManager) { |
| 77 _sessionCertificatePolicyManager = |
| 78 [[CRWSessionCertificatePolicyManager alloc] init]; |
| 79 } |
| 80 _XCallbackParameters = |
| 81 [[decoder decodeObjectForKey:kXCallbackParametersKey] retain]; |
| 82 } |
| 83 return self; |
| 84 } |
| 85 |
| 86 - (void)encodeWithCoder:(NSCoder*)coder { |
| 87 [coder encodeObject:self.tabID forKey:kTabIDKey]; |
| 88 [coder encodeObject:self.openerID forKey:kOpenerIDKey]; |
| 89 [coder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey]; |
| 90 [coder encodeInt:self.openerNavigationIndex forKey:kOpenerNavigationIndexKey]; |
| 91 [coder encodeObject:self.windowName forKey:kWindowNameKey]; |
| 92 [coder encodeInt:self.currentNavigationIndex |
| 93 forKey:kCurrentNavigationIndexKey]; |
| 94 [coder encodeInt:self.previousNavigationIndex |
| 95 forKey:kPreviousNavigationIndexKey]; |
| 96 [coder encodeDouble:self.lastVisitedTimestamp |
| 97 forKey:kLastVisitedTimestampKey]; |
| 98 [coder encodeObject:self.entries forKey:kEntriesKey]; |
| 99 [coder encodeObject:self.sessionCertificatePolicyManager |
| 100 forKey:kCertificatePolicyManagerKey]; |
| 101 [coder encodeObject:self.XCallbackParameters forKey:kXCallbackParametersKey]; |
| 102 // rendererInitiated is deliberately not preserved, as upstream. |
| 103 } |
| 104 |
| 105 @end |
| OLD | NEW |