Commit ac0ae92c authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Android: Fix VR crash

TabRedirectHandler can be null when swapped out for VR mode change,
for which it should not be put into UserDataHost when restored.
This CL adds the missing null check to prevent crash upon exiting
VR mode.

Bug: 882977
Change-Id: I67f740eceffb2ad2acde12501d142583a10d052b
Reviewed-on: https://chromium-review.googlesource.com/1220407Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590493}
parent 60b1ce94
...@@ -89,10 +89,10 @@ public class TabRedirectHandler extends EmptyTabObserver implements UserData { ...@@ -89,10 +89,10 @@ public class TabRedirectHandler extends EmptyTabObserver implements UserData {
* Replace {@link TabRedirectHandler} instance for the Tab with the new one. * Replace {@link TabRedirectHandler} instance for the Tab with the new one.
* @return Old {@link TabRedirectHandler} associated with the Tab. Could be {@code null}. * @return Old {@link TabRedirectHandler} associated with the Tab. Could be {@code null}.
*/ */
public static TabRedirectHandler swapFor(Tab tab, TabRedirectHandler newHandler) { public static TabRedirectHandler swapFor(Tab tab, @Nullable TabRedirectHandler newHandler) {
UserDataHost host = tab.getUserDataHost(); UserDataHost host = tab.getUserDataHost();
TabRedirectHandler oldHandler = host.getUserData(TabRedirectHandler.class); TabRedirectHandler oldHandler = host.getUserData(TabRedirectHandler.class);
host.setUserData(TabRedirectHandler.class, newHandler); if (newHandler != null) host.setUserData(TabRedirectHandler.class, newHandler);
return oldHandler; return oldHandler;
} }
......
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