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

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: .. 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 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 import org.chromium.chrome.browser.tab.TabUma.TabCreationState; 79 import org.chromium.chrome.browser.tab.TabUma.TabCreationState;
80 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager; 80 import org.chromium.chrome.browser.tabmodel.AsyncTabParamsManager;
81 import org.chromium.chrome.browser.tabmodel.TabModel; 81 import org.chromium.chrome.browser.tabmodel.TabModel;
82 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType; 82 import org.chromium.chrome.browser.tabmodel.TabModel.TabLaunchType;
83 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType; 83 import org.chromium.chrome.browser.tabmodel.TabModel.TabSelectionType;
84 import org.chromium.chrome.browser.tabmodel.TabModelImpl; 84 import org.chromium.chrome.browser.tabmodel.TabModelImpl;
85 import org.chromium.chrome.browser.tabmodel.TabModelSelector; 85 import org.chromium.chrome.browser.tabmodel.TabModelSelector;
86 import org.chromium.chrome.browser.tabmodel.TabReparentingParams; 86 import org.chromium.chrome.browser.tabmodel.TabReparentingParams;
87 import org.chromium.chrome.browser.util.ColorUtils; 87 import org.chromium.chrome.browser.util.ColorUtils;
88 import org.chromium.chrome.browser.util.FeatureUtilities; 88 import org.chromium.chrome.browser.util.FeatureUtilities;
89 import org.chromium.chrome.browser.widget.textbubble.TextBubble;
89 import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble; 90 import org.chromium.chrome.browser.widget.textbubble.ViewAnchoredTextBubble;
90 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils; 91 import org.chromium.components.dom_distiller.core.DomDistillerUrlUtils;
91 import org.chromium.components.feature_engagement.EventConstants; 92 import org.chromium.components.feature_engagement.EventConstants;
92 import org.chromium.components.feature_engagement.FeatureConstants; 93 import org.chromium.components.feature_engagement.FeatureConstants;
93 import org.chromium.components.feature_engagement.Tracker; 94 import org.chromium.components.feature_engagement.Tracker;
94 import org.chromium.components.navigation_interception.InterceptNavigationDelega te; 95 import org.chromium.components.navigation_interception.InterceptNavigationDelega te;
95 import org.chromium.components.security_state.ConnectionSecurityLevel; 96 import org.chromium.components.security_state.ConnectionSecurityLevel;
96 import org.chromium.components.sync.SyncConstants; 97 import org.chromium.components.sync.SyncConstants;
97 import org.chromium.content.browser.ContentView; 98 import org.chromium.content.browser.ContentView;
98 import org.chromium.content.browser.ContentViewCore; 99 import org.chromium.content.browser.ContentViewCore;
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 * widely used the data saver feature is for a particular user at a time (i. e. not since the 375 * widely used the data saver feature is for a particular user at a time (i. e. not since the
375 * user started using Chrome). 376 * user started using Chrome).
376 */ 377 */
377 private long mDataSavedOnStartPageLoad; 378 private long mDataSavedOnStartPageLoad;
378 379
379 private final int mDefaultThemeColor; 380 private final int mDefaultThemeColor;
380 private int mThemeColor; 381 private int mThemeColor;
381 382
382 private ChromeDownloadDelegate mDownloadDelegate; 383 private ChromeDownloadDelegate mDownloadDelegate;
383 384
385 /**
386 * The Text bubble used to display In Product help widget for download featu re on videos.
387 */
388 private TextBubble mDownloadIPHBubble;
389
384 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */ 390 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */
385 private boolean mIsAllowedToReturnToExternalApp; 391 private boolean mIsAllowedToReturnToExternalApp;
386 392
387 private GestureStateListener createGestureStateListener() { 393 private GestureStateListener createGestureStateListener() {
388 return new GestureStateListener() { 394 return new GestureStateListener() {
389 @Override 395 @Override
390 public void onFlingStartGesture(int scrollOffsetY, int scrollExtentY ) { 396 public void onFlingStartGesture(int scrollOffsetY, int scrollExtentY ) {
391 onScrollingStateChanged(); 397 onScrollingStateChanged();
392 } 398 }
393 399
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1846 public void destroy() { 1852 public void destroy() {
1847 mIsInitialized = false; 1853 mIsInitialized = false;
1848 // Update the title before destroying the tab. http://b/5783092 1854 // Update the title before destroying the tab. http://b/5783092
1849 updateTitle(); 1855 updateTitle();
1850 1856
1851 if (mTabUma != null) mTabUma.onDestroy(); 1857 if (mTabUma != null) mTabUma.onDestroy();
1852 1858
1853 for (TabObserver observer : mObservers) observer.onDestroyed(this); 1859 for (TabObserver observer : mObservers) observer.onDestroyed(this);
1854 mObservers.clear(); 1860 mObservers.clear();
1855 1861
1862 hideMediaDownloadInProductHelp();
1863
1856 NativePage currentNativePage = mNativePage; 1864 NativePage currentNativePage = mNativePage;
1857 mNativePage = null; 1865 mNativePage = null;
1858 destroyNativePageInternal(currentNativePage); 1866 destroyNativePageInternal(currentNativePage);
1859 destroyContentViewCore(true); 1867 destroyContentViewCore(true);
1860 1868
1861 // Destroys the native tab after destroying the ContentView but before d estroying the 1869 // Destroys the native tab after destroying the ContentView but before d estroying the
1862 // InfoBarContainer. The native tab should be destroyed before the infob ar container as 1870 // InfoBarContainer. The native tab should be destroyed before the infob ar container as
1863 // destroying the native tab cleanups up any remaining infobars. The inf obar container 1871 // destroying the native tab cleanups up any remaining infobars. The inf obar container
1864 // expects all infobars to be cleaned up before its own destruction. 1872 // expects all infobars to be cleaned up before its own destruction.
1865 assert mNativeTabAndroid != 0; 1873 assert mNativeTabAndroid != 0;
(...skipping 1231 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 Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLas tUsedProfile());
3120 tracker.notifyEvent(EventConstants.MEDIA_DOWNLOAD_BUTTON_DISPLAYED);
3121 if (!tracker.shouldTriggerHelpUI(FeatureConstants.MEDIA_DOWNLOAD_FEA TURE)) {
3122 // Inform native that the button was dismissed to notify the ren derer that the
3123 // request was rejected.
3124 nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid);
3125 return;
3126 }
3127
3128 mDownloadIPHBubble = new TextBubble(getApplicationContext(),
3129 mContentViewCore.getContainerView(), R.string.iph_media_down load_text,
3130 R.string.iph_media_download_accessibility_text);
3131 mDownloadIPHBubble.setDismissOnTouchInteraction(true);
Khushal 2017/08/16 21:02:06 Oh and about the user scrolling/interacting with t
3132 mDownloadIPHBubble.addOnDismissListener(new OnDismissListener() {
3133 @Override
3134 public void onDismiss() {
3135 hideMediaDownloadInProductHelp();
3136 }
3137 });
3138 }
3139
3140 Rect rect = new Rect(x, y, x + width, y + height);
3141 mDownloadIPHBubble.setAnchorRect(rect);
3142 mDownloadIPHBubble.show();
3143 }
3144
3145 @CalledByNative
3146 private void hideMediaDownloadInProductHelp() {
3147 if (mDownloadIPHBubble == null) return;
3148
3149 mDownloadIPHBubble.dismiss();
3150 mDownloadIPHBubble = null;
3151 Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUse dProfile());
3152 tracker.dismissed(FeatureConstants.MEDIA_DOWNLOAD_FEATURE);
3153 nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid);
3154 }
3155
3107 private native void nativeInit(); 3156 private native void nativeInit();
3108 private native void nativeDestroy(long nativeTabAndroid); 3157 private native void nativeDestroy(long nativeTabAndroid);
3109 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, 3158 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito,
3110 boolean isBackgroundTab, WebContents webContents, 3159 boolean isBackgroundTab, WebContents webContents,
3111 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); 3160 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator);
3112 private native void nativeUpdateDelegates(long nativeTabAndroid, 3161 private native void nativeUpdateDelegates(long nativeTabAndroid,
3113 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); 3162 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator);
3114 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); 3163 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative);
3115 private native void nativeOnPhysicalBackingSizeChanged( 3164 private native void nativeOnPhysicalBackingSizeChanged(
3116 long nativeTabAndroid, WebContents webContents, int width, int heigh t); 3165 long nativeTabAndroid, WebContents webContents, int width, int heigh t);
(...skipping 14 matching lines...) Expand all
3131 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); 3180 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable);
3132 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, 3181 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id,
3133 InterceptNavigationDelegate delegate); 3182 InterceptNavigationDelegate delegate);
3134 private native void nativeAttachToTabContentManager(long nativeTabAndroid, 3183 private native void nativeAttachToTabContentManager(long nativeTabAndroid,
3135 TabContentManager tabContentManager); 3184 TabContentManager tabContentManager);
3136 private native void nativeClearThumbnailPlaceholder(long nativeTabAndroid); 3185 private native void nativeClearThumbnailPlaceholder(long nativeTabAndroid);
3137 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); 3186 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url);
3138 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope); 3187 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope);
3139 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled); 3188 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled);
3140 private native void nativeAttachDetachedTab(long nativeTabAndroid); 3189 private native void nativeAttachDetachedTab(long nativeTabAndroid);
3190 private native void nativeMediaDownloadInProductHelpDismissed(long nativeTab Android);
3141 } 3191 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/strings/android_chrome_strings.grd » ('j') | chrome/browser/android/tab_android.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698