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 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3097 | 3103 |
3098 /** | 3104 /** |
3099 * Configures web preferences for viewing downloaded media. | 3105 * Configures web preferences for viewing downloaded media. |
3100 * @param enabled Whether embedded media experience should be enabled. | 3106 * @param enabled Whether embedded media experience should be enabled. |
3101 */ | 3107 */ |
3102 public void enableEmbeddedMediaExperience(boolean enabled) { | 3108 public void enableEmbeddedMediaExperience(boolean enabled) { |
3103 if (mNativeTabAndroid == 0) return; | 3109 if (mNativeTabAndroid == 0) return; |
3104 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled); | 3110 nativeEnableEmbeddedMediaExperience(mNativeTabAndroid, enabled); |
3105 } | 3111 } |
3106 | 3112 |
3113 @CalledByNative | |
3114 public void showMediaDownloadInProductHelp(int x, int y, int width, int heig ht) { | |
nyquist
2017/06/29 02:10:23
Nit: Could this and the method below be private?
Khushal
2017/07/07 04:18:14
Done.
| |
3115 // If we are not currently showing the widget, ask the tracker if we can show it. | |
3116 if (mDownloadIPHBubble == null) { | |
3117 FeatureEngagementTracker tracker = | |
3118 FeatureEngagementTrackerFactory.getFeatureEngagementTrackerF orProfile( | |
3119 getProfile()); | |
3120 tracker.notifyEvent(EventConstants.MEDIA_DOWNLOAD_BUTTON_DISPLAYED); | |
3121 if (tracker.shouldTriggerHelpUI(FeatureConstants.MEDIA_DOWNLOAD_FEAT URE)) { | |
3122 mDownloadIPHBubble = new TextBubble(getApplicationContext(), | |
3123 mContentViewCore.getContainerView(), R.string.iph_media_ download_text, | |
3124 R.string.iph_media_download_accessibility_text); | |
3125 mDownloadIPHBubble.show(); | |
nyquist
2017/06/29 02:10:23
Optional nit: It's probably just me, but it feels
Khushal
2017/07/07 04:18:14
Done.
| |
3126 mDownloadIPHBubble.setDismissOnTouchInteraction(true); | |
3127 mDownloadIPHBubble.addOnDismissListener(new OnDismissListener() { | |
3128 @Override | |
3129 public void onDismiss() { | |
3130 hideMediaDownloadInProductHelp(); | |
3131 } | |
3132 }); | |
3133 } else { | |
3134 // Inform native that the button was dismissed to notify the ren derer that the | |
3135 // request was rejected. | |
3136 nativeDownloadMediaInProductHelpDismissed(mNativeTabAndroid); | |
nyquist
2017/06/29 02:10:23
Note to self, this is in the same callstack as sho
| |
3137 return; | |
3138 } | |
3139 } | |
3140 | |
3141 Rect rect = new Rect(x, y, x + width, y + height); | |
3142 mDownloadIPHBubble.setAnchorRect(rect); | |
3143 } | |
3144 | |
3145 @CalledByNative | |
3146 public void hideMediaDownloadInProductHelp() { | |
3147 if (mDownloadIPHBubble == null) return; | |
3148 | |
3149 mDownloadIPHBubble.dismiss(); | |
3150 mDownloadIPHBubble = null; | |
3151 FeatureEngagementTracker tracker = | |
3152 FeatureEngagementTrackerFactory.getFeatureEngagementTrackerForPr ofile(getProfile()); | |
3153 tracker.dismissed(FeatureConstants.MEDIA_DOWNLOAD_FEATURE); | |
3154 nativeDownloadMediaInProductHelpDismissed(mNativeTabAndroid); | |
3155 } | |
3156 | |
3107 private native void nativeInit(); | 3157 private native void nativeInit(); |
3108 private native void nativeDestroy(long nativeTabAndroid); | 3158 private native void nativeDestroy(long nativeTabAndroid); |
3109 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, | 3159 private native void nativeInitWebContents(long nativeTabAndroid, boolean inc ognito, |
3110 boolean isBackgroundTab, WebContents webContents, | 3160 boolean isBackgroundTab, WebContents webContents, |
3111 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); | 3161 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); |
3112 private native void nativeUpdateDelegates(long nativeTabAndroid, | 3162 private native void nativeUpdateDelegates(long nativeTabAndroid, |
3113 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); | 3163 TabWebContentsDelegateAndroid delegate, ContextMenuPopulator context MenuPopulator); |
3114 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); | 3164 private native void nativeDestroyWebContents(long nativeTabAndroid, boolean deleteNative); |
3115 private native void nativeOnPhysicalBackingSizeChanged( | 3165 private native void nativeOnPhysicalBackingSizeChanged( |
3116 long nativeTabAndroid, WebContents webContents, int width, int heigh t); | 3166 long nativeTabAndroid, WebContents webContents, int width, int heigh t); |
(...skipping 12 matching lines...) Expand all Loading... | |
3129 private native void nativeLoadOriginalImage(long nativeTabAndroid); | 3179 private native void nativeLoadOriginalImage(long nativeTabAndroid); |
3130 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); | 3180 private native long nativeGetBookmarkId(long nativeTabAndroid, boolean onlyE ditable); |
3131 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, | 3181 private native void nativeSetInterceptNavigationDelegate(long nativeTabAndro id, |
3132 InterceptNavigationDelegate delegate); | 3182 InterceptNavigationDelegate delegate); |
3133 private native void nativeAttachToTabContentManager(long nativeTabAndroid, | 3183 private native void nativeAttachToTabContentManager(long nativeTabAndroid, |
3134 TabContentManager tabContentManager); | 3184 TabContentManager tabContentManager); |
3135 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); | 3185 private native boolean nativeHasPrerenderedUrl(long nativeTabAndroid, String url); |
3136 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope); | 3186 private native void nativeSetWebappManifestScope(long nativeTabAndroid, Stri ng scope); |
3137 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled); | 3187 private native void nativeEnableEmbeddedMediaExperience(long nativeTabAndroi d, boolean enabled); |
3138 private native void nativeAttachDetachedTab(long nativeTabAndroid); | 3188 private native void nativeAttachDetachedTab(long nativeTabAndroid); |
3189 private native void nativeDownloadMediaInProductHelpDismissed(long nativeTab Android); | |
3139 } | 3190 } |
OLD | NEW |