Skip to content

Commit

Permalink
[privacy sandbox settings] Add handling NoticeLearnMore action
Browse files Browse the repository at this point in the history
When NoticeLearnMore action occurs, open privacy sandbox page with
"Learn more" dialog opened. Also, inform the HaTS service about the
interaction and if all the conditions are met, show a survey.

Bug: 1321587
Change-Id: I1f004d81da2c0e64aa75940f2b3a066278ec2f11
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3634681
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com>
Commit-Queue: Olesia Marukhno <olesiamarukhno@google.com>
Cr-Commit-Position: refs/heads/main@{#1001980}
  • Loading branch information
Olesia Marukhno authored and Chromium LUCI CQ committed May 11, 2022
1 parent b69cb38 commit 92c9c0d
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 7 deletions.
14 changes: 9 additions & 5 deletions chrome/browser/privacy_sandbox/privacy_sandbox_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1106,22 +1106,26 @@ void PrivacySandboxService::InformSentimentService(

TrustSafetySentimentService::FeatureArea area;
switch (action) {
case (DialogAction::kNoticeOpenSettings):
case DialogAction::kNoticeOpenSettings:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeSettings;
break;
case (DialogAction::kNoticeAcknowledge):
case DialogAction::kNoticeAcknowledge:
area = TrustSafetySentimentService::FeatureArea::kPrivacySandbox3NoticeOk;
break;
case (DialogAction::kNoticeDismiss):
case DialogAction::kNoticeDismiss:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeDismiss;
break;
case (DialogAction::kConsentAccepted):
case DialogAction::kNoticeLearnMore:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeLearnMore;
break;
case DialogAction::kConsentAccepted:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3ConsentAccept;
break;
case (DialogAction::kConsentDeclined):
case DialogAction::kConsentDeclined:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3ConsentDecline;
break;
Expand Down
16 changes: 16 additions & 0 deletions chrome/browser/privacy_sandbox/privacy_sandbox_service_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,22 @@ TEST_F(PrivacySandboxServiceTest, DialogActionsSentimentService) {
privacy_sandbox_service()->DialogActionOccurred(
PrivacySandboxService::DialogAction::kNoticeClosedNoInteraction);
}
{
EXPECT_CALL(
*mock_sentiment_service(),
InteractedWithPrivacySandbox3(TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeLearnMore))
.Times(1);
SetupDialogTestState(feature_list(), prefs(),
{/*consent_required=*/false,
/*old_api_pref=*/true,
/*new_api_pref=*/false,
/*notice_displayed=*/false,
/*consent_decision_made=*/false,
/*confirmation_not_shown=*/false});
privacy_sandbox_service()->DialogActionOccurred(
PrivacySandboxService::DialogAction::kNoticeLearnMore);
}
{
EXPECT_CALL(*mock_sentiment_service(),
InteractedWithPrivacySandbox3(testing::_))
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/ui/chrome_pages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ void ShowPrivacySandboxAdPersonalization(Browser* browser) {
ShowSettingsSubPage(browser, kPrivacySandboxAdPersonalizationSubPage);
}

void ShowPrivacySandboxLearnMore(Browser* browser) {
base::RecordAction(UserMetricsAction("Options_ShowPrivacySandbox"));
ShowSettingsSubPage(browser, kPrivacySandboxLearnMoreSubPage);
}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void ShowEnterpriseManagementPageInTabbedBrowser(Browser* browser) {
// Management shows in a tab because it has a "back" arrow that takes the
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/chrome_pages.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ void ShowSearchEngineSettings(Browser* browser);
void ShowWebStore(Browser* browser);
void ShowPrivacySandboxSettings(Browser* browser);
void ShowPrivacySandboxAdPersonalization(Browser* browser);
void ShowPrivacySandboxLearnMore(Browser* browser);

#if BUILDFLAG(IS_CHROMEOS_ASH)
// Shows the enterprise management info page in a browser tab.
Expand Down
10 changes: 10 additions & 0 deletions chrome/browser/ui/hats/hats_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ constexpr char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeOk[] =
"ts-ps3-notice-ok";
constexpr char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeSettings[] =
"ts-ps3-notice-settings";
constexpr char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeLearnMore[] =
"ts-ps3-notice-learn-more";
constexpr char kHatsSurveyTriggerTrustSafetyPrivacySettings[] =
"ts-privacy-settings";
constexpr char kHatsSurveyTriggerTrustSafetyTrustedSurface[] =
Expand Down Expand Up @@ -221,6 +223,14 @@ std::vector<HatsService::SurveyConfig> GetSurveyConfigs() {
.Get(),
std::vector<std::string>{"Stable channel", "3P cookies blocked",
"Privacy Sandbox enabled"});
survey_configs.emplace_back(
&features::kTrustSafetySentimentSurvey,
kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeLearnMore,
features::
kTrustSafetySentimentSurveyPrivacySandbox3NoticeLearnMoreTriggerId
.Get(),
std::vector<std::string>{"Stable channel", "3P cookies blocked",
"Privacy Sandbox enabled"});

// Accuracy tips survey.
survey_configs.emplace_back(
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/hats/hats_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3ConsentDecline[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeDismiss[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeOk[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeSettings[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeLearnMore[];
extern const char kHatsSurveyTriggerTrustSafetyPrivacySettings[];
extern const char kHatsSurveyTriggerTrustSafetyTrustedSurface[];
extern const char kHatsSurveyTriggerTrustSafetyTransactions[];
Expand Down
9 changes: 9 additions & 0 deletions chrome/browser/ui/hats/trust_safety_sentiment_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ std::string GetHatsTriggerForFeatureArea(
case (TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeSettings):
return kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeSettings;
case (TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeLearnMore):
return kHatsSurveyTriggerTrustSafetyPrivacySandbox3NoticeLearnMore;
default:
NOTREACHED();
return "";
Expand Down Expand Up @@ -118,6 +121,12 @@ bool ProbabilityCheck(TrustSafetySentimentService::FeatureArea feature_area) {
features::
kTrustSafetySentimentSurveyPrivacySandbox3NoticeSettingsProbability
.Get();
case (TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeLearnMore):
return base::RandDouble() <
features::
kTrustSafetySentimentSurveyPrivacySandbox3NoticeLearnMoreProbability
.Get();
default:
NOTREACHED();
return false;
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ui/hats/trust_safety_sentiment_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class TrustSafetySentimentService : public KeyedService,
kPrivacySandbox3NoticeDismiss = 6,
kPrivacySandbox3NoticeOk = 7,
kPrivacySandbox3NoticeSettings = 8,
kMaxValue = kPrivacySandbox3NoticeSettings,
kPrivacySandbox3NoticeLearnMore = 9,
kMaxValue = kPrivacySandbox3NoticeLearnMore,
};

// Called when the user interacts with Privacy Sandbox 3, |feature_area|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ void PrivacySandboxNoticeBubbleView::AppMenuShown() {
}

void PrivacySandboxNoticeBubbleView::OpenAboutAdPersonalizationSettings() {
chrome::ShowPrivacySandboxSettings(browser_);
chrome::ShowPrivacySandboxLearnMore(browser_);
NotifyServiceAboutDialogAction(browser_->profile(),
DialogAction::kNoticeLearnMore);
GetWidget()->CloseWithReason(
Expand Down
8 changes: 8 additions & 0 deletions chrome/common/chrome_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,10 @@ const base::FeatureParam<double>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeSettingsProbability{
&kTrustSafetySentimentSurvey,
"privacy-sandbox-3-notice-settings-probability", 0.8};
const base::FeatureParam<double>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeLearnMoreProbability{
&kTrustSafetySentimentSurvey,
"privacy-sandbox-3-notice-learn-more-probability", 0.2};
// The HaTS trigger IDs, which determine which survey is delivered from the HaTS
// backend.
const base::FeatureParam<std::string>
Expand Down Expand Up @@ -1066,6 +1070,10 @@ extern const base::FeatureParam<std::string>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeSettingsTriggerId{
&kTrustSafetySentimentSurvey,
"privacy-sandbox-3-notice-settings-trigger-id", ""};
extern const base::FeatureParam<std::string>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeLearnMoreTriggerId{
&kTrustSafetySentimentSurvey,
"privacy-sandbox-3-notice-learn-more-trigger-id", ""};
// The time the user must remain on settings after interacting with a privacy
// setting to be considered.
const base::FeatureParam<base::TimeDelta>
Expand Down
6 changes: 6 additions & 0 deletions chrome/common/chrome_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,9 @@ COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::FeatureParam<double>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeSettingsProbability;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::FeatureParam<double>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeLearnMoreProbability;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::FeatureParam<std::string>
kTrustSafetySentimentSurveyPrivacySettingsTriggerId;
COMPONENT_EXPORT(CHROME_FEATURES)
Expand All @@ -729,6 +732,9 @@ COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::FeatureParam<std::string>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeSettingsTriggerId;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::FeatureParam<std::string>
kTrustSafetySentimentSurveyPrivacySandbox3NoticeLearnMoreTriggerId;
COMPONENT_EXPORT(CHROME_FEATURES)
extern const base::FeatureParam<base::TimeDelta>
kTrustSafetySentimentSurveyPrivacySettingsTime;
COMPONENT_EXPORT(CHROME_FEATURES)
Expand Down
2 changes: 2 additions & 0 deletions chrome/common/webui_url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ const char kManageProfileSubPage[] = "manageProfile";
const char kPeopleSubPage[] = "people";
const char kPrivacySandboxAdPersonalizationSubPage[] =
"privacySandbox?view=adPersonalizationDialog";
const char kPrivacySandboxLearnMoreSubPage[] =
"privacySandbox?view=learnMoreDialog";
const char kPrivacySandboxSubPage[] = "privacySandbox";

#if !BUILDFLAG(IS_ANDROID)
Expand Down
1 change: 1 addition & 0 deletions chrome/common/webui_url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ extern const char kSignOutSubPage[];
extern const char kSyncSetupSubPage[];
extern const char kTriggeredResetProfileSettingsSubPage[];
extern const char kPrivacySandboxAdPersonalizationSubPage[];
extern const char kPrivacySandboxLearnMoreSubPage[];
extern const char kPrivacySandboxSubPage[];

#if !BUILDFLAG(IS_ANDROID)
Expand Down

0 comments on commit 92c9c0d

Please sign in to comment.