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

Side by Side Diff: ios/web/navigation/crw_session_controller.mm

Issue 1360993002: Moved NavigationManagerImpl serialization out of CRWSessionController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compilation fix after rebase Created 3 years, 10 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/navigation/crw_session_controller.h" 5 #import "ios/web/navigation/crw_session_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 14 matching lines...) Expand all
25 #include "ios/web/navigation/time_smoother.h" 25 #include "ios/web/navigation/time_smoother.h"
26 #include "ios/web/public/browser_state.h" 26 #include "ios/web/public/browser_state.h"
27 #include "ios/web/public/browser_url_rewriter.h" 27 #include "ios/web/public/browser_url_rewriter.h"
28 #include "ios/web/public/referrer.h" 28 #include "ios/web/public/referrer.h"
29 #include "ios/web/public/ssl_status.h" 29 #include "ios/web/public/ssl_status.h"
30 30
31 #if !defined(__has_feature) || !__has_feature(objc_arc) 31 #if !defined(__has_feature) || !__has_feature(objc_arc)
32 #error "This file requires ARC support." 32 #error "This file requires ARC support."
33 #endif 33 #endif
34 34
35 namespace {
36 NSString* const kCertificatePolicyManagerKey = @"certificatePolicyManager";
37 NSString* const kCurrentNavigationIndexKey = @"currentNavigationIndex";
38 NSString* const kEntriesKey = @"entries";
39 NSString* const kLastVisitedTimestampKey = @"lastVisitedTimestamp";
40 NSString* const kOpenerIdKey = @"openerId";
41 NSString* const kOpenedByDOMKey = @"openedByDOM";
42 NSString* const kOpenerNavigationIndexKey = @"openerNavigationIndex";
43 NSString* const kPreviousNavigationIndexKey = @"previousNavigationIndex";
44 NSString* const kTabIdKey = @"tabId";
45 NSString* const kWindowNameKey = @"windowName";
46 } // namespace
47
48 @interface CRWSessionController () { 35 @interface CRWSessionController () {
49 // Weak pointer back to the owning NavigationManager. This is to facilitate 36 // Weak pointer back to the owning NavigationManager. This is to facilitate
50 // the incremental merging of the two classes. 37 // the incremental merging of the two classes.
51 web::NavigationManagerImpl* _navigationManager; 38 web::NavigationManagerImpl* _navigationManager;
52 39
53 NSString* _tabId; // Unique id of the tab. 40 NSString* _tabId; // Unique id of the tab.
54 NSString* _openerId; // Id of tab who opened this tab, empty/nil if none. 41 NSString* _openerId; // Id of tab who opened this tab, empty/nil if none.
55 // Navigation index of the tab which opened this tab. Do not rely on the 42 // Navigation index of the tab which opened this tab. Do not rely on the
56 // value of this member variable to indicate whether or not this tab has 43 // value of this member variable to indicate whether or not this tab has
57 // an opener, as both 0 and -1 are used as navigationIndex values. 44 // an opener, as both 0 and -1 are used as navigationIndex values.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Redefine as readwrite. 90 // Redefine as readwrite.
104 @property(nonatomic, readwrite, assign) NSInteger currentNavigationIndex; 91 @property(nonatomic, readwrite, assign) NSInteger currentNavigationIndex;
105 92
106 // TODO(rohitrao): These properties must be redefined readwrite to work around a 93 // TODO(rohitrao): These properties must be redefined readwrite to work around a
107 // clang bug. crbug.com/228650 94 // clang bug. crbug.com/228650
108 @property(nonatomic, readwrite, copy) NSString* tabId; 95 @property(nonatomic, readwrite, copy) NSString* tabId;
109 @property(nonatomic, readwrite, strong) NSArray* entries; 96 @property(nonatomic, readwrite, strong) NSArray* entries;
110 @property(nonatomic, readwrite, strong) 97 @property(nonatomic, readwrite, strong)
111 CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager; 98 CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager;
112 99
100 // Expose setters for serialization properties. These are exposed in a category
101 // in NavigationManagerStorageBuilder, and will be removed as ownership of
102 // their backing ivars moves to NavigationManagerImpl.
103 @property(nonatomic, readwrite, copy) NSString* openerId;
104 @property(nonatomic, readwrite, getter=isOpenedByDOM) BOOL openedByDOM;
105 @property(nonatomic, readwrite, assign) NSInteger openerNavigationIndex;
106 @property(nonatomic, readwrite, assign) NSInteger previousNavigationIndex;
107
113 - (NSString*)uniqueID; 108 - (NSString*)uniqueID;
114 // Removes all entries after currentNavigationIndex_. 109 // Removes all entries after currentNavigationIndex_.
115 - (void)clearForwardEntries; 110 - (void)clearForwardEntries;
116 // Discards the transient entry, if any. 111 // Discards the transient entry, if any.
117 - (void)discardTransientEntry; 112 - (void)discardTransientEntry;
118 // Create a new autoreleased session entry. 113 // Create a new autoreleased session entry.
119 - (CRWSessionEntry*)sessionEntryWithURL:(const GURL&)url 114 - (CRWSessionEntry*)sessionEntryWithURL:(const GURL&)url
120 referrer:(const web::Referrer&)referrer 115 referrer:(const web::Referrer&)referrer
121 transition:(ui::PageTransition)transition 116 transition:(ui::PageTransition)transition
122 useDesktopUserAgent:(BOOL)useDesktopUserAgent 117 useDesktopUserAgent:(BOOL)useDesktopUserAgent
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 186 }
192 _previousNavigationIndex = -1; 187 _previousNavigationIndex = -1;
193 _pendingEntryIndex = -1; 188 _pendingEntryIndex = -1;
194 _lastVisitedTimestamp = [[NSDate date] timeIntervalSince1970]; 189 _lastVisitedTimestamp = [[NSDate date] timeIntervalSince1970];
195 _sessionCertificatePolicyManager = 190 _sessionCertificatePolicyManager =
196 [[CRWSessionCertificatePolicyManager alloc] init]; 191 [[CRWSessionCertificatePolicyManager alloc] init];
197 } 192 }
198 return self; 193 return self;
199 } 194 }
200 195
201 - (id)initWithCoder:(NSCoder*)aDecoder {
202 self = [super init];
203 if (self) {
204 NSString* uuid = [aDecoder decodeObjectForKey:kTabIdKey];
205 if (!uuid)
206 uuid = [self uniqueID];
207
208 self.windowName = [aDecoder decodeObjectForKey:kWindowNameKey];
209 _tabId = [uuid copy];
210 _openerId = [[aDecoder decodeObjectForKey:kOpenerIdKey] copy];
211 _openedByDOM = [aDecoder decodeBoolForKey:kOpenedByDOMKey];
212 _openerNavigationIndex =
213 [aDecoder decodeIntForKey:kOpenerNavigationIndexKey];
214 _currentNavigationIndex =
215 [aDecoder decodeIntForKey:kCurrentNavigationIndexKey];
216 _previousNavigationIndex =
217 [aDecoder decodeIntForKey:kPreviousNavigationIndexKey];
218 _pendingEntryIndex = -1;
219 _lastVisitedTimestamp =
220 [aDecoder decodeDoubleForKey:kLastVisitedTimestampKey];
221 NSMutableArray* temp =
222 [NSMutableArray arrayWithArray:
223 [aDecoder decodeObjectForKey:kEntriesKey]];
224 _entries = temp;
225 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that.
226 if (![_entries count])
227 _currentNavigationIndex = -1;
228 _sessionCertificatePolicyManager =
229 [aDecoder decodeObjectForKey:kCertificatePolicyManagerKey];
230 if (!_sessionCertificatePolicyManager) {
231 _sessionCertificatePolicyManager =
232 [[CRWSessionCertificatePolicyManager alloc] init];
233 }
234 }
235 return self;
236 }
237
238 - (void)encodeWithCoder:(NSCoder*)aCoder {
239 [aCoder encodeObject:_tabId forKey:kTabIdKey];
240 [aCoder encodeObject:_openerId forKey:kOpenerIdKey];
241 [aCoder encodeBool:_openedByDOM forKey:kOpenedByDOMKey];
242 [aCoder encodeInt:_openerNavigationIndex forKey:kOpenerNavigationIndexKey];
243 [aCoder encodeObject:_windowName forKey:kWindowNameKey];
244 [aCoder encodeInt:_currentNavigationIndex forKey:kCurrentNavigationIndexKey];
245 [aCoder encodeInt:_previousNavigationIndex
246 forKey:kPreviousNavigationIndexKey];
247 [aCoder encodeDouble:_lastVisitedTimestamp forKey:kLastVisitedTimestampKey];
248 [aCoder encodeObject:_entries forKey:kEntriesKey];
249 [aCoder encodeObject:_sessionCertificatePolicyManager
250 forKey:kCertificatePolicyManagerKey];
251 // rendererInitiated is deliberately not preserved, as upstream.
252 }
253
254 - (id)copyWithZone:(NSZone*)zone { 196 - (id)copyWithZone:(NSZone*)zone {
255 CRWSessionController* copy = [[[self class] alloc] init]; 197 CRWSessionController* copy = [[[self class] alloc] init];
256 copy->_tabId = [_tabId copy]; 198 copy->_tabId = [_tabId copy];
257 copy->_openerId = [_openerId copy]; 199 copy->_openerId = [_openerId copy];
258 copy->_openedByDOM = _openedByDOM; 200 copy->_openedByDOM = _openedByDOM;
259 copy->_openerNavigationIndex = _openerNavigationIndex; 201 copy->_openerNavigationIndex = _openerNavigationIndex;
260 copy.windowName = self.windowName; 202 copy.windowName = self.windowName;
261 copy->_currentNavigationIndex = _currentNavigationIndex; 203 copy->_currentNavigationIndex = _currentNavigationIndex;
262 copy->_previousNavigationIndex = _previousNavigationIndex; 204 copy->_previousNavigationIndex = _previousNavigationIndex;
263 copy->_pendingEntryIndex = _pendingEntryIndex; 205 copy->_pendingEntryIndex = _pendingEntryIndex;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
743 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; 685 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)];
744 } 686 }
745 687
746 - (BOOL)isRedirectTransitionForEntryAtIndex:(NSInteger)index { 688 - (BOOL)isRedirectTransitionForEntryAtIndex:(NSInteger)index {
747 ui::PageTransition transition = 689 ui::PageTransition transition =
748 [_entries[index] navigationItem]->GetTransitionType(); 690 [_entries[index] navigationItem]->GetTransitionType();
749 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; 691 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO;
750 } 692 }
751 693
752 @end 694 @end
OLDNEW
« no previous file with comments | « ios/web/navigation/crw_session_controller.h ('k') | ios/web/navigation/navigation_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698