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 #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"; | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
kOpenerIDKey
kkhorimoto
2015/09/24 18:12:59
Done.
| |
| 17 NSString* const kOpenedByDOMKey = @"openedByDOM"; | |
| 18 NSString* const kOpenerNavigationIndexKey = @"openerNavigationIndex"; | |
| 19 NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex"; | |
| 20 NSString* const kTabIdKey = @"tabId"; | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
kTabIDKey
kkhorimoto
2015/09/24 18:12:59
Done.
| |
| 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 = _openerNavigationIdes; | |
| 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*)aDecoder { | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
s/aDecoder/decoder
kkhorimoto
2015/09/24 18:12:59
Done.
| |
| 55 self = [super init]; | |
| 56 if (self) { | |
| 57 self.tabId = [aDecoder decodeObjectForKey:kTabIdKey]; | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
Please don't access properties in init
kkhorimoto
2015/09/24 18:12:59
Done.
| |
| 58 self.windowName = [aDecoder decodeObjectForKey:kWindowNameKey]; | |
| 59 self.openerId = [aDecoder decodeObjectForKey:kOpenerIdKey]; | |
| 60 self.openedByDOM = [aDecoder decodeBoolForKey:kOpenedByDOMKey]; | |
| 61 self.openerNavigationIndex = | |
| 62 [aDecoder decodeIntForKey:kOpenerNavigationIndexKey]; | |
| 63 self.currentNavigationIndex = | |
| 64 [aDecoder decodeIntForKey:kCurrentNavigationIndexKey]; | |
| 65 self.previousNavigationIndex = | |
| 66 [aDecoder decodeIntForKey:kPreviousNavigationIndexKey]; | |
| 67 self.lastVisitedTimestamp = | |
| 68 [aDecoder decodeDoubleForKey:kLastVisitedTimestampKey]; | |
| 69 self.entries = [NSMutableArray | |
| 70 arrayWithArray:[aDecoder decodeObjectForKey:kEntriesKey]]; | |
| 71 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. | |
| 72 if (!self.entries.count) | |
| 73 self.currentNavigationIndex = -1; | |
| 74 self.sessionCertificatePolicyManager = | |
| 75 [aDecoder decodeObjectForKey:kCertificatePolicyManagerKey]; | |
| 76 if (!self.sessionCertificatePolicyManager) { | |
| 77 self.sessionCertificatePolicyManager = | |
| 78 [[CRWSessionCertificatePolicyManager alloc] init]; | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
This is a memory leak
kkhorimoto
2015/09/24 18:12:59
Done.
| |
| 79 } | |
| 80 self.xCallbackParameters = | |
| 81 [[aDecoder decodeObjectForKey:kXCallbackParametersKey] retain]; | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
ditto
kkhorimoto
2015/09/24 18:12:59
Done.
| |
| 82 } | |
| 83 return self; | |
| 84 } | |
| 85 | |
| 86 - (void)encodeWithCoder:(NSCoder*)aCoder { | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
s/aCoder/coder
kkhorimoto
2015/09/24 18:12:59
Done.
| |
| 87 [aCoder encodeObject:self.tabId forKey:kTabIdKey]; | |
| 88 [aCoder encodeObject:self.openerId forKey:kOpenerIdKey]; | |
| 89 [aCoder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey]; | |
| 90 [aCoder encodeInt:self.openerNavigationIndex | |
| 91 forKey:kOpenerNavigationIndexKey]; | |
| 92 [aCoder encodeObject:self.windowName forKey:kWindowNameKey]; | |
| 93 [aCoder encodeInt:self.currentNavigationIndex | |
| 94 forKey:kCurrentNavigationIndexKey]; | |
| 95 [aCoder encodeInt:self.previousNavigationIndex | |
| 96 forKey:kPreviousNavigationIndexKey]; | |
| 97 [aCoder encodeDouble:self.lastVisitedTimestamp | |
| 98 forKey:kLastVisitedTimestampKey]; | |
| 99 [aCoder encodeObject:self.entries forKey:kEntriesKey]; | |
| 100 [aCoder encodeObject:self.sessionCertificatePolicyManager | |
| 101 forKey:kCertificatePolicyManagerKey]; | |
| 102 [aCoder encodeObject:self.xCallbackParameters forKey:kXCallbackParametersKey]; | |
| 103 // rendererInitiated is deliberately not preserved, as upstream. | |
| 104 } | |
| 105 | |
| 106 @end | |
| OLD | NEW |