Commit ef9a6dff authored by Nazerke's avatar Nazerke Committed by Commit Bot

[ios] Show the active webstate.

This CL updates the switch to the active webstate according to the
tapped tab in the TabStrip.
This CL doesn't update the tabstrip UI, i.e doesn't highlight the
selected tab.

Bug: 1128249
Change-Id: I89041c22d27df2d171821c6d5fc7342c99ab06db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2550711Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Nazerke Kalidolda <nazerke@google.com>
Cr-Commit-Position: refs/heads/master@{#830132}
parent 43f5c398
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
// Tells the receiver to insert a new item in the tabstrip. // Tells the receiver to insert a new item in the tabstrip.
- (void)addNewItem; - (void)addNewItem;
// Tells the receiver to show to the selected tab.
- (void)selectTab:(int)index;
@end @end
#endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_STRIP_TAB_STRIP_CONSUMER_DELEGATE_H_ #endif // IOS_CHROME_BROWSER_UI_TAB_SWITCHER_TAB_STRIP_TAB_STRIP_CONSUMER_DELEGATE_H_
...@@ -197,6 +197,13 @@ web::WebState* GetWebStateWithId(WebStateList* web_state_list, ...@@ -197,6 +197,13 @@ web::WebState* GetWebStateWithId(WebStateList* web_state_list,
WebStateOpener()); WebStateOpener());
} }
- (void)selectTab:(int)index {
if (!self.webStateList)
return;
_webStateList->ActivateWebStateAt(index);
}
#pragma mark - Private #pragma mark - Private
// Calls |-populateItems:selectedItemID:| on the consumer. // Calls |-populateItems:selectedItemID:| on the consumer.
......
...@@ -178,4 +178,12 @@ const CGFloat kNewTabButtonBottomImageInset = -2.0; ...@@ -178,4 +178,12 @@ const CGFloat kNewTabButtonBottomImageInset = -2.0;
[self.delegate addNewItem]; [self.delegate addNewItem];
} }
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView*)collectionView
didSelectItemAtIndexPath:(NSIndexPath*)indexPath {
int index = indexPath.item;
[self.delegate selectTab:index];
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment