Skip to content

Commit

Permalink
Data Saver Details IPH must only be shown for particular activity type.
Browse files Browse the repository at this point in the history
The Data Saver Details in-product help should only ever be displayed in
the case of a ChromeTabbedActivity.

Additionally, not all activities in Chrome has a ToolbarManager.

Since the in-product help code uses the ToolbarManager from the current
activity on a didFinishPageLoad() event, this will lead to an NPE.

This CL ensures that we bail out early if the activity is not of the
correct type.

BUG=772556

Change-Id: I0c7dfe194625fba79ed8eadf7c1f2dd2947abc94
Reviewed-on: https://chromium-review.googlesource.com/706540
Reviewed-by: Tommy Nyquist <nyquist@chromium.org>
Reviewed-by: Ted Choc <tedchoc@chromium.org>
Commit-Queue: Tommy Nyquist <nyquist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#507247}
  • Loading branch information
tommynyquist authored and Commit Bot committed Oct 7, 2017
1 parent 7c6cd60 commit 78bb2a3
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.chromium.chrome.browser.ChromeActionModeCallback;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.ChromeVersionInfo;
import org.chromium.chrome.browser.FrozenNativePage;
import org.chromium.chrome.browser.IntentHandler;
Expand Down Expand Up @@ -1613,6 +1614,8 @@ protected void didFinishPageLoad() {
private void maybeShowDataSaverInProductHelp(final Tracker tracker) {
if (!tracker.shouldTriggerHelpUI(FeatureConstants.DATA_SAVER_DETAIL_FEATURE)) return;

if (!(getActivity() instanceof ChromeTabbedActivity)) return;

ViewAnchoredTextBubble textBubble = new ViewAnchoredTextBubble(getActivity(),
getActivity().getToolbarManager().getMenuButton(),
R.string.iph_data_saver_detail_text,
Expand Down

0 comments on commit 78bb2a3

Please sign in to comment.