Commit 37f47c07 authored by Justin Cohen's avatar Justin Cohen Committed by Commit Bot

[ios] Check for non nil webState, not tab, for NewTabPageTabHelper.

Bug: 934294
Change-Id: I34eac982df5e4ce23a7e748debe9b118cd88afb4
Reviewed-on: https://chromium-review.googlesource.com/c/1481491
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Auto-Submit: Justin Cohen <justincohen@chromium.org>
Reviewed-by: default avatarKurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634365}
parent 85bb3ca8
...@@ -2813,7 +2813,7 @@ NSString* const kBrowserViewControllerSnackbarCategory = ...@@ -2813,7 +2813,7 @@ NSString* const kBrowserViewControllerSnackbarCategory =
- (id)nativeControllerForTab:(Tab*)tab { - (id)nativeControllerForTab:(Tab*)tab {
id nativeController = tab.webController.nativeController; id nativeController = tab.webController.nativeController;
if (tab) { if (tab.webState) {
NewTabPageTabHelper* NTPHelper = NewTabPageTabHelper* NTPHelper =
NewTabPageTabHelper::FromWebState(tab.webState); NewTabPageTabHelper::FromWebState(tab.webState);
if (NTPHelper && NTPHelper->IsActive()) if (NTPHelper && NTPHelper->IsActive())
......
...@@ -504,7 +504,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -504,7 +504,6 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
- (void)handleiPhoneTabSwipe:(SideSwipeGestureRecognizer*)gesture { - (void)handleiPhoneTabSwipe:(SideSwipeGestureRecognizer*)gesture {
if (gesture.state == UIGestureRecognizerStateBegan) { if (gesture.state == UIGestureRecognizerStateBegan) {
Tab* currentTab = [model_ currentTab]; Tab* currentTab = [model_ currentTab];
DCHECK(currentTab.webState);
inSwipe_ = YES; inSwipe_ = YES;
...@@ -513,10 +512,13 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -513,10 +512,13 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
// Add horizontal stack view controller. // Add horizontal stack view controller.
// TODO(crbug.com/904992): Do not use SnapshotGeneratorDelegate from // TODO(crbug.com/904992): Do not use SnapshotGeneratorDelegate from
// SideSwipeController. // SideSwipeController.
CGFloat headerHeight = CGFloat headerHeight = 0;
[self.snapshotDelegate snapshotGenerator:nil if (currentTab.webState) {
snapshotEdgeInsetsForWebState:currentTab.webState] headerHeight =
.top; [self.snapshotDelegate snapshotGenerator:nil
snapshotEdgeInsetsForWebState:currentTab.webState]
.top;
}
if (tabSideSwipeView_) { if (tabSideSwipeView_) {
[tabSideSwipeView_ setFrame:frame]; [tabSideSwipeView_ setFrame:frame];
...@@ -537,8 +539,10 @@ const NSUInteger kIpadGreySwipeTabCount = 8; ...@@ -537,8 +539,10 @@ const NSUInteger kIpadGreySwipeTabCount = 8;
} }
// Ensure that there's an up-to-date snapshot of the current tab. // Ensure that there's an up-to-date snapshot of the current tab.
SnapshotTabHelper::FromWebState(currentTab.webState) if (currentTab.webState) {
->UpdateSnapshotWithCallback(nil); SnapshotTabHelper::FromWebState(currentTab.webState)
->UpdateSnapshotWithCallback(nil);
}
// Layout tabs with new snapshots in the current orientation. // Layout tabs with new snapshots in the current orientation.
[tabSideSwipeView_ updateViewsForDirection:gesture.direction]; [tabSideSwipeView_ updateViewsForDirection:gesture.direction];
......
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