| 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_observers_bridge.h" | 5 #import "ios/chrome/browser/tabs/tab_model_observers_bridge.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_model.h" | 9 #import "ios/chrome/browser/tabs/tab_model.h" |
| 10 #import "ios/chrome/browser/tabs/tab_model_observers.h" | 10 #import "ios/chrome/browser/tabs/tab_model_observers.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 _tabModel = tabModel; | 26 _tabModel = tabModel; |
| 27 _tabModelObservers = tabModelObservers; | 27 _tabModelObservers = tabModelObservers; |
| 28 } | 28 } |
| 29 return self; | 29 return self; |
| 30 } | 30 } |
| 31 | 31 |
| 32 #pragma mark WebStateListObserving | 32 #pragma mark WebStateListObserving |
| 33 | 33 |
| 34 - (void)webStateList:(WebStateList*)webStateList | 34 - (void)webStateList:(WebStateList*)webStateList |
| 35 didInsertWebState:(web::WebState*)webState | 35 didInsertWebState:(web::WebState*)webState |
| 36 atIndex:(int)index { | 36 atIndex:(int)atIndex { |
| 37 DCHECK_GE(index, 0); | 37 DCHECK_GE(atIndex, 0); |
| 38 [_tabModelObservers tabModel:_tabModel | 38 [_tabModelObservers tabModel:_tabModel |
| 39 didInsertTab:LegacyTabHelper::GetTabForWebState(webState) | 39 didInsertTab:LegacyTabHelper::GetTabForWebState(webState) |
| 40 atIndex:static_cast<NSUInteger>(index) | 40 atIndex:static_cast<NSUInteger>(atIndex) |
| 41 inForeground:NO]; | 41 inForeground:NO]; |
| 42 [_tabModelObservers tabModelDidChangeTabCount:_tabModel]; | 42 [_tabModelObservers tabModelDidChangeTabCount:_tabModel]; |
| 43 } | 43 } |
| 44 | 44 |
| 45 - (void)webStateList:(WebStateList*)webStateList | 45 - (void)webStateList:(WebStateList*)webStateList |
| 46 didMoveWebState:(web::WebState*)webState | 46 didMoveWebState:(web::WebState*)webState |
| 47 fromIndex:(int)fromIndex | 47 fromIndex:(int)fromIndex |
| 48 toIndex:(int)toIndex { | 48 toIndex:(int)toIndex { |
| 49 DCHECK_GE(fromIndex, 0); | 49 DCHECK_GE(fromIndex, 0); |
| 50 DCHECK_GE(toIndex, 0); | 50 DCHECK_GE(toIndex, 0); |
| 51 [_tabModelObservers tabModel:_tabModel | 51 [_tabModelObservers tabModel:_tabModel |
| 52 didMoveTab:LegacyTabHelper::GetTabForWebState(webState) | 52 didMoveTab:LegacyTabHelper::GetTabForWebState(webState) |
| 53 fromIndex:static_cast<NSUInteger>(fromIndex) | 53 fromIndex:static_cast<NSUInteger>(fromIndex) |
| 54 toIndex:static_cast<NSUInteger>(toIndex)]; | 54 toIndex:static_cast<NSUInteger>(toIndex)]; |
| 55 } | 55 } |
| 56 | 56 |
| 57 - (void)webStateList:(WebStateList*)webStateList | 57 - (void)webStateList:(WebStateList*)webStateList |
| 58 didReplaceWebState:(web::WebState*)oldWebState | 58 didReplaceWebState:(web::WebState*)oldWebState |
| 59 withWebState:(web::WebState*)newWebState | 59 withWebState:(web::WebState*)newWebState |
| 60 atIndex:(int)index { | 60 atIndex:(int)atIndex { |
| 61 DCHECK_GE(index, 0); | 61 DCHECK_GE(atIndex, 0); |
| 62 [_tabModelObservers tabModel:_tabModel | 62 [_tabModelObservers tabModel:_tabModel |
| 63 didReplaceTab:LegacyTabHelper::GetTabForWebState(oldWebState) | 63 didReplaceTab:LegacyTabHelper::GetTabForWebState(oldWebState) |
| 64 withTab:LegacyTabHelper::GetTabForWebState(newWebState) | 64 withTab:LegacyTabHelper::GetTabForWebState(newWebState) |
| 65 atIndex:static_cast<NSUInteger>(index)]; | 65 atIndex:static_cast<NSUInteger>(atIndex)]; |
| 66 } | 66 } |
| 67 | 67 |
| 68 - (void)webStateList:(WebStateList*)webStateList | 68 - (void)webStateList:(WebStateList*)webStateList |
| 69 didDetachWebState:(web::WebState*)webState | 69 didDetachWebState:(web::WebState*)webState |
| 70 atIndex:(int)index { | 70 atIndex:(int)atIndex { |
| 71 DCHECK_GE(index, 0); | 71 DCHECK_GE(atIndex, 0); |
| 72 [_tabModelObservers tabModel:_tabModel | 72 [_tabModelObservers tabModel:_tabModel |
| 73 didRemoveTab:LegacyTabHelper::GetTabForWebState(webState) | 73 didRemoveTab:LegacyTabHelper::GetTabForWebState(webState) |
| 74 atIndex:static_cast<NSUInteger>(index)]; | 74 atIndex:static_cast<NSUInteger>(atIndex)]; |
| 75 [_tabModelObservers tabModelDidChangeTabCount:_tabModel]; | 75 [_tabModelObservers tabModelDidChangeTabCount:_tabModel]; |
| 76 } | 76 } |
| 77 | 77 |
| 78 - (void)webStateList:(WebStateList*)webStateList | 78 - (void)webStateList:(WebStateList*)webStateList |
| 79 didChangeActiveWebState:(web::WebState*)newWebState | 79 didChangeActiveWebState:(web::WebState*)newWebState |
| 80 oldWebState:(web::WebState*)oldWebState | 80 oldWebState:(web::WebState*)oldWebState |
| 81 atIndex:(int)atIndex | 81 atIndex:(int)atIndex |
| 82 userAction:(BOOL)userAction { | 82 userAction:(BOOL)userAction { |
| 83 if (!newWebState) | 83 if (!newWebState) |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 // If there is no new active WebState, then it means that the atIndex will be | 86 // If there is no new active WebState, then it means that the atIndex will be |
| 87 // set to WebStateList::kInvalidIndex, so only check for a positive index if | 87 // set to WebStateList::kInvalidIndex, so only check for a positive index if |
| 88 // there is a new WebState. | 88 // there is a new WebState. |
| 89 DCHECK_GE(atIndex, 0); | 89 DCHECK_GE(atIndex, 0); |
| 90 | 90 |
| 91 Tab* oldTab = | 91 Tab* oldTab = |
| 92 oldWebState ? LegacyTabHelper::GetTabForWebState(oldWebState) : nil; | 92 oldWebState ? LegacyTabHelper::GetTabForWebState(oldWebState) : nil; |
| 93 [_tabModelObservers tabModel:_tabModel | 93 [_tabModelObservers tabModel:_tabModel |
| 94 didChangeActiveTab:LegacyTabHelper::GetTabForWebState(newWebState) | 94 didChangeActiveTab:LegacyTabHelper::GetTabForWebState(newWebState) |
| 95 previousTab:oldTab | 95 previousTab:oldTab |
| 96 atIndex:static_cast<NSUInteger>(atIndex)]; | 96 atIndex:static_cast<NSUInteger>(atIndex)]; |
| 97 } | 97 } |
| 98 | 98 |
| 99 @end | 99 @end |
| OLD | NEW |