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

Unified Diff: ios/chrome/browser/tabs/tab_model.mm

Issue 2808773004: [ios] Change WebStateList serialization method to use SessionWindowIOS. (Closed)
Patch Set: Rename //ios/chrome/browser/sessions:session_window_ios target. Created 3 years, 8 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
« no previous file with comments | « ios/chrome/browser/tabs/BUILD.gn ('k') | ios/chrome/browser/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/tab_model.mm
diff --git a/ios/chrome/browser/tabs/tab_model.mm b/ios/chrome/browser/tabs/tab_model.mm
index 050cdcfff85ea0d5d28412dad39f862bed903ad1..f3dd565fa6ec1abed5e46fb4a22da16a3dcff4be 100644
--- a/ios/chrome/browser/tabs/tab_model.mm
+++ b/ios/chrome/browser/tabs/tab_model.mm
@@ -700,10 +700,8 @@ void CleanCertificatePolicyCache(
// be done on a separate thread.
// TODO(crbug.com/661986): This could get expensive especially since this
// window may never be saved (if another call comes in before the delay).
- SessionWindowIOS* sessionWindow = [[[SessionWindowIOS alloc]
- initWithSessions:SerializeWebStateList(_webStateList.get())
- selectedIndex:[self indexOfTab:self.currentTab]] autorelease];
- return [[SessionIOS alloc] initWithWindows:@[ sessionWindow ]];
+ return [[SessionIOS alloc]
+ initWithWindows:@[ SerializeWebStateList(_webStateList.get()) ]];
}
- (void)postNotificationName:(NSString*)notificationName withTab:(Tab*)tab {
@@ -723,28 +721,30 @@ void CleanCertificatePolicyCache(
DCHECK(_browserState);
DCHECK(window);
- NSArray* sessions = window.sessions;
- if (!sessions.count)
+ if (!window.sessions.count)
return NO;
int oldCount = _webStateList->count();
DCHECK_GE(oldCount, 0);
+ if (persistState && self.currentTab)
+ [self.currentTab recordStateInHistory];
+
web::WebState::CreateParams createParams(_browserState);
DeserializeWebStateList(
- _webStateList.get(), sessions,
+ _webStateList.get(), window,
base::BindRepeating(&web::WebState::CreateWithStorageSession,
createParams));
DCHECK_GT(_webStateList->count(), oldCount);
int restoredCount = _webStateList->count() - oldCount;
- DCHECK_EQ(sessions.count, static_cast<NSUInteger>(restoredCount));
+ DCHECK_EQ(window.sessions.count, static_cast<NSUInteger>(restoredCount));
scoped_refptr<web::CertificatePolicyCache> policyCache =
web::BrowserState::GetCertificatePolicyCache(_browserState);
base::scoped_nsobject<NSMutableArray<Tab*>> restoredTabs(
- [[NSMutableArray alloc] initWithCapacity:sessions.count]);
+ [[NSMutableArray alloc] initWithCapacity:window.sessions.count]);
for (int index = oldCount; index < _webStateList->count(); ++index) {
web::WebState* webState = _webStateList->GetWebStateAt(index);
@@ -759,17 +759,6 @@ void CleanCertificatePolicyCache(
[restoredTabs addObject:tab];
}
- // Update the selected tab if there was a selected Tab in the saved session.
- if (window.selectedIndex != NSNotFound) {
- NSUInteger selectedIndex = window.selectedIndex + oldCount;
- DCHECK_LT(selectedIndex, self.count);
- DCHECK([self tabAtIndex:selectedIndex]);
-
- if (persistState && self.currentTab)
- [self.currentTab recordStateInHistory];
- _webStateList->ActivateWebStateAt(static_cast<int>(selectedIndex));
- }
-
// If there was only one tab and it was the new tab page, clobber it.
BOOL closedNTPTab = NO;
if (oldCount == 1) {
« no previous file with comments | « ios/chrome/browser/tabs/BUILD.gn ('k') | ios/chrome/browser/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698