--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -905,50 +905,51 @@ public class Tabs implements BundleEvent
*
* @param url URL of page to load
* @param flags flags used to load tab
*
* @return the Tab if a new one was created; null otherwise
*/
@RobocopTarget
public Tab loadUrl(String url, int flags) {
- return loadUrl(url, null, INVALID_TAB_ID, null, flags);
+ return loadUrl(url, null, null, INVALID_TAB_ID, null, flags);
}
public Tab loadUrlWithIntentExtras(final String url, final SafeIntent intent, final int flags) {
// We can't directly create a listener to tell when the user taps on the "What's new"
// notification, so we use this intent handling as a signal that they tapped the notification.
if (intent.getBooleanExtra(WhatsNewReceiver.EXTRA_WHATSNEW_NOTIFICATION, false)) {
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.NOTIFICATION,
WhatsNewReceiver.EXTRA_WHATSNEW_NOTIFICATION);
}
// Note: we don't get the URL from the intent so the calling
// method has the opportunity to change the URL if applicable.
- return loadUrl(url, null, INVALID_TAB_ID, intent, flags);
+ return loadUrl(url, null, null, INVALID_TAB_ID, intent, flags);
}
public Tab loadUrl(final String url, final String searchEngine, final int parentId, final int flags) {
- return loadUrl(url, searchEngine, parentId, null, flags);
+ return loadUrl(url, searchEngine, null, parentId, null, flags);
}
/**
* Loads a tab with the given URL.
*
* @param url URL of page to load, or search term used if searchEngine is given
* @param searchEngine if given, the search engine with this name is used
* to search for the url string; if null, the URL is loaded directly
+ * @param referrerUri the URI which referred this page load, or null if there is none.
* @param parentId ID of this tab's parent, or INVALID_TAB_ID (-1) if it has no parent
* @param intent an intent whose extras are used to modify the request
* @param flags flags used to load tab
*
* @return the Tab if a new one was created; null otherwise
*/
- public Tab loadUrl(final String url, final String searchEngine, final int parentId,
- final SafeIntent intent, final int flags) {
+ public Tab loadUrl(final String url, final String searchEngine, @Nullable final String referrerUri,
+ final int parentId, @Nullable final SafeIntent intent, final int flags) {
final GeckoBundle data = new GeckoBundle();
Tab tabToSelect = null;
boolean delayLoad = (flags & LOADURL_DELAY_LOAD) != 0;
// delayLoad implies background tab
boolean background = delayLoad || (flags & LOADURL_BACKGROUND) != 0;
boolean isPrivate = (flags & LOADURL_PRIVATE) != 0 || (intent != null && intent.getBooleanExtra(PRIVATE_TAB_INTENT_EXTRA, false));
@@ -959,16 +960,17 @@ public class Tabs implements BundleEvent
data.putString("url", url);
data.putString("engine", searchEngine);
data.putInt("parentId", parentId);
data.putBoolean("userEntered", userEntered);
data.putBoolean("isPrivate", isPrivate);
data.putBoolean("pinned", (flags & LOADURL_PINNED) != 0);
data.putBoolean("desktopMode", desktopMode);
+ data.putString("referrerURI", referrerUri);
final boolean needsNewTab;
final String applicationId = (intent == null) ? null :
intent.getStringExtra(Browser.EXTRA_APPLICATION_ID);
if (applicationId == null) {
needsNewTab = (flags & LOADURL_NEW_TAB) != 0;
} else {
// If you modify this code, be careful that intent != null.
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -1892,16 +1892,25 @@ var BrowserApp = {
isPrivate: (data.isPrivate === true),
pinned: (data.pinned === true),
delayLoad: (delayLoad === true),
desktopMode: (data.desktopMode === true)
};
params.userRequested = url;
+ if (data.referrerURI) {
+ try {
+ params.referrerURI = Services.io.newURI(data.referrerURI);
+ } catch (e) {
+ console.warn("Tab:Load referrerURI is invalid - ignoring."); // don't log exception to avoid leaking urls.
+ params.referrerURI = null;
+ }
+ }
+
if (data.engine) {
let engine = Services.search.getEngineByName(data.engine);
if (engine) {
let submission = engine.getSubmission(url);
url = submission.uri.spec;
params.postData = submission.postData;
params.isSearch = true;
}