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

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
« no previous file with comments | « no previous file | chrome/android/java/strings/android_chrome_strings.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 * widely used the data saver feature is for a particular user at a time (i. e. not since the 383 * widely used the data saver feature is for a particular user at a time (i. e. not since the
383 * user started using Chrome). 384 * user started using Chrome).
384 */ 385 */
385 private long mDataSavedOnStartPageLoad; 386 private long mDataSavedOnStartPageLoad;
386 387
387 private final int mDefaultThemeColor; 388 private final int mDefaultThemeColor;
388 private int mThemeColor; 389 private int mThemeColor;
389 390
390 private ChromeDownloadDelegate mDownloadDelegate; 391 private ChromeDownloadDelegate mDownloadDelegate;
391 392
393 /**
394 * The Text bubble used to display In Product help widget for download featu re on videos.
395 */
396 private TextBubble mDownloadIPHBubble;
397
392 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */ 398 /** Whether or not the tab closing the tab can send the user back to the app that opened it. */
393 private boolean mIsAllowedToReturnToExternalApp; 399 private boolean mIsAllowedToReturnToExternalApp;
394 400
395 private GestureStateListener createGestureStateListener() { 401 private GestureStateListener createGestureStateListener() {
396 return new GestureStateListener() { 402 return new GestureStateListener() {
397 @Override 403 @Override
398 public void onFlingStartGesture(int scrollOffsetY, int scrollExtentY ) { 404 public void onFlingStartGesture(int scrollOffsetY, int scrollExtentY ) {
399 onScrollingStateChanged(); 405 onScrollingStateChanged();
400 } 406 }
401 407
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 public void destroy() { 1869 public void destroy() {
1864 mIsInitialized = false; 1870 mIsInitialized = false;
1865 // Update the title before destroying the tab. http://b/5783092 1871 // Update the title before destroying the tab. http://b/5783092
1866 updateTitle(); 1872 updateTitle();
1867 1873
1868 if (mTabUma != null) mTabUma.onDestroy(); 1874 if (mTabUma != null) mTabUma.onDestroy();
1869 1875
1870 for (TabObserver observer : mObservers) observer.onDestroyed(this); 1876 for (TabObserver observer : mObservers) observer.onDestroyed(this);
1871 mObservers.clear(); 1877 mObservers.clear();
1872 1878
1879 hideMediaDownloadInProductHelp();
1880
1873 NativePage currentNativePage = mNativePage; 1881 NativePage currentNativePage = mNativePage;
1874 mNativePage = null; 1882 mNativePage = null;
1875 destroyNativePageInternal(currentNativePage); 1883 destroyNativePageInternal(currentNativePage);
1876 destroyContentViewCore(true); 1884 destroyContentViewCore(true);
1877 1885
1878 // Destroys the native tab after destroying the ContentView but before d estroying the 1886 // Destroys the native tab after destroying the ContentView but before d estroying the
1879 // InfoBarContainer. The native tab should be destroyed before the infob ar container as 1887 // InfoBarContainer. The native tab should be destroyed before the infob ar container as
1880 // destroying the native tab cleanups up any remaining infobars. The inf obar container 1888 // destroying the native tab cleanups up any remaining infobars. The inf obar container
1881 // expects all infobars to be cleaned up before its own destruction. 1889 // expects all infobars to be cleaned up before its own destruction.
1882 assert mNativeTabAndroid != 0; 1890 assert mNativeTabAndroid != 0;
(...skipping 1231 matching lines...) Expand 10 before | Expand all | Expand 10 after
3114 3122
3115 /** 3123 /**
3116 * Configures web preferences for viewing downloaded media. 3124 * Configures web preferences for viewing downloaded media.
3117 * @param enabled Whether embedded media experience should be enabled. 3125 * @param enabled Whether embedded media experience should be enabled.
3118 */ 3126 */
3119 public void enableEmbeddedMediaExperience(boolean enabled) { 3127 public void enableEmbeddedMediaExperience(boolean enabled) {
3120 if (mNativeTabAndroid == 0) return; 3128 if (mNativeTabAndroid == 0) return;
3121 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled); 3129 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled);
3122 } 3130 }
3123 3131
3132 @CalledByNative
3133 private void showMediaDownloadInProductHelp(int x, int y, int width, int hei ght) {
3134 // If we are not currently showing the widget, ask the tracker if we can show it.
3135 if (mDownloadIPHBubble == null) {
3136 Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLas tUsedProfile());
3137 tracker.notifyEvent(EventConstants.MEDIA_DOWNLOAD_BUTTON_DISPLAYED);
3138 if (!tracker.shouldTriggerHelpUI(FeatureConstants.MEDIA_DOWNLOAD_FEA TURE)) {
3139 // Inform native that the button was dismissed to notify the ren derer that the
3140 // request was rejected.
3141 nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid);
3142 return;
3143 }
3144
3145 mDownloadIPHBubble = new TextBubble(getApplicationContext(),
3146 mContentViewCore.getContainerView(), R.string.iph_media_down load_text,
3147 R.string.iph_media_download_accessibility_text);
3148 mDownloadIPHBubble.setDismissOnTouchInteraction(true);
3149 mDownloadIPHBubble.addOnDismissListener(new OnDismissListener() {
3150 @Override
3151 public void onDismiss() {
3152 hideMediaDownloadInProductHelp();
3153 }
3154 });
3155 }
3156
3157 Rect rect = new Rect(x, y, x + width, y + height);
3158 mDownloadIPHBubble.setAnchorRect(rect);
3159 mDownloadIPHBubble.show();
3160 }
3161
3162 @CalledByNative
3163 private void hideMediaDownloadInProductHelp() {
3164 if (mDownloadIPHBubble == null) return;
3165
3166 mDownloadIPHBubble.dismiss();
3167 mDownloadIPHBubble = null;
3168 Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUse dProfile());
3169 tracker.dismissed(FeatureConstants.MEDIA_DOWNLOAD_FEATURE);
3170 nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid);
3171 }
3172
3124 private native void nativeInit(); 3173 private native void nativeInit();
3125 private native void nativeDestroy(long nativeTabAndroid); 3174 private native void nativeDestroy(long nativeTabAndroid);
3126 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, 3175 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito,
3127 boolean isBackgroundTab, WebContents webContents, 3176 boolean isBackgroundTab, WebContents webContents,
3128 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); 3177 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator);
3129 private native void nativeUpdateDelegates(long nativeTabAndroid, 3178 private native void nativeUpdateDelegates(long nativeTabAndroid,
3130 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); 3179 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator);
3131 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); 3180 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative);
3132 private native void nativeOnPhysicalBackingSizeChanged( 3181 private native void nativeOnPhysicalBackingSizeChanged(
3133 long nativeTabAndroid, WebContents webContents, int width, int heigh t); 3182 long nativeTabAndroid, WebContents webContents, int width, int heigh t);
(...skipping 14 matching lines...) Expand all
3148 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); 3197 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable);
3149 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, 3198 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id,
3150 InterceptNavigationDelegate delegate); 3199 InterceptNavigationDelegate delegate);
3151 private native void nativeAttachToTabContentManager(long nativeTabAndroid, 3200 private native void nativeAttachToTabContentManager(long nativeTabAndroid,
3152 TabContentManager tabContentManager); 3201 TabContentManager tabContentManager);
3153 private native void nativeClearThumbnailPlaceholder(long nativeTabAndroid); 3202 private native void nativeClearThumbnailPlaceholder(long nativeTabAndroid);
3154 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); 3203 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url);
3155 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope); 3204 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope);
3156 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled); 3205 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled);
3157 private native void nativeAttachDetachedTab(long nativeTabAndroid); 3206 private native void nativeAttachDetachedTab(long nativeTabAndroid);
3207 private native void nativeMediaDownloadInProductHelpDismissed(long nativeTab Android);
3158 } 3208 }
OLDNEW
« 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