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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java

Issue 1284743003: Add referrer through service connection in custom tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased 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/customtabs/CustomTabActivity.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
index 28fa0e471ce67fea08ccfd61188d44d53a9577bc..885d767919311307c116029a221975ba8ba5384c 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabActivity.java
@@ -37,6 +37,7 @@ import org.chromium.chrome.browser.toolbar.ToolbarControlContainer;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.chrome.browser.widget.findinpage.FindToolbarManager;
import org.chromium.content_public.browser.LoadUrlParams;
+import org.chromium.content_public.common.Referrer;
/**
* The activity for custom tabs. It will be launched on top of a client's task.
@@ -157,9 +158,15 @@ public class CustomTabActivity extends ChromeActivity {
@Override
public void finishNativeInitialization() {
- String url = IntentHandler.getUrlFromIntent(getIntent());
- String referrer = IntentHandler.getReferrerUrlIncludingExtraHeaders(getIntent(), this);
mSession = mIntentDataProvider.getSession();
+ String url = IntentHandler.getUrlFromIntent(getIntent());
+ // Get any referrer that has been explicitly set by the app.
+ String referrerUrl = IntentHandler.getReferrerUrlIncludingExtraHeaders(getIntent(), this);
+ if (referrerUrl == null) {
+ Referrer referrer = CustomTabsConnection.getInstance(getApplication())
+ .getReferrerForSession(mSession);
+ if (referrer != null) referrerUrl = referrer.getUrl();
+ }
// If extra headers have been passed, cancel any current prerender, as
// prerendering doesn't support extra headers.
if (IntentHandler.getExtraHeadersFromIntent(getIntent()) != null) {
@@ -167,7 +174,7 @@ public class CustomTabActivity extends ChromeActivity {
.takePrerenderedUrl(mSession, "", null);
}
- mTab = new CustomTab(this, getWindowAndroid(), mSession, url, referrer,
+ mTab = new CustomTab(this, getWindowAndroid(), mSession, url, referrerUrl,
Tab.INVALID_TAB_ID, mIntentDataProvider.shouldEnableUrlBarHiding());
getTabModelSelector().setTab(mTab);
@@ -188,8 +195,6 @@ public class CustomTabActivity extends ChromeActivity {
});
mTab.setFullscreenManager(getFullscreenManager());
- loadUrlInCurrentTab(new LoadUrlParams(url),
- IntentHandler.getTimestampFromIntent(getIntent()));
mCustomTabContentHandler = new CustomTabContentHandler() {
@Override
public void loadUrlAndTrackFromTimestamp(LoadUrlParams params, long timestamp) {
@@ -206,6 +211,8 @@ public class CustomTabActivity extends ChromeActivity {
return mIntentHandler.shouldIgnoreIntent(CustomTabActivity.this, intent);
}
};
+ loadUrlInCurrentTab(new LoadUrlParams(url),
+ IntentHandler.getTimestampFromIntent(getIntent()));
super.finishNativeInitialization();
}
@@ -245,6 +252,10 @@ public class CustomTabActivity extends ChromeActivity {
private void loadUrlInCurrentTab(LoadUrlParams params, long timeStamp) {
Intent intent = getIntent();
IntentHandler.addReferrerAndHeaders(params, intent, this);
+ if (params.getReferrer() == null) {
+ params.setReferrer(CustomTabsConnection.getInstance(getApplication())
+ .getReferrerForSession(mSession));
+ }
mTab.loadUrlAndTrackFromTimestamp(params, timeStamp);
}

Powered by Google App Engine
This is Rietveld 408576698