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

Unified Diff: ios/web/navigation/crw_serialized_navigation_manager.mm

Issue 1360993002: Moved NavigationManagerImpl serialization out of CRWSessionController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Eugene's comments Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/navigation/crw_serialized_navigation_manager.mm
diff --git a/ios/web/navigation/crw_serialized_navigation_manager.mm b/ios/web/navigation/crw_serialized_navigation_manager.mm
new file mode 100644
index 0000000000000000000000000000000000000000..ea90d7fdae65cb7fb81b275cfcb8362cd688f530
--- /dev/null
+++ b/ios/web/navigation/crw_serialized_navigation_manager.mm
@@ -0,0 +1,105 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/web/navigation/crw_serialized_navigation_manager.h"
+
+#include "base/mac/objc_property_releaser.h"
+#import "ios/web/navigation/crw_session_certificate_policy_manager.h"
+
+namespace {
+// Serialization keys used in NSCoding functions.
+NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager";
+NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex";
+NSString* const kEntriesKey = @"entries";
+NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp";
+NSString* const kOpenerIDKey = @"openerId";
+NSString* const kOpenedByDOMKey = @"openedByDOM";
+NSString* const kOpenerNavigationIndexKey = @"openerNavigationIndex";
+NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex";
+NSString* const kTabIDKey = @"tabId";
+NSString* const kWindowNameKey = @"windowName";
+NSString* const kXCallbackParametersKey = @"xCallbackParameters";
+}
+
+@interface CRWSerializedNavigationManager () {
+ base::mac::ObjCPropertyReleaser
+ _propertyReleaser_CRWSerializedNavigationManager;
+}
+@end
+
+@implementation CRWSerializedNavigationManager
+
+@synthesize tabID = _tabID;
+@synthesize openerID = _openerID;
+@synthesize openedByDOM = _openedByDOM;
+@synthesize openerNavigationIndex = _openerNavigationIndex;
+@synthesize windowName = _windowName;
+@synthesize currentNavigationIndex = _currentNavigationIndex;
+@synthesize previousNavigationIndex = _previousNavigationIndex;
+@synthesize lastVisitedTimestamp = _lastVisitedTimestamp;
+@synthesize entries = _entries;
+@synthesize sessionCertificatePolicyManager = _sessionCertificatePolicyManager;
+@synthesize XCallbackParameters = _XCallbackParameters;
+
+- (instancetype)init {
+ self = [super init];
+ if (self) {
+ _propertyReleaser_CRWSerializedNavigationManager.Init(
+ self, [CRWSerializedNavigationManager class]);
+ }
+ return self;
+}
+
+- (instancetype)initWithCoder:(nonnull NSCoder*)decoder {
+ self = [super init];
+ if (self) {
+ _tabID = [[decoder decodeObjectForKey:kTabIDKey] copy];
+ _windowName = [[decoder decodeObjectForKey:kWindowNameKey] copy];
+ _openerID = [[decoder decodeObjectForKey:kOpenerIDKey] copy];
+ _openedByDOM = [decoder decodeBoolForKey:kOpenedByDOMKey];
+ _openerNavigationIndex =
+ [decoder decodeIntForKey:kOpenerNavigationIndexKey];
+ _currentNavigationIndex =
+ [decoder decodeIntForKey:kCurrentNavigationIndexKey];
+ _previousNavigationIndex =
+ [decoder decodeIntForKey:kPreviousNavigationIndexKey];
+ _lastVisitedTimestamp =
+ [decoder decodeDoubleForKey:kLastVisitedTimestampKey];
+ _entries = [[NSMutableArray alloc]
+ initWithArray:[decoder decodeObjectForKey:kEntriesKey]];
+ // Prior to M34, 0 was used as "no index" instead of -1; adjust for that.
+ if (!_entries.count)
+ _currentNavigationIndex = -1;
+ _sessionCertificatePolicyManager =
+ [[decoder decodeObjectForKey:kCertificatePolicyManagerKey] retain];
+ if (!_sessionCertificatePolicyManager) {
+ _sessionCertificatePolicyManager =
+ [[CRWSessionCertificatePolicyManager alloc] init];
+ }
+ _XCallbackParameters =
+ [[decoder decodeObjectForKey:kXCallbackParametersKey] retain];
+ }
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder*)coder {
+ [coder encodeObject:self.tabID forKey:kTabIDKey];
+ [coder encodeObject:self.openerID forKey:kOpenerIDKey];
+ [coder encodeBool:self.openedByDOM forKey:kOpenedByDOMKey];
+ [coder encodeInt:self.openerNavigationIndex forKey:kOpenerNavigationIndexKey];
+ [coder encodeObject:self.windowName forKey:kWindowNameKey];
+ [coder encodeInt:self.currentNavigationIndex
+ forKey:kCurrentNavigationIndexKey];
+ [coder encodeInt:self.previousNavigationIndex
+ forKey:kPreviousNavigationIndexKey];
+ [coder encodeDouble:self.lastVisitedTimestamp
+ forKey:kLastVisitedTimestampKey];
+ [coder encodeObject:self.entries forKey:kEntriesKey];
+ [coder encodeObject:self.sessionCertificatePolicyManager
+ forKey:kCertificatePolicyManagerKey];
+ [coder encodeObject:self.XCallbackParameters forKey:kXCallbackParametersKey];
+ // rendererInitiated is deliberately not preserved, as upstream.
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698