Commit a2d0b5a2 authored by Lijin Shen's avatar Lijin Shen Committed by Commit Bot

Add suffix to promo intent key in default browser promo

Add a suffix to the key of intent data to distinguish intent from
another chrome channel. Otherwise, intent from another chrome channel
leads to an unnecessary metrics logging.

Bug: 1090103
Change-Id: Iead382e1c052759da2c491c4d87bf61d142698f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2299523
Commit-Queue: Lijin Shen <lazzzis@google.com>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Reviewed-by: default avatarPavel Yatsuk <pavely@chromium.org>
Cr-Commit-Position: refs/heads/master@{#788781}
parent 136eaf26
......@@ -158,7 +158,7 @@ public class DefaultBrowserPromoManager implements PauseResumeWithNativeObserver
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_APP_BROWSER);
}
intent.putExtra(DefaultBrowserPromoUtils.DISAMBIGUATION_SHEET_PROMOED_KEY, true);
intent.putExtra(DefaultBrowserPromoUtils.getDisambiguationSheetPromoedKey(), true);
mActivity.startActivity(intent);
});
}
......
......@@ -54,7 +54,8 @@ public class DefaultBrowserPromoUtils {
private static final String PROMO_COUNT_PARAM = "max_promo_count";
private static final String PROMO_INTERVAL_PARAM = "promo_interval";
static final String DISAMBIGUATION_SHEET_PROMOED_KEY = "disambiguation_sheet_promoed";
private static final String DISAMBIGUATION_SHEET_PROMOED_KEY_PREFIX =
"disambiguation_sheet_promoed.";
static final String CHROME_STABLE_PACKAGE_NAME = "com.android.chrome";
// TODO(crbug.com/1090103): move to some util class for reuse.
......@@ -194,19 +195,24 @@ public class DefaultBrowserPromoUtils {
* Called on new intent is received on the activity so that we can record some metrics.
*/
public static void onNewIntentReceived(Intent intent) {
boolean promoed = intent.getBooleanExtra(DISAMBIGUATION_SHEET_PROMOED_KEY, false);
boolean promoed = intent.getBooleanExtra(getDisambiguationSheetPromoedKey(), false);
if (promoed) {
DefaultBrowserPromoMetrics.recordLaunchedByDisambiguationSheet(
getCurrentDefaultBrowserState());
}
}
static String getDisambiguationSheetPromoedKey() {
return DISAMBIGUATION_SHEET_PROMOED_KEY_PREFIX
+ ContextUtils.getApplicationContext().getPackageName();
}
/**
* Remove intent data if this intent is triggered by default browser promo; Otherwise,
* chrome will open a new tab.
*/
public static void maybeRemoveIntentData(Intent intent) {
if (intent.getBooleanExtra(DISAMBIGUATION_SHEET_PROMOED_KEY, false)) {
if (intent.getBooleanExtra(getDisambiguationSheetPromoedKey(), false)) {
// Intent with Uri.EMPTY as data will be ignored by the IntentHandler.
intent.setData(Uri.EMPTY);
}
......
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