OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1850 public void destroy() { | 1856 public void destroy() { |
1851 mIsInitialized = false; | 1857 mIsInitialized = false; |
1852 // Update the title before destroying the tab. http://b/5783092 | 1858 // Update the title before destroying the tab. http://b/5783092 |
1853 updateTitle(); | 1859 updateTitle(); |
1854 | 1860 |
1855 if (mTabUma != null) mTabUma.onDestroy(); | 1861 if (mTabUma != null) mTabUma.onDestroy(); |
1856 | 1862 |
1857 for (TabObserver observer : mObservers) observer.onDestroyed(this); | 1863 for (TabObserver observer : mObservers) observer.onDestroyed(this); |
1858 mObservers.clear(); | 1864 mObservers.clear(); |
1859 | 1865 |
1866 hideMediaDownloadInProductHelp(); | |
1867 | |
1860 NativePage currentNativePage = mNativePage; | 1868 NativePage currentNativePage = mNativePage; |
1861 mNativePage = null; | 1869 mNativePage = null; |
1862 destroyNativePageInternal(currentNativePage); | 1870 destroyNativePageInternal(currentNativePage); |
1863 destroyContentViewCore(true); | 1871 destroyContentViewCore(true); |
1864 | 1872 |
1865 // Destroys the native tab after destroying the ContentView but before d estroying the | 1873 // Destroys the native tab after destroying the ContentView but before d estroying the |
1866 // InfoBarContainer. The native tab should be destroyed before the infob ar container as | 1874 // InfoBarContainer. The native tab should be destroyed before the infob ar container as |
1867 // destroying the native tab cleanups up any remaining infobars. The inf obar container | 1875 // destroying the native tab cleanups up any remaining infobars. The inf obar container |
1868 // expects all infobars to be cleaned up before its own destruction. | 1876 // expects all infobars to be cleaned up before its own destruction. |
1869 assert mNativeTabAndroid != 0; | 1877 assert mNativeTabAndroid != 0; |
(...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3103 | 3111 |
3104 /** | 3112 /** |
3105 * Configures web preferences for viewing downloaded media. | 3113 * Configures web preferences for viewing downloaded media. |
3106 * @param enabled Whether embedded media experience should be enabled. | 3114 * @param enabled Whether embedded media experience should be enabled. |
3107 */ | 3115 */ |
3108 public void enableEmbeddedMediaExperience(boolean enabled) { | 3116 public void enableEmbeddedMediaExperience(boolean enabled) { |
3109 if (mNativeTabAndroid == 0) return; | 3117 if (mNativeTabAndroid == 0) return; |
3110 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled); | 3118 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled); |
3111 } | 3119 } |
3112 | 3120 |
3121 @CalledByNative | |
3122 private void showMediaDownloadInProductHelp(int x, int y, int width, int hei ght) { | |
3123 // If we are not currently showing the widget, ask the tracker if we can show it. | |
3124 if (mDownloadIPHBubble == null) { | |
3125 FeatureEngagementTracker tracker = | |
3126 FeatureEngagementTrackerFactory.getFeatureEngagementTrackerF orProfile( | |
3127 getProfile()); | |
3128 tracker.notifyEvent(EventConstants.MEDIA_DOWNLOAD_BUTTON_DISPLAYED); | |
3129 if (tracker.shouldTriggerHelpUI(FeatureConstants.MEDIA_DOWNLOAD_FEAT URE)) { | |
mlamouri (slow - plz ping)
2017/07/25 17:29:08
Maybe you could do:
```
if (!tracker.shouldTrigger
Khushal
2017/08/03 02:41:21
Done.
| |
3130 mDownloadIPHBubble = new TextBubble(getApplicationContext(), | |
3131 mContentViewCore.getContainerView(), R.string.iph_media_ download_text, | |
3132 R.string.iph_media_download_accessibility_text); | |
3133 mDownloadIPHBubble.setDismissOnTouchInteraction(true); | |
3134 mDownloadIPHBubble.addOnDismissListener(new OnDismissListener() { | |
3135 @Override | |
3136 public void onDismiss() { | |
3137 hideMediaDownloadInProductHelp(); | |
3138 } | |
3139 }); | |
3140 } else { | |
3141 // Inform native that the button was dismissed to notify the ren derer that the | |
3142 // request was rejected. | |
3143 nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid); | |
3144 return; | |
3145 } | |
3146 } | |
3147 | |
3148 Rect rect = new Rect(x, y, x + width, y + height); | |
3149 mDownloadIPHBubble.setAnchorRect(rect); | |
3150 mDownloadIPHBubble.show(); | |
3151 } | |
3152 | |
3153 @CalledByNative | |
3154 private void hideMediaDownloadInProductHelp() { | |
3155 if (mDownloadIPHBubble == null) return; | |
3156 | |
3157 mDownloadIPHBubble.dismiss(); | |
3158 mDownloadIPHBubble = null; | |
3159 FeatureEngagementTracker tracker = | |
3160 FeatureEngagementTrackerFactory.getFeatureEngagementTrackerForPr ofile(getProfile()); | |
3161 tracker.dismissed(FeatureConstants.MEDIA_DOWNLOAD_FEATURE); | |
3162 nativeMediaDownloadInProductHelpDismissed(mNativeTabAndroid); | |
3163 } | |
3164 | |
3113 private native void nativeInit(); | 3165 private native void nativeInit(); |
3114 private native void nativeDestroy(long nativeTabAndroid); | 3166 private native void nativeDestroy(long nativeTabAndroid); |
3115 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, | 3167 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, |
3116 boolean isBackgroundTab, WebContents webContents, | 3168 boolean isBackgroundTab, WebContents webContents, |
3117 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); | 3169 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); |
3118 private native void nativeUpdateDelegates(long nativeTabAndroid, | 3170 private native void nativeUpdateDelegates(long nativeTabAndroid, |
3119 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); | 3171 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); |
3120 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); | 3172 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); |
3121 private native void nativeOnPhysicalBackingSizeChanged( | 3173 private native void nativeOnPhysicalBackingSizeChanged( |
3122 long nativeTabAndroid, WebContents webContents, int width, int heigh t); | 3174 long nativeTabAndroid, WebContents webContents, int width, int heigh t); |
(...skipping 14 matching lines...) Expand all Loading... | |
3137 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); | 3189 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); |
3138 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, | 3190 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, |
3139 InterceptNavigationDelegate delegate); | 3191 InterceptNavigationDelegate delegate); |
3140 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3192 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
3141 TabContentManager tabContentManager); | 3193 TabContentManager tabContentManager); |
3142 private native void nativeClearThumbnailPlaceholder(long nativeTabAndroid); | 3194 private native void nativeClearThumbnailPlaceholder(long nativeTabAndroid); |
3143 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); | 3195 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); |
3144 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope); | 3196 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope); |
3145 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled); | 3197 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled); |
3146 private native void nativeAttachDetachedTab(long nativeTabAndroid); | 3198 private native void nativeAttachDetachedTab(long nativeTabAndroid); |
3199 private native void nativeMediaDownloadInProductHelpDismissed(long nativeTab Android); | |
3147 } | 3200 } |
OLD | NEW |