Skip to content

Commit

Permalink
[Merge] Suppress dialog when Chrome is launched from an external app
Browse files Browse the repository at this point in the history
This CL suppresses any Privacy Sandbox dialog if Chrome Tab is launched
from an external app. We added a feature param to switch off the
behavior in case metrics won't match the expectations.

Bug: 1456352

(cherry picked from commit f0ce86d)

Change-Id: If0c8022c0d063fe757a02d09c37346400614e586
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4628111
Reviewed-by: Roger McFarlane <rogerm@chromium.org>
Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Commit-Queue: Nicola Tommasi <tommasin@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1161243}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4643594
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Nicola Tommasi <tommasin@chromium.org>
Cr-Commit-Position: refs/branch-heads/5845@{#129}
Cr-Branched-From: 5a5dff6-refs/heads/main@{#1160321}
  • Loading branch information
Nicola Tommasi authored and Chromium LUCI CQ committed Jun 27, 2023
1 parent 26d8967 commit 5a67eb5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.chromium.base.CallbackController;
import org.chromium.base.CommandLine;
import org.chromium.base.TraceEvent;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.ObservableSupplierImpl;
import org.chromium.base.supplier.OneShotCallback;
Expand Down Expand Up @@ -664,10 +665,25 @@ private void initializeIPH(boolean intentWithEffect) {

if (ChromeFeatureList.isEnabled(ChromeFeatureList.PRIVACY_SANDBOX_SETTINGS_3)
|| ChromeFeatureList.isEnabled(ChromeFeatureList.PRIVACY_SANDBOX_SETTINGS_4)) {
didTriggerPromo = PrivacySandboxDialogController.maybeLaunchPrivacySandboxDialog(
mActivity, new SettingsLauncherImpl(),
mTabModelSelectorSupplier.get().isIncognitoSelected(),
getBottomSheetController());
String histogramName =
"Startup.Android.PrivacySandbox.DialogNotShownDueToTabLaunchedFromExternalApp";
Tab tab = mActivityTabProvider.get();
boolean isTabLaunchedFromExternalApp =
tab != null && tab.getLaunchType() == TabLaunchType.FROM_EXTERNAL_APP;
boolean shouldSuppressPSDialogForExternalAppLaunches =
ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.PRIVACY_SANDBOX_SETTINGS_4,
"suppress-dialog-for-external-app-launches", true);
boolean shouldSuppressPSDialog =
isTabLaunchedFromExternalApp && shouldSuppressPSDialogForExternalAppLaunches;

if (!shouldSuppressPSDialog) {
didTriggerPromo = PrivacySandboxDialogController.maybeLaunchPrivacySandboxDialog(
mActivity, new SettingsLauncherImpl(),
mTabModelSelectorSupplier.get().isIncognitoSelected(),
getBottomSheetController());
}
RecordHistogram.recordBooleanHistogram(histogramName, shouldSuppressPSDialog);
}

if (!didTriggerPromo) {
Expand Down
5 changes: 5 additions & 0 deletions components/privacy_sandbox/privacy_sandbox_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ const base::FeatureParam<bool> kPrivacySandboxSettings4ShowSampleDataForTesting{
&kPrivacySandboxSettings4,
kPrivacySandboxSettings4ShowSampleDataForTestingName, false};

const base::FeatureParam<bool>
kPrivacySandboxSettings4SuppressDialogForExternalAppLaunches{
&kPrivacySandboxSettings4, "suppress-dialog-for-external-app-launches",
true};

BASE_FEATURE(kPrivacySandboxSettings3,
"PrivacySandboxSettings3",
base::FEATURE_ENABLED_BY_DEFAULT);
Expand Down
6 changes: 6 additions & 0 deletions components/privacy_sandbox/privacy_sandbox_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ COMPONENT_EXPORT(PRIVACY_SANDBOX_FEATURES)
extern const base::FeatureParam<bool>
kPrivacySandboxSettings4ShowSampleDataForTesting;

// When true, suppress any Privacy Sandbox dialog if Chrome is launched
// from an external app.
COMPONENT_EXPORT(PRIVACY_SANDBOX_FEATURES)
extern const base::FeatureParam<bool>
kPrivacySandboxSettings4SuppressDialogForExternalAppLaunches;

// Enables the third release of the Privacy Sandbox settings.
COMPONENT_EXPORT(PRIVACY_SANDBOX_FEATURES)
BASE_DECLARE_FEATURE(kPrivacySandboxSettings3);
Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/metadata/startup/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,17 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>

<histogram
name="Startup.Android.PrivacySandbox.DialogNotShownDueToTabLaunchedFromExternalApp"
enum="Boolean" expires_after="2024-03-31">
<owner>tommasin@chromium.org</owner>
<owner>kartoffel-core-eng@google.com</owner>
<summary>
Android: PrivacySandbox dialog not shown because Chrome Tab was launched
from an external app.
</summary>
</histogram>

<histogram base="true" name="Startup.Android.SingleTabTitleAvailableTime"
units="ms" expires_after="2023-11-12">
<!-- Name completed by histogram_suffixes name="JavaStartMode" -->
Expand Down

0 comments on commit 5a67eb5

Please sign in to comment.