Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java

Issue 2943983003: chrome/blink: Add functionality for in-product help for media elements. (Closed)
Patch Set: .. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
index db37a2458447a85cd5515e49f899c2d1437244db..1c3630b1bea5d5576514e0f9622d6a97f9829f2e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/Tab.java
@@ -86,6 +86,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.tabmodel.TabReparentingParams;
import org.chromium.chrome.browser.util.ColorUtils;
import org.chromium.chrome.browser.util.FeatureUtilities;
+import org.chromium.chrome.browser.widget.textbubble.TextBubble;
import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble;
import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
import org.chromium.components.feature_engagement.EventConstants;
@@ -389,6 +390,11 @@ public class Tab
private ChromeDownloadDelegate mDownloadDelegate;
+ /**
+ * The Text bubble used to display In Product help widget for download feature on videos.
+ */
+ private TextBubble mDownloadIPHBubble;
+
/** Whether or not the tab closing the tab can send the user back to the app that opened it. */
private boolean mIsAllowedToReturnToExternalApp;
@@ -1870,6 +1876,8 @@ public class Tab
for (TabObserver observer : mObservers) observer.onDestroyed(this);
mObservers.clear();
+ hideMediaDownloadInProductHelp();
+
NativePage currentNativePage = mNativePage;
mNativePage = null;
destroyNativePageInternal(currentNativePage);
@@ -3121,6 +3129,47 @@ public class Tab
nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled);
}
+ @CalledByNative
+ private void showMediaDownloadInProductHelp(int x, int y, int width, int height) {
+ // If we are not currently showing the widget, ask the tracker if we can show it.
+ if (mDownloadIPHBubble == null) {
+ Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile());
+ tracker.notifyEvent(EventConstants.MEDIA_DOWNLOAD_BUTTON_DISPLAYED);
+ if (!tracker.shouldTriggerHelpUI(FeatureConstants.MEDIA_DOWNLOAD_FEATURE)) {
+ // Inform native that the button was dismissed to notify the renderer that the
+ // request was rejected.
+ nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid);
+ return;
+ }
+
+ mDownloadIPHBubble = new TextBubble(getApplicationContext(),
+ mContentViewCore.getContainerView(), R.string.iph_media_download_text,
+ R.string.iph_media_download_accessibility_text);
+ mDownloadIPHBubble.setDismissOnTouchInteraction(true);
+ mDownloadIPHBubble.addOnDismissListener(new OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ hideMediaDownloadInProductHelp();
+ }
+ });
+ }
+
+ Rect rect = new Rect(x, y, x + width, y + height);
+ mDownloadIPHBubble.setAnchorRect(rect);
+ mDownloadIPHBubble.show();
+ }
+
+ @CalledByNative
+ private void hideMediaDownloadInProductHelp() {
+ if (mDownloadIPHBubble == null) return;
+
+ mDownloadIPHBubble.dismiss();
+ mDownloadIPHBubble = null;
+ Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile());
+ tracker.dismissed(FeatureConstants.MEDIA_DOWNLOAD_FEATURE);
+ nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid);
+ }
+
private native void nativeInit();
private native void nativeDestroy(long nativeTabAndroid);
private native void nativeInitWebContents(long nativeTabAndroid, boolean incognito,
@@ -3155,4 +3204,5 @@ public class Tab
private native void nativeSetWebappManifestScope(long nativeTabAndroid, String scope);
private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroid, boolean enabled);
private native void nativeAttachDetachedTab(long nativeTabAndroid);
+ private native void nativeMediaDownloadInProductHelpDismissed(long nativeTabAndroid);
}
« no previous file with comments | « no previous file | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698