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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java

Issue 1243253004: Pass user gesture bit when chrome handles an intent fired by itself (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix findbugs warning Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
index cffa39538a0eee250972fb53a02347d9d7a1249e..08ce9a40f90c4f3107b6e16c5e46875e49c769cb 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/document/ChromeLauncherActivity.java
@@ -39,6 +39,7 @@ import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.WarmupManager;
import org.chromium.chrome.browser.WebappAuthenticator;
import org.chromium.chrome.browser.customtabs.CustomTabActivity;
+import org.chromium.chrome.browser.externalnav.IntentWithGesturesHandler;
import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
import org.chromium.chrome.browser.metrics.LaunchHistogram;
import org.chromium.chrome.browser.metrics.LaunchMetrics;
@@ -254,7 +255,7 @@ public class ChromeLauncherActivity extends Activity
@Override
public void processUrlViewIntent(String url, String referer, String headers,
IntentHandler.TabOpenType tabOpenType, String externalAppId,
- int tabIdToBringToFront, Intent intent) {
+ int tabIdToBringToFront, boolean hasUserGesture, Intent intent) {
assert false;
}
@@ -300,6 +301,9 @@ public class ChromeLauncherActivity extends Activity
maybePrefetchDnsInBackground();
+ boolean hasUserGesture =
+ IntentWithGesturesHandler.getInstance().getUserGestureAndClear(getIntent());
+
// Increment the Tab ID counter at this point since this Activity may not appear in
// getAppTasks() when DocumentTabModelSelector is initialized. This can potentially happen
// when Chrome is launched via the GSA/e200 search box and they relinquish their task.
@@ -316,7 +320,7 @@ public class ChromeLauncherActivity extends Activity
}
// Sometimes an Intent requests that the current Document get clobbered.
- if (clobberCurrentDocument(url)) return;
+ if (clobberCurrentDocument(url, hasUserGesture)) return;
// Try to retarget existing Documents before creating a new one.
boolean incognito = IntentUtils.safeGetBooleanExtra(getIntent(),
@@ -386,9 +390,10 @@ public class ChromeLauncherActivity extends Activity
/**
* If necessary, attempts to clobber the current DocumentActivity's tab with the given URL.
* @param url URL to display.
+ * @param hasUserGesture Whether the intent is launched from a previous user gesture.
* @return Whether or not the clobber was successful.
*/
- private boolean clobberCurrentDocument(String url) {
+ private boolean clobberCurrentDocument(String url, boolean hasUserGesture) {
boolean shouldOpenNewTab = IntentUtils.safeGetBooleanExtra(
getIntent(), Browser.EXTRA_CREATE_NEW_TAB, false);
String applicationId =
@@ -400,8 +405,11 @@ public class ChromeLauncherActivity extends Activity
if (tabId == Tab.INVALID_TAB_ID) return false;
// Try to clobber the page.
+ LoadUrlParams params = new LoadUrlParams(
+ url, PageTransition.LINK | PageTransition.FROM_API);
+ params.setHasUserGesture(hasUserGesture);
AsyncTabCreationParams data =
- new AsyncTabCreationParams(new LoadUrlParams(url), new Intent(getIntent()));
+ new AsyncTabCreationParams(params, new Intent(getIntent()));
AsyncTabCreationParamsManager.add(tabId, data);
if (!relaunchTask(tabId)) {
// Were not able to clobber, will fall through to handle in a new document.

Powered by Google App Engine
This is Rietveld 408576698