Commit a19e912e authored by Filip Gorski's avatar Filip Gorski Committed by Commit Bot

[EoC] Adding option to override the referrer URL

Bug: 891980
Change-Id: I0cf05a9dfd9eccce9765cdfa5ed238bc990bd636
Reviewed-on: https://chromium-review.googlesource.com/c/1260512
Commit-Queue: Filip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarTheresa <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596764}
parent 60ed0f8d
...@@ -35,10 +35,15 @@ public final class SuggestionsConfig { ...@@ -35,10 +35,15 @@ public final class SuggestionsConfig {
private static final String REFERRER_URL_PARAM = "referrer_url"; private static final String REFERRER_URL_PARAM = "referrer_url";
/** /**
* Default value for referrer URL. * Default value of referrer URL for content suggestions.
* It must be kept in sync with //components/ntp_suggestions/features.cc * It must be kept in sync with //components/ntp_suggestions/features.cc
*/ */
private static final String DEFAULT_REFERRER_URL = "https://discover.google.com/"; private static final String DEFAULT_CONTENT_SUGGESTIONS_REFERRER_URL =
"https://discover.google.com/";
/** Default value of referrer URL for contextual suggestions. */
private static final String DEFAULT_CONTEXTUAL_SUGGESTIONS_REFERRER_URL =
"https://goto.google.com/explore-on-content-viewer";
private SuggestionsConfig() {} private SuggestionsConfig() {}
...@@ -83,6 +88,19 @@ public final class SuggestionsConfig { ...@@ -83,6 +88,19 @@ public final class SuggestionsConfig {
* @return The value of referrer URL to use with content suggestions. * @return The value of referrer URL to use with content suggestions.
*/ */
public static String getReferrerUrl(String featureName) { public static String getReferrerUrl(String featureName) {
assert ChromeFeatureList.NTP_ARTICLE_SUGGESTIONS.equals(featureName)
|| ChromeFeatureList.INTEREST_FEED_CONTENT_SUGGESTIONS.equals(featureName)
|| ChromeFeatureList.CONTEXTUAL_SUGGESTIONS_BUTTON.equals(featureName);
if (ChromeFeatureList.CONTEXTUAL_SUGGESTIONS_BUTTON.equals(featureName)) {
return getReferrerUrlParamOrDefault(
featureName, DEFAULT_CONTEXTUAL_SUGGESTIONS_REFERRER_URL);
}
return getReferrerUrlParamOrDefault(featureName, DEFAULT_CONTENT_SUGGESTIONS_REFERRER_URL);
}
private static String getReferrerUrlParamOrDefault(String featureName, String defaultValue) {
String referrerParamValue = String referrerParamValue =
ChromeFeatureList.getFieldTrialParamByFeature(featureName, REFERRER_URL_PARAM); ChromeFeatureList.getFieldTrialParamByFeature(featureName, REFERRER_URL_PARAM);
...@@ -90,6 +108,6 @@ public final class SuggestionsConfig { ...@@ -90,6 +108,6 @@ public final class SuggestionsConfig {
return referrerParamValue; return referrerParamValue;
} }
return DEFAULT_REFERRER_URL; return defaultValue;
} }
} }
...@@ -32,8 +32,6 @@ import org.chromium.ui.mojom.WindowOpenDisposition; ...@@ -32,8 +32,6 @@ import org.chromium.ui.mojom.WindowOpenDisposition;
* Extension of {@link NativePageNavigationDelegate} with suggestions-specific methods. * Extension of {@link NativePageNavigationDelegate} with suggestions-specific methods.
*/ */
public class SuggestionsNavigationDelegate extends NativePageNavigationDelegateImpl { public class SuggestionsNavigationDelegate extends NativePageNavigationDelegateImpl {
private static final String CHROME_CONTEXTUAL_SUGGESTIONS_REFERRER =
"https://goto.google.com/explore-on-content-viewer";
private static final String NEW_TAB_URL_HELP = "https://support.google.com/chrome/?p=new_tab"; private static final String NEW_TAB_URL_HELP = "https://support.google.com/chrome/?p=new_tab";
public SuggestionsNavigationDelegate(ChromeActivity activity, Profile profile, public SuggestionsNavigationDelegate(ChromeActivity activity, Profile profile,
...@@ -136,7 +134,9 @@ public class SuggestionsNavigationDelegate extends NativePageNavigationDelegateI ...@@ -136,7 +134,9 @@ public class SuggestionsNavigationDelegate extends NativePageNavigationDelegateI
// from a page. // from a page.
if (article.mCategory == KnownCategories.CONTEXTUAL) { if (article.mCategory == KnownCategories.CONTEXTUAL) {
loadUrlParams.setReferrer( loadUrlParams.setReferrer(
new Referrer(CHROME_CONTEXTUAL_SUGGESTIONS_REFERRER, WebReferrerPolicy.ALWAYS)); new Referrer(SuggestionsConfig.getReferrerUrl(
ChromeFeatureList.CONTEXTUAL_SUGGESTIONS_BUTTON),
WebReferrerPolicy.ALWAYS));
} }
Tab loadingTab = openUrl(windowOpenDisposition, loadUrlParams); Tab loadingTab = openUrl(windowOpenDisposition, loadUrlParams);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment