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