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

Side by Side 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: move to button Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.tab; 5 package org.chromium.chrome.browser.tab;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.Application; 9 import android.app.Application;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 import org.chromium.chrome.browser.tab.TabUma.TabCreationState; 80 import org.chromium.chrome.browser.tab.TabUma.TabCreationState;
81 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; 81 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
82 import org.chromium.chrome.browser.tabmodel.TabModel; 82 import org.chromium.chrome.browser.tabmodel.TabModel;
83 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; 83 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
84 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; 84 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
85 import org.chromium.chrome.browser.tabmodel.TabModelImpl; 85 import org.chromium.chrome.browser.tabmodel.TabModelImpl;
86 import org.chromium.chrome.browser.tabmodel.TabModelSelector; 86 import org.chromium.chrome.browser.tabmodel.TabModelSelector;
87 import org.chromium.chrome.browser.tabmodel.TabReparentingParams; 87 import org.chromium.chrome.browser.tabmodel.TabReparentingParams;
88 import org.chromium.chrome.browser.util.ColorUtils; 88 import org.chromium.chrome.browser.util.ColorUtils;
89 import org.chromium.chrome.browser.util.FeatureUtilities; 89 import org.chromium.chrome.browser.util.FeatureUtilities;
90 import org.chromium.chrome.browser.widget.textbubble.TextBubble;
90 import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble; 91 import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble;
91 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; 92 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
92 import org.chromium.components.feature_engagement_tracker.EventConstants; 93 import org.chromium.components.feature_engagement_tracker.EventConstants;
93 import org.chromium.components.feature_engagement_tracker.FeatureConstants; 94 import org.chromium.components.feature_engagement_tracker.FeatureConstants;
94 import org.chromium.components.feature_engagement_tracker.FeatureEngagementTrack er; 95 import org.chromium.components.feature_engagement_tracker.FeatureEngagementTrack er;
95 import org.chromium.components.navigation_interception.InterceptNavigationDelega te; 96 import org.chromium.components.navigation_interception.InterceptNavigationDelega te;
96 import org.chromium.components.security_state.ConnectionSecurityLevel; 97 import org.chromium.components.security_state.ConnectionSecurityLevel;
97 import org.chromium.components.sync.SyncConstants; 98 import org.chromium.components.sync.SyncConstants;
98 import org.chromium.content.browser.ContentView; 99 import org.chromium.content.browser.ContentView;
99 import org.chromium.content.browser.ContentViewCore; 100 import org.chromium.content.browser.ContentViewCore;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 * widely used the data saver feature is for a particular user at a time (i. e. not since the 376 * widely used the data saver feature is for a particular user at a time (i. e. not since the
376 * user started using Chrome). 377 * user started using Chrome).
377 */ 378 */
378 private long mDataSavedOnStartPageLoad; 379 private long mDataSavedOnStartPageLoad;
379 380
380 private final int mDefaultThemeColor; 381 private final int mDefaultThemeColor;
381 private int mThemeColor; 382 private int mThemeColor;
382 383
383 private ChromeDownloadDelegate mDownloadDelegate; 384 private ChromeDownloadDelegate mDownloadDelegate;
384 385
386 /**
387 * The Text bubble used to display In Product help widget for download featu re on videos.
388 */
389 private TextBubble mDownloadIPHBubble;
390
385 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */ 391 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */
386 private boolean mIsAllowedToReturnToExternalApp; 392 private boolean mIsAllowedToReturnToExternalApp;
387 393
388 private GestureStateListener createGestureStateListener() { 394 private GestureStateListener createGestureStateListener() {
389 return new GestureStateListener() { 395 return new GestureStateListener() {
390 @Override 396 @Override
391 public void onFlingStartGesture(int scrollOffsetY, int scrollExtentY ) { 397 public void onFlingStartGesture(int scrollOffsetY, int scrollExtentY ) {
392 onScrollingStateChanged(); 398 onScrollingStateChanged();
393 } 399 }
394 400
(...skipping 1454 matching lines...) Expand 10 before | Expand all | Expand 10 after
1849 public void destroy() { 1855 public void destroy() {
1850 mIsInitialized = false; 1856 mIsInitialized = false;
1851 // Update the title before destroying the tab. http://b/5783092 1857 // Update the title before destroying the tab. http://b/5783092
1852 updateTitle(); 1858 updateTitle();
1853 1859
1854 if (mTabUma != null) mTabUma.onDestroy(); 1860 if (mTabUma != null) mTabUma.onDestroy();
1855 1861
1856 for (TabObserver observer : mObservers) observer.onDestroyed(this); 1862 for (TabObserver observer : mObservers) observer.onDestroyed(this);
1857 mObservers.clear(); 1863 mObservers.clear();
1858 1864
1865 hideMediaDownloadInProductHelp();
1866
1859 NativePage currentNativePage = mNativePage; 1867 NativePage currentNativePage = mNativePage;
1860 mNativePage = null; 1868 mNativePage = null;
1861 destroyNativePageInternal(currentNativePage); 1869 destroyNativePageInternal(currentNativePage);
1862 destroyContentViewCore(true); 1870 destroyContentViewCore(true);
1863 1871
1864 // Destroys the native tab after destroying the ContentView but before d estroying the 1872 // Destroys the native tab after destroying the ContentView but before d estroying the
1865 // InfoBarContainer. The native tab should be destroyed before the infob ar container as 1873 // InfoBarContainer. The native tab should be destroyed before the infob ar container as
1866 // destroying the native tab cleanups up any remaining infobars. The inf obar container 1874 // destroying the native tab cleanups up any remaining infobars. The inf obar container
1867 // expects all infobars to be cleaned up before its own destruction. 1875 // expects all infobars to be cleaned up before its own destruction.
1868 assert mNativeTabAndroid != 0; 1876 assert mNativeTabAndroid != 0;
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
3097 3105
3098 /** 3106 /**
3099 * Configures web preferences for viewing downloaded media. 3107 * Configures web preferences for viewing downloaded media.
3100 * @param enabled Whether embedded media experience should be enabled. 3108 * @param enabled Whether embedded media experience should be enabled.
3101 */ 3109 */
3102 public void enableEmbeddedMediaExperience(boolean enabled) { 3110 public void enableEmbeddedMediaExperience(boolean enabled) {
3103 if (mNativeTabAndroid == 0) return; 3111 if (mNativeTabAndroid == 0) return;
3104 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled); 3112 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled);
3105 } 3113 }
3106 3114
3115 @CalledByNative
3116 private void showMediaDownloadInProductHelp(int x, int y, int width, int hei ght) {
3117 // If we are not currently showing the widget, ask the tracker if we can show it.
3118 if (mDownloadIPHBubble == null) {
3119 FeatureEngagementTracker tracker =
3120 FeatureEngagementTrackerFactory.getFeatureEngagementTrackerF orProfile(
3121 getProfile());
3122 tracker.notifyEvent(EventConstants.MEDIA_DOWNLOAD_BUTTON_DISPLAYED);
3123 if (tracker.shouldTriggerHelpUI(FeatureConstants.MEDIA_DOWNLOAD_FEAT URE)) {
3124 mDownloadIPHBubble = new TextBubble(getApplicationContext(),
3125 mContentViewCore.getContainerView(), R.string.iph_media_ download_text,
3126 R.string.iph_media_download_accessibility_text);
3127 mDownloadIPHBubble.setDismissOnTouchInteraction(true);
3128 mDownloadIPHBubble.addOnDismissListener(new OnDismissListener() {
3129 @Override
3130 public void onDismiss() {
3131 hideMediaDownloadInProductHelp();
3132 }
3133 });
3134 mDownloadIPHBubble.show();
3135 } else {
3136 // Inform native that the button was dismissed to notify the ren derer that the
3137 // request was rejected.
3138 nativeDownloadMediaInProductHelpDismissed(mNativeTabAndroid);
3139 return;
3140 }
3141 }
3142
3143 Rect rect = new Rect(x, y, x + width, y + height);
3144 mDownloadIPHBubble.setAnchorRect(rect);
David Trainor- moved to gerrit 2017/07/11 16:34:42 Does it make sense to do this before the show() ca
Khushal 2017/07/11 20:34:36 Done.
3145 }
3146
3147 @CalledByNative
3148 private void hideMediaDownloadInProductHelp() {
3149 if (mDownloadIPHBubble == null) return;
3150
3151 mDownloadIPHBubble.dismiss();
3152 mDownloadIPHBubble = null;
3153 FeatureEngagementTracker tracker =
3154 FeatureEngagementTrackerFactory.getFeatureEngagementTrackerForPr ofile(getProfile());
3155 tracker.dismissed(FeatureConstants.MEDIA_DOWNLOAD_FEATURE);
3156 nativeDownloadMediaInProductHelpDismissed(mNativeTabAndroid);
3157 }
3158
3107 private native void nativeInit(); 3159 private native void nativeInit();
3108 private native void nativeDestroy(long nativeTabAndroid); 3160 private native void nativeDestroy(long nativeTabAndroid);
3109 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, 3161 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito,
3110 boolean isBackgroundTab, WebContents webContents, 3162 boolean isBackgroundTab, WebContents webContents,
3111 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); 3163 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator);
3112 private native void nativeUpdateDelegates(long nativeTabAndroid, 3164 private native void nativeUpdateDelegates(long nativeTabAndroid,
3113 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); 3165 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator);
3114 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); 3166 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative);
3115 private native void nativeOnPhysicalBackingSizeChanged( 3167 private native void nativeOnPhysicalBackingSizeChanged(
3116 long nativeTabAndroid, WebContents webContents, int width, int heigh t); 3168 long nativeTabAndroid, WebContents webContents, int width, int heigh t);
(...skipping 12 matching lines...) Expand all
3129 private native void nativeLoadOriginalImage(long nativeTabAndroid); 3181 private native void nativeLoadOriginalImage(long nativeTabAndroid);
3130 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); 3182 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable);
3131 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, 3183 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id,
3132 InterceptNavigationDelegate delegate); 3184 InterceptNavigationDelegate delegate);
3133 private native void nativeAttachToTabContentManager(long nativeTabAndroid, 3185 private native void nativeAttachToTabContentManager(long nativeTabAndroid,
3134 TabContentManager tabContentManager); 3186 TabContentManager tabContentManager);
3135 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); 3187 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url);
3136 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope); 3188 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope);
3137 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled); 3189 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled);
3138 private native void nativeAttachDetachedTab(long nativeTabAndroid); 3190 private native void nativeAttachDetachedTab(long nativeTabAndroid);
3191 private native void nativeDownloadMediaInProductHelpDismissed(long nativeTab Android);
3139 } 3192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698