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