| 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 efc46dbd381a8a777b9229df063bd25289a785ca..e1247e4960ed500f581bac3af2f48b546304d311 100644
|
| --- a/ios/chrome/browser/tabs/tab_model.mm
|
| +++ b/ios/chrome/browser/tabs/tab_model.mm
|
| @@ -66,14 +66,17 @@
|
| namespace {
|
|
|
| // Updates CRWSessionCertificatePolicyManager's certificate policy cache.
|
| -void UpdateCertificatePolicyCacheFromWebState(web::WebStateImpl* web_state) {
|
| +void UpdateCertificatePolicyCacheFromWebState(web::WebState* web_state) {
|
| DCHECK([NSThread isMainThread]);
|
| DCHECK(web_state);
|
| scoped_refptr<web::CertificatePolicyCache> policy_cache =
|
| web::BrowserState::GetCertificatePolicyCache(
|
| web_state->GetBrowserState());
|
| - CRWSessionController* controller =
|
| - web_state->GetNavigationManagerImpl().GetSessionController();
|
| + // TODO(crbug.com/454984): Remove CRWSessionController usage once certificate
|
| + // policy manager is moved to NavigationManager.
|
| + CRWSessionController* controller = static_cast<web::WebStateImpl*>(web_state)
|
| + ->GetNavigationManagerImpl()
|
| + .GetSessionController();
|
| [[controller sessionCertificatePolicyManager]
|
| updateCertificatePolicyCache:policy_cache];
|
| }
|
| @@ -264,8 +267,9 @@ - (instancetype)initWithSessionWindow:(SessionWindowIOS*)window
|
|
|
| NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
|
| if (window) {
|
| - while (window.unclaimedSessions) {
|
| - std::unique_ptr<web::WebStateImpl> webState = [window nextSession];
|
| + for (CRWNavigationManagerSerialization* session in window.sessions) {
|
| + web::WebState::CreateParams params(_browserState, session);
|
| + std::unique_ptr<web::WebState> webState = web::WebState::Create(params);
|
| DCHECK_EQ(webState->GetBrowserState(), _browserState);
|
| // Restore the CertificatePolicyCache.
|
| UpdateCertificatePolicyCacheFromWebState(webState.get());
|
| @@ -328,12 +332,14 @@ - (instancetype)init {
|
| - (BOOL)restoreSessionWindow:(SessionWindowIOS*)window {
|
| DCHECK(_browserState);
|
| DCHECK(window);
|
| - if (!window.unclaimedSessions)
|
| + NSArray* sessions = window.sessions;
|
| + if (!sessions.count)
|
| return NO;
|
| size_t oldCount = self.count;
|
| size_t index = oldCount;
|
| - while (window.unclaimedSessions) {
|
| - std::unique_ptr<web::WebStateImpl> webState = [window nextSession];
|
| + for (CRWNavigationManagerSerialization* session in sessions) {
|
| + web::WebState::CreateParams params(_browserState, session);
|
| + std::unique_ptr<web::WebState> webState = web::WebState::Create(params);
|
| DCHECK_EQ(webState->GetBrowserState(), _browserState);
|
| Tab* tab = [self insertTabWithWebState:std::move(webState) atIndex:index++];
|
| tab.webController.usePlaceholderOverlay = YES;
|
| @@ -855,10 +861,9 @@ - (SessionWindowIOS*)windowForSavingSession {
|
| // window may never be saved (if another call comes in before the delay).
|
| SessionWindowIOS* window = [[[SessionWindowIOS alloc] init] autorelease];
|
| for (Tab* tab in self) {
|
| - DCHECK(tab.webStateImpl);
|
| - std::unique_ptr<web::WebStateImpl> webStateCopy(
|
| - tab.webStateImpl->CopyForSessionWindow());
|
| - [window addSession:std::move(webStateCopy)];
|
| + web::WebState* webState = tab.webState;
|
| + DCHECK(webState);
|
| + [window addSerializedSession:webState->BuildSerializedNavigationManager()];
|
| }
|
| window.selectedIndex = [self indexOfTab:_currentTab];
|
| return window;
|
|
|