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

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

Issue 2720983002: Remove windowName from CRWSessionController. (Closed)
Patch Set: Created 3 years, 9 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
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_session_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 #import "ios/web/public/serializable_user_data_manager.h"
9 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc) 10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support." 11 #error "This file requires ARC support."
12 #endif 12 #endif
13 13
14 namespace { 14 namespace {
15 // Serialization keys used in NSCoding functions. 15 // Serialization keys used in NSCoding functions.
16 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager"; 16 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager";
17 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex"; 17 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex";
18 NSString* const kItemStoragesKey = @"entries"; 18 NSString* const kItemStoragesKey = @"entries";
19 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp"; 19 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp";
20 NSString* const kOpenedByDOMKey = @"openedByDOM"; 20 NSString* const kOpenedByDOMKey = @"openedByDOM";
21 NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex"; 21 NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex";
22 NSString* const kWindowNameKey = @"windowName";
23 } 22 }
24 23
25 @interface CRWSessionStorage () { 24 @interface CRWSessionStorage () {
26 // Backing object for property of same name. 25 // Backing object for property of same name.
27 std::unique_ptr<web::SerializableUserData> _userData; 26 std::unique_ptr<web::SerializableUserData> _userData;
28 } 27 }
29 28
30 @end 29 @end
31 30
32 @implementation CRWSessionStorage 31 @implementation CRWSessionStorage
33 32
34 @synthesize openedByDOM = _openedByDOM; 33 @synthesize openedByDOM = _openedByDOM;
35 @synthesize windowName = _windowName;
36 @synthesize currentNavigationIndex = _currentNavigationIndex; 34 @synthesize currentNavigationIndex = _currentNavigationIndex;
37 @synthesize previousNavigationIndex = _previousNavigationIndex; 35 @synthesize previousNavigationIndex = _previousNavigationIndex;
38 @synthesize lastVisitedTimestamp = _lastVisitedTimestamp; 36 @synthesize lastVisitedTimestamp = _lastVisitedTimestamp;
39 @synthesize itemStorages = _itemStorages; 37 @synthesize itemStorages = _itemStorages;
40 @synthesize sessionCertificatePolicyManager = _sessionCertificatePolicyManager; 38 @synthesize sessionCertificatePolicyManager = _sessionCertificatePolicyManager;
41 39
42 #pragma mark - Accessors 40 #pragma mark - Accessors
43 41
44 - (web::SerializableUserData*)userData { 42 - (web::SerializableUserData*)userData {
45 return _userData.get(); 43 return _userData.get();
46 } 44 }
47 45
48 - (void)setSerializableUserData: 46 - (void)setSerializableUserData:
49 (std::unique_ptr<web::SerializableUserData>)userData { 47 (std::unique_ptr<web::SerializableUserData>)userData {
50 _userData = std::move(userData); 48 _userData = std::move(userData);
51 } 49 }
52 50
53 #pragma mark - NSCoding 51 #pragma mark - NSCoding
54 52
55 - (instancetype)initWithCoder:(nonnull NSCoder*)decoder { 53 - (instancetype)initWithCoder:(nonnull NSCoder*)decoder {
56 self = [super init]; 54 self = [super init];
57 if (self) { 55 if (self) {
58 _windowName = [[decoder decodeObjectForKey:kWindowNameKey] copy];
59 _openedByDOM = [decoder decodeBoolForKey:kOpenedByDOMKey]; 56 _openedByDOM = [decoder decodeBoolForKey:kOpenedByDOMKey];
60 _currentNavigationIndex = 57 _currentNavigationIndex =
61 [decoder decodeIntForKey:kCurrentNavigationIndexKey]; 58 [decoder decodeIntForKey:kCurrentNavigationIndexKey];
62 _previousNavigationIndex = 59 _previousNavigationIndex =
63 [decoder decodeIntForKey:kPreviousNavigationIndexKey]; 60 [decoder decodeIntForKey:kPreviousNavigationIndexKey];
64 _lastVisitedTimestamp = 61 _lastVisitedTimestamp =
65 [decoder decodeDoubleForKey:kLastVisitedTimestampKey]; 62 [decoder decodeDoubleForKey:kLastVisitedTimestampKey];
66 _itemStorages = [[NSMutableArray alloc] 63 _itemStorages = [[NSMutableArray alloc]
67 initWithArray:[decoder decodeObjectForKey:kItemStoragesKey]]; 64 initWithArray:[decoder decodeObjectForKey:kItemStoragesKey]];
68 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. 65 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that.
69 if (!_itemStorages.count) 66 if (!_itemStorages.count)
70 _currentNavigationIndex = -1; 67 _currentNavigationIndex = -1;
71 _sessionCertificatePolicyManager = 68 _sessionCertificatePolicyManager =
72 [decoder decodeObjectForKey:kCertificatePolicyManagerKey]; 69 [decoder decodeObjectForKey:kCertificatePolicyManagerKey];
73 if (!_sessionCertificatePolicyManager) { 70 if (!_sessionCertificatePolicyManager) {
74 _sessionCertificatePolicyManager = 71 _sessionCertificatePolicyManager =
75 [[CRWSessionCertificatePolicyManager alloc] init]; 72 [[CRWSessionCertificatePolicyManager alloc] init];
76 } 73 }
77 _userData = web::SerializableUserData::Create(); 74 _userData = web::SerializableUserData::Create();
78 _userData->Decode(decoder); 75 _userData->Decode(decoder);
79 } 76 }
80 return self; 77 return self;
81 } 78 }
82 79
83 - (void)encodeWithCoder:(NSCoder*)coder { 80 - (void)encodeWithCoder:(NSCoder*)coder {
84 [coder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey]; 81 [coder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey];
85 [coder encodeObject:self.windowName forKey:kWindowNameKey];
86 [coder encodeInt:self.currentNavigationIndex 82 [coder encodeInt:self.currentNavigationIndex
87 forKey:kCurrentNavigationIndexKey]; 83 forKey:kCurrentNavigationIndexKey];
88 [coder encodeInt:self.previousNavigationIndex 84 [coder encodeInt:self.previousNavigationIndex
89 forKey:kPreviousNavigationIndexKey]; 85 forKey:kPreviousNavigationIndexKey];
90 [coder encodeDouble:self.lastVisitedTimestamp 86 [coder encodeDouble:self.lastVisitedTimestamp
91 forKey:kLastVisitedTimestampKey]; 87 forKey:kLastVisitedTimestampKey];
92 [coder encodeObject:self.itemStorages forKey:kItemStoragesKey]; 88 [coder encodeObject:self.itemStorages forKey:kItemStoragesKey];
93 [coder encodeObject:self.sessionCertificatePolicyManager 89 [coder encodeObject:self.sessionCertificatePolicyManager
94 forKey:kCertificatePolicyManagerKey]; 90 forKey:kCertificatePolicyManagerKey];
95 if (_userData) 91 if (_userData)
96 _userData->Encode(coder); 92 _userData->Encode(coder);
97 } 93 }
98 94
99 @end 95 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698