Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java |
| index 236c9c93d87c9edf251beec7f9fdfcc02a108f81..c423c59662da650b9e818fc22fbb49b6c8a6e82e 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/infobar/InfoBarContainer.java |
| @@ -5,6 +5,7 @@ |
| package org.chromium.chrome.browser.infobar; |
| import android.content.Context; |
| +import android.support.annotation.StringRes; |
| import android.view.Gravity; |
| import android.view.View; |
| import android.view.ViewGroup; |
| @@ -15,9 +16,14 @@ import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.chrome.R; |
| import org.chromium.chrome.browser.banners.SwipableOverlayView; |
| +import org.chromium.chrome.browser.feature_engagement_tracker.FeatureEngagementTrackerFactory; |
| +import org.chromium.chrome.browser.profiles.Profile; |
| import org.chromium.chrome.browser.tab.EmptyTabObserver; |
| import org.chromium.chrome.browser.tab.Tab; |
| import org.chromium.chrome.browser.tab.TabObserver; |
| +import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble; |
| +import org.chromium.components.feature_engagement_tracker.FeatureConstants; |
| +import org.chromium.components.feature_engagement_tracker.FeatureEngagementTracker; |
| import org.chromium.content.browser.ContentViewCore; |
| import org.chromium.content_public.browser.WebContents; |
| import org.chromium.ui.UiUtils; |
| @@ -257,6 +263,8 @@ public class InfoBarContainer extends SwipableOverlayView { |
| infoBar.createView(); |
| mLayout.addInfoBar(infoBar); |
| + |
| + showFeatureEngagementForInfoBar(infoBar); |
|
David Trainor- moved to gerrit
2017/04/12 08:41:20
Hmm this doesn't mean the infobar is showing. Wou
gone
2017/04/12 17:12:44
Maybe see when InfoBarAnimationListener fires?
|
| } |
| /** |
| @@ -289,6 +297,36 @@ public class InfoBarContainer extends SwipableOverlayView { |
| mLayout.removeInfoBar(infoBar); |
| } |
| + private void showFeatureEngagementForInfoBar(InfoBar infoBar) { |
| + String feature = null; |
| + @StringRes |
| + int text = 0; |
| + switch (infoBar.getInfoBarIdentifier()) { |
| + case InfoBarIdentifier.DATA_REDUCTION_PROXY_PREVIEW_INFOBAR_DELEGATE: |
| + feature = FeatureConstants.DATA_SAVER_PREVIEW; |
| + text = R.string.iph_data_saver_preview_text; |
| + break; |
| + } |
| + |
| + if (feature == null) return; |
| + |
| + Profile profile = Profile.getLastUsedProfile(); |
| + final FeatureEngagementTracker tracker = |
| + FeatureEngagementTrackerFactory.getFeatureEngagementTrackerForProfile(profile); |
| + if (!tracker.shouldTriggerHelpUI(feature)) return; |
| + |
| + ViewAnchoredTextBubble bubble = |
| + new ViewAnchoredTextBubble(getContext(), infoBar.getView(), text); |
| + bubble.setDismissOnTouchInteraction(true); |
| + bubble.setOnDismissListener(new OnDismissListener() { |
| + @Override |
| + public void onDismiss() { |
| + tracker.dismissed(); |
| + } |
| + }); |
| + bubble.show(); |
| + } |
| + |
| /** |
| * @return True when this container has been emptied and its native counterpart has been |
| * destroyed. |