| 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 de7719be65684299990d49c6ebf5ef911635363c..8c8f6467110cdb04bbadd50158ae5090a0478cce 100644
|
| --- a/ios/chrome/browser/tabs/tab_model.mm
|
| +++ b/ios/chrome/browser/tabs/tab_model.mm
|
| @@ -66,13 +66,17 @@
|
| namespace {
|
|
|
| // Updates CRWSessionCertificatePolicyManager's certificate policy cache.
|
| -void UpdateCertificatePolicyCacheFromWebState(web::WebStateImpl* webState) {
|
| +void UpdateCertificatePolicyCacheFromWebState(web::WebState* web_state) {
|
| DCHECK([NSThread isMainThread]);
|
| - DCHECK(webState);
|
| + DCHECK(web_state);
|
| scoped_refptr<web::CertificatePolicyCache> policy_cache =
|
| - web::BrowserState::GetCertificatePolicyCache(webState->GetBrowserState());
|
| - CRWSessionController* controller =
|
| - webState->GetNavigationManagerImpl().GetSessionController();
|
| + web::BrowserState::GetCertificatePolicyCache(
|
| + web_state->GetBrowserState());
|
| + // 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];
|
| }
|
| @@ -254,8 +258,10 @@ - (instancetype)initWithSessionWindow:(SessionWindowIOS*)window
|
| _tabs.reset([[NSMutableArray alloc] init]);
|
| NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
|
| if (window) {
|
| - while (window.unclaimedSessions) {
|
| - std::unique_ptr<web::WebStateImpl> webState = [window nextSession];
|
| + web::WebState::CreateParams params(_browserState);
|
| + for (CRWNavigationManagerStorage* session in window.sessions) {
|
| + std::unique_ptr<web::WebState> webState =
|
| + web::WebState::Create(params, session);
|
| DCHECK_EQ(webState->GetBrowserState(), _browserState);
|
| // Restore the CertificatePolicyCache.
|
| UpdateCertificatePolicyCacheFromWebState(webState.get());
|
| @@ -315,12 +321,15 @@ - (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 = [_tabs count];
|
| size_t index = oldCount;
|
| - while (window.unclaimedSessions) {
|
| - std::unique_ptr<web::WebStateImpl> webState = [window nextSession];
|
| + web::WebState::CreateParams params(_browserState);
|
| + for (CRWNavigationManagerStorage* session in sessions) {
|
| + std::unique_ptr<web::WebState> webState =
|
| + web::WebState::Create(params, session);
|
| DCHECK_EQ(webState->GetBrowserState(), _browserState);
|
| Tab* tab = [self insertTabWithWebState:std::move(webState) atIndex:index++];
|
| tab.webController.usePlaceholderOverlay = YES;
|
| @@ -848,11 +857,10 @@ - (SessionWindowIOS*)windowForSavingSession {
|
| // 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* window = [[[SessionWindowIOS alloc] init] autorelease];
|
| - for (Tab* tab in _tabs.get()) {
|
| - DCHECK(tab.webStateImpl);
|
| - std::unique_ptr<web::WebStateImpl> webStateCopy(
|
| - tab.webStateImpl->CopyForSessionWindow());
|
| - [window addSession:std::move(webStateCopy)];
|
| + for (Tab* tab in self) {
|
| + web::WebState* webState = tab.webState;
|
| + DCHECK(webState);
|
| + [window addSerializedSession:webState->BuildSerializedNavigationManager()];
|
| }
|
| window.selectedIndex = [self indexOfTab:_currentTab];
|
| return window;
|
|
|