Commit d910f829 authored by Alice Wang's avatar Alice Wang Committed by Commit Bot

[Android][WebSignin] Fix crash when bottomSheetController is null

This CL dismisses the account picker bottom sheet when the bottom
sheet controller is null.

Bug: 1136799
Change-Id: I9814c10f6becb07c3e95ab93f0d81b69af936853
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2463307
Commit-Queue: Alice Wang <aliceywang@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815676}
parent 1530b442
...@@ -28,6 +28,7 @@ import org.chromium.chrome.browser.signin.account_picker.AccountPickerDelegate; ...@@ -28,6 +28,7 @@ import org.chromium.chrome.browser.signin.account_picker.AccountPickerDelegate;
import org.chromium.chrome.browser.sync.settings.AccountManagementFragment; import org.chromium.chrome.browser.sync.settings.AccountManagementFragment;
import org.chromium.chrome.browser.tabmodel.TabCreator; import org.chromium.chrome.browser.tabmodel.TabCreator;
import org.chromium.chrome.browser.tabmodel.TabModel; import org.chromium.chrome.browser.tabmodel.TabModel;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
import org.chromium.components.browser_ui.bottomsheet.BottomSheetControllerProvider; import org.chromium.components.browser_ui.bottomsheet.BottomSheetControllerProvider;
import org.chromium.components.browser_ui.settings.ManagedPreferencesUtils; import org.chromium.components.browser_ui.settings.ManagedPreferencesUtils;
import org.chromium.components.signin.AccountManagerFacadeProvider; import org.chromium.components.signin.AccountManagerFacadeProvider;
...@@ -97,8 +98,16 @@ public class SigninUtils { ...@@ -97,8 +98,16 @@ public class SigninUtils {
AccountConsistencyPromoAction.SUPPRESSED_NO_ACCOUNTS); AccountConsistencyPromoAction.SUPPRESSED_NO_ACCOUNTS);
return; return;
} }
ChromeActivity activity = (ChromeActivity) windowAndroid.getActivity().get(); BottomSheetController bottomSheetController =
BottomSheetControllerProvider.from(windowAndroid);
if (bottomSheetController == null) {
// The bottomSheetController can be null when google.com is just opened inside a
// bottom sheet for example. In this case, it's better to disable the account picker
// bottom sheet.
return;
}
ChromeActivity activity = (ChromeActivity) windowAndroid.getActivity().get();
// To close the current regular tab after the user clicks on "Continue" in the incognito // To close the current regular tab after the user clicks on "Continue" in the incognito
// interstitial. // interstitial.
TabModel regularTabModel = activity.getTabModelSelector().getModel(/*incognito=*/false); TabModel regularTabModel = activity.getTabModelSelector().getModel(/*incognito=*/false);
...@@ -110,7 +119,7 @@ public class SigninUtils { ...@@ -110,7 +119,7 @@ public class SigninUtils {
HelpAndFeedbackLauncherImpl.getInstance()); HelpAndFeedbackLauncherImpl.getInstance());
AccountPickerBottomSheetCoordinator coordinator = new AccountPickerBottomSheetCoordinator( AccountPickerBottomSheetCoordinator coordinator = new AccountPickerBottomSheetCoordinator(
windowAndroid.getContext().get(), BottomSheetControllerProvider.from(windowAndroid), windowAndroid.getContext().get(), bottomSheetController,
new AccountPickerDelegate(windowAndroid, activity.getActivityTab(), new AccountPickerDelegate(windowAndroid, activity.getActivityTab(),
new WebSigninBridge.Factory(), continueUrl), new WebSigninBridge.Factory(), continueUrl),
incognitoInterstitialDelegate); incognitoInterstitialDelegate);
......
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