| OLD | NEW |
| 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/chrome/browser/tabs/tab_model.h" | 5 #import "ios/chrome/browser/tabs/tab_model.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 [_currentTab recordStateInHistory]; | 802 [_currentTab recordStateInHistory]; |
| 803 | 803 |
| 804 // Build the array of sessions. Copy the session objects as the saving will | 804 // Build the array of sessions. Copy the session objects as the saving will |
| 805 // be done on a separate thread. | 805 // be done on a separate thread. |
| 806 // TODO(crbug.com/661986): This could get expensive especially since this | 806 // TODO(crbug.com/661986): This could get expensive especially since this |
| 807 // window may never be saved (if another call comes in before the delay). | 807 // window may never be saved (if another call comes in before the delay). |
| 808 SessionWindowIOS* window = [[[SessionWindowIOS alloc] init] autorelease]; | 808 SessionWindowIOS* window = [[[SessionWindowIOS alloc] init] autorelease]; |
| 809 for (Tab* tab in self) { | 809 for (Tab* tab in self) { |
| 810 web::WebState* webState = tab.webState; | 810 web::WebState* webState = tab.webState; |
| 811 DCHECK(webState); | 811 DCHECK(webState); |
| 812 [window addSerializedSession:webState->BuildSerializedNavigationManager()]; | 812 [window addSerializedSessionStorage:webState->BuildSessionStorage()]; |
| 813 } | 813 } |
| 814 window.selectedIndex = [self indexOfTab:_currentTab]; | 814 window.selectedIndex = [self indexOfTab:_currentTab]; |
| 815 return window; | 815 return window; |
| 816 } | 816 } |
| 817 | 817 |
| 818 - (BOOL)isNTPTab:(Tab*)tab { | 818 - (BOOL)isNTPTab:(Tab*)tab { |
| 819 std::string host = tab.url.host(); | 819 std::string host = tab.url.host(); |
| 820 return host == kChromeUINewTabHost || host == kChromeUIBookmarksHost; | 820 return host == kChromeUINewTabHost || host == kChromeUIBookmarksHost; |
| 821 } | 821 } |
| 822 | 822 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 | 956 |
| 957 NSArray* sessions = window.sessions; | 957 NSArray* sessions = window.sessions; |
| 958 if (!sessions.count) | 958 if (!sessions.count) |
| 959 return NO; | 959 return NO; |
| 960 | 960 |
| 961 size_t oldCount = [_tabs count]; | 961 size_t oldCount = [_tabs count]; |
| 962 web::WebState::CreateParams params(_browserState); | 962 web::WebState::CreateParams params(_browserState); |
| 963 scoped_refptr<web::CertificatePolicyCache> policyCache = | 963 scoped_refptr<web::CertificatePolicyCache> policyCache = |
| 964 web::BrowserState::GetCertificatePolicyCache(_browserState); | 964 web::BrowserState::GetCertificatePolicyCache(_browserState); |
| 965 | 965 |
| 966 for (CRWNavigationManagerStorage* session in sessions) { | 966 for (CRWSessionStorage* session in sessions) { |
| 967 std::unique_ptr<web::WebState> webState = | 967 std::unique_ptr<web::WebState> webState = |
| 968 web::WebState::Create(params, session); | 968 web::WebState::Create(params, session); |
| 969 DCHECK_EQ(webState->GetBrowserState(), _browserState); | 969 DCHECK_EQ(webState->GetBrowserState(), _browserState); |
| 970 Tab* tab = | 970 Tab* tab = |
| 971 [self insertTabWithWebState:std::move(webState) atIndex:[_tabs count]]; | 971 [self insertTabWithWebState:std::move(webState) atIndex:[_tabs count]]; |
| 972 tab.webController.usePlaceholderOverlay = YES; | 972 tab.webController.usePlaceholderOverlay = YES; |
| 973 | 973 |
| 974 // Restore the CertificatePolicyCache (note that webState is invalid after | 974 // Restore the CertificatePolicyCache (note that webState is invalid after |
| 975 // passing it via move semantic to -insertTabWithWebState:atIndex:). | 975 // passing it via move semantic to -insertTabWithWebState:atIndex:). |
| 976 UpdateCertificatePolicyCacheFromWebState(policyCache, tab.webState); | 976 UpdateCertificatePolicyCacheFromWebState(policyCache, tab.webState); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 web::NavigationManager::WebLoadParams params(URL); | 1078 web::NavigationManager::WebLoadParams params(URL); |
| 1079 params.referrer = referrer; | 1079 params.referrer = referrer; |
| 1080 params.transition_type = ui::PAGE_TRANSITION_TYPED; | 1080 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
| 1081 [[tab webController] loadWithParams:params]; | 1081 [[tab webController] loadWithParams:params]; |
| 1082 [tab webController].webUsageEnabled = webUsageEnabled_; | 1082 [tab webController].webUsageEnabled = webUsageEnabled_; |
| 1083 [self insertTab:tab atIndex:index]; | 1083 [self insertTab:tab atIndex:index]; |
| 1084 return tab; | 1084 return tab; |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 @end | 1087 @end |
| OLD | NEW |