| 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 <cstdint> | 7 #include <cstdint> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 | 355 |
| 356 - (BOOL)restoreSessionWindow:(SessionWindowIOS*)window { | 356 - (BOOL)restoreSessionWindow:(SessionWindowIOS*)window { |
| 357 return [self restoreSessionWindow:window persistState:YES]; | 357 return [self restoreSessionWindow:window persistState:YES]; |
| 358 } | 358 } |
| 359 | 359 |
| 360 - (void)saveSessionImmediately:(BOOL)immediately { | 360 - (void)saveSessionImmediately:(BOOL)immediately { |
| 361 // Do nothing if there are tabs in the model but no selected tab. This is | 361 // Do nothing if there are tabs in the model but no selected tab. This is |
| 362 // a transitional state. | 362 // a transitional state. |
| 363 if ((!self.currentTab && _webStateList->count()) || !_browserState) | 363 if ((!self.currentTab && _webStateList->count()) || !_browserState) |
| 364 return; | 364 return; |
| 365 [_sessionService saveWindow:self.windowForSavingSession | 365 NSString* statePath = |
| 366 forBrowserState:_browserState | 366 base::SysUTF8ToNSString(_browserState->GetStatePath().AsUTF8Unsafe()); |
| 367 immediately:immediately]; | 367 NSString* sessionPath = [_sessionService sessionPathForDirectory:statePath]; |
| 368 [_sessionService saveSessionWindow:self.windowForSavingSession |
| 369 sessionPath:sessionPath |
| 370 immediately:immediately]; |
| 368 } | 371 } |
| 369 | 372 |
| 370 - (Tab*)tabAtIndex:(NSUInteger)index { | 373 - (Tab*)tabAtIndex:(NSUInteger)index { |
| 371 DCHECK_LE(index, static_cast<NSUInteger>(INT_MAX)); | 374 DCHECK_LE(index, static_cast<NSUInteger>(INT_MAX)); |
| 372 return LegacyTabHelper::GetTabForWebState( | 375 return LegacyTabHelper::GetTabForWebState( |
| 373 _webStateList->GetWebStateAt(static_cast<int>(index))); | 376 _webStateList->GetWebStateAt(static_cast<int>(index))); |
| 374 } | 377 } |
| 375 | 378 |
| 376 - (NSUInteger)indexOfTab:(Tab*)tab { | 379 - (NSUInteger)indexOfTab:(Tab*)tab { |
| 377 int index = _webStateList->GetIndexOfWebState(tab.webState); | 380 int index = _webStateList->GetIndexOfWebState(tab.webState); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 790 } | 793 } |
| 791 | 794 |
| 792 // Called when UIApplicationWillEnterForegroundNotification is received. | 795 // Called when UIApplicationWillEnterForegroundNotification is received. |
| 793 - (void)applicationWillEnterForeground:(NSNotification*)notify { | 796 - (void)applicationWillEnterForeground:(NSNotification*)notify { |
| 794 if (_tabUsageRecorder) { | 797 if (_tabUsageRecorder) { |
| 795 _tabUsageRecorder->AppWillEnterForeground(); | 798 _tabUsageRecorder->AppWillEnterForeground(); |
| 796 } | 799 } |
| 797 } | 800 } |
| 798 | 801 |
| 799 @end | 802 @end |
| OLD | NEW |