Commit c9bcd832 authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

[Offline indicator v2] Fix NullPointerException

NPE was caused by a line in ToolbarManager where
mCanAnimateNativeBrowserControls was used before being set.

The fix is to check if null. Also, it might make sense to update the if
statement where the feature is checked to make sure we return early if
ChromeFeatureList isn't initialized. Otherwise, we end up running
feature specific code if CFL isn't initialized.

Bug: 1062302
Change-Id: Ieac75c96d285f5768321c6d8425fda4511d0fa4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2107701
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751077}
parent 7b7d746e
......@@ -585,14 +585,17 @@ public class ToolbarManager implements ScrimObserver, ToolbarTabController, UrlF
public void onControlsOffsetChanged(int topOffset, int topControlsMinHeightOffset,
int bottomOffset, int bottomControlsMinHeightOffset, boolean needsAnimate) {
// For now, this is only useful for the offline indicator v2 feature.
if (ChromeFeatureList.isInitialized()
&& !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) {
if (!ChromeFeatureList.isInitialized()
|| !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) {
return;
}
// If the browser controls can't be animated, we shouldn't listen for the offset
// changes.
if (!mCanAnimateNativeBrowserControls.get()) return;
if (mCanAnimateNativeBrowserControls == null
|| !mCanAnimateNativeBrowserControls.get()) {
return;
}
// Controls need to be offset to match the composited layer, which is
// anchored at the bottom of the controls container.
......@@ -603,15 +606,18 @@ public class ToolbarManager implements ScrimObserver, ToolbarTabController, UrlF
public void onTopControlsHeightChanged(
int topControlsHeight, int topControlsMinHeight) {
// For now, this is only useful for the offline indicator v2 feature.
if (ChromeFeatureList.isInitialized()
&& !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) {
if (!ChromeFeatureList.isInitialized()
|| !ChromeFeatureList.isEnabled(ChromeFeatureList.OFFLINE_INDICATOR_V2)) {
return;
}
// If the browser controls can be animated, we shouldn't set the extra offset here.
// Instead, that should happen when the animation starts (i.e. we get new offsets)
// to prevent the Android view from jumping before the animation starts.
if (mCanAnimateNativeBrowserControls.get()) return;
if (mCanAnimateNativeBrowserControls == null
|| mCanAnimateNativeBrowserControls.get()) {
return;
}
// Controls need to be offset to match the composited layer, which is
// anchored at the bottom of the controls container.
......
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