| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_selected_tab_observer.h" | 5 #import "ios/chrome/browser/tabs/tab_model_selected_tab_observer.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" | 8 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" |
| 9 #import "ios/chrome/browser/tabs/tab.h" | 9 #import "ios/chrome/browser/tabs/tab.h" |
| 10 #import "ios/chrome/browser/tabs/tab_model.h" | 10 #import "ios/chrome/browser/tabs/tab_model.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 // Save state, such as scroll position, ... of the old selected Tab. | 38 // Save state, such as scroll position, ... of the old selected Tab. |
| 39 oldTab = LegacyTabHelper::GetTabForWebState(oldWebState); | 39 oldTab = LegacyTabHelper::GetTabForWebState(oldWebState); |
| 40 if (userAction) | 40 if (userAction) |
| 41 [oldTab recordStateInHistory]; | 41 [oldTab recordStateInHistory]; |
| 42 | 42 |
| 43 // Avoid artificially extending the lifetime of oldTab until the global | 43 // Avoid artificially extending the lifetime of oldTab until the global |
| 44 // autoreleasepool is purged. | 44 // autoreleasepool is purged. |
| 45 @autoreleasepool { | 45 @autoreleasepool { |
| 46 [[NSNotificationCenter defaultCenter] | 46 [[NSNotificationCenter defaultCenter] |
| 47 postNotificationName:kTabModelTabDeselectedNotification | 47 postNotificationName:kTabModelTabDeselectedNotification |
| 48 object:@{kTabModelTabKey : oldTab}]; | 48 object:_tabModel |
| 49 userInfo:@{kTabModelTabKey : oldTab}]; |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 | 52 |
| 52 if (newWebState) { | 53 if (newWebState) { |
| 53 newTab = LegacyTabHelper::GetTabForWebState(newWebState); | 54 newTab = LegacyTabHelper::GetTabForWebState(newWebState); |
| 54 [newTab updateLastVisitedTimestamp]; | 55 [newTab updateLastVisitedTimestamp]; |
| 55 | 56 |
| 56 // Persist the session state. | 57 // Persist the session state. |
| 57 if (newTab.loadFinished) | 58 if (newTab.loadFinished) |
| 58 [_tabModel saveSessionImmediately:NO]; | 59 [_tabModel saveSessionImmediately:NO]; |
| 59 } | 60 } |
| 60 } | 61 } |
| 61 | 62 |
| 62 @end | 63 @end |
| OLD | NEW |