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

Unified Diff: ios/chrome/browser/tabs/tab_model.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, 11 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/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;
« no previous file with comments | « ios/chrome/browser/sessions/session_window_unittest.mm ('k') | ios/chrome/browser/tabs/tab_model_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698