Skip to content

Commit

Permalink
[Sheriff] Revert "[privacy sandbox settings] Rename DialogAction to P…
Browse files Browse the repository at this point in the history
…romptAction"

This reverts commit 6ee23c5.

Reason for revert: Sheriff-o-matic errors, see: https://ci.chromium.org/p/chromium/builders/ci/Network%20Service%20Linux

Original change's description:
> [privacy sandbox settings] Rename DialogAction to PromptAction
>
> Bug: 1321587
> Change-Id: Ideca2f0c848265ff173a8e9b493310b80812be7c
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3637992
> Commit-Queue: Olesia Marukhno <olesiamarukhno@google.com>
> Reviewed-by: Theodore Olsauskas-Warren <sauski@google.com>
> Cr-Commit-Position: refs/heads/main@{#1002665}

Bug: 1321587
Change-Id: Ib13b15df56711a303678b9279fd370854d2e0a19
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3646030
Reviewed-by: Og Astorga <ogastorga@chromium.org>
Commit-Queue: Roman Arora <romanarora@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Owners-Override: Roman Arora <romanarora@google.com>
Cr-Commit-Position: refs/heads/main@{#1002741}
  • Loading branch information
Roman Arora authored and Chromium LUCI CQ committed May 12, 2022
1 parent 7f07275 commit f33a95f
Show file tree
Hide file tree
Showing 20 changed files with 271 additions and 270 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private static List<Topic> sortTopics(List<Topic> topics) {
return PrivacySandboxBridgeJni.get().getRequiredPromptType();
}

public static void promptActionOccurred(@PromptAction int action) {
PrivacySandboxBridgeJni.get().promptActionOccurred(action);
public static void dialogActionOccurred(@DialogAction int action) {
PrivacySandboxBridgeJni.get().dialogActionOccurred(action);
}

@NativeMethods
Expand All @@ -115,6 +115,6 @@ public interface Natives {
Topic[] getBlockedTopics();
void setTopicAllowed(int topicId, int taxonomyVersion, boolean allowed);
int getRequiredPromptType();
void promptActionOccurred(int action);
void dialogActionOccurred(int action);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public PrivacySandboxDialogConsent(Context context) {

@Override
public void show() {
PrivacySandboxBridge.promptActionOccurred(PromptAction.CONSENT_SHOWN);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.CONSENT_SHOWN);
super.show();
}

Expand All @@ -70,19 +70,19 @@ public void show() {
public void onClick(View view) {
int id = view.getId();
if (id == R.id.yes_button) {
PrivacySandboxBridge.promptActionOccurred(PromptAction.CONSENT_ACCEPTED);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.CONSENT_ACCEPTED);
dismiss();
} else if (id == R.id.no_button) {
PrivacySandboxBridge.promptActionOccurred(PromptAction.CONSENT_DECLINED);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.CONSENT_DECLINED);
dismiss();
} else if (id == R.id.dropdown_element) {
LinearLayout dropdownContainer = mContentView.findViewById(R.id.dropdown_container);
if (mDropdownExpanded) {
PrivacySandboxBridge.promptActionOccurred(PromptAction.CONSENT_MORE_INFO_CLOSED);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.CONSENT_MORE_INFO_CLOSED);
dropdownContainer.removeAllViews();
dropdownContainer.setVisibility(View.GONE);
} else {
PrivacySandboxBridge.promptActionOccurred(PromptAction.CONSENT_MORE_INFO_OPENED);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.CONSENT_MORE_INFO_OPENED);
dropdownContainer.setVisibility(View.VISIBLE);
mLayoutInflater.inflate(
R.layout.privacy_sandbox_consent_dropdown, dropdownContainer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public PrivacySandboxDialogNotice(Context context, @NonNull SettingsLauncher set

@Override
public void show() {
PrivacySandboxBridge.promptActionOccurred(PromptAction.NOTICE_SHOWN);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.NOTICE_SHOWN);
super.show();
}

Expand All @@ -46,10 +46,10 @@ public void show() {
public void onClick(View view) {
int id = view.getId();
if (id == R.id.ack_button) {
PrivacySandboxBridge.promptActionOccurred(PromptAction.NOTICE_ACKNOWLEDGE);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.NOTICE_ACKNOWLEDGE);
dismiss();
} else if (id == R.id.settings_button) {
PrivacySandboxBridge.promptActionOccurred(PromptAction.NOTICE_OPEN_SETTINGS);
PrivacySandboxBridge.dialogActionOccurred(DialogAction.NOTICE_OPEN_SETTINGS);
dismiss();
PrivacySandboxSettingsFragmentV3.launchPrivacySandboxSettings(
mContext, mSettingsLauncher, PrivacySandboxReferrer.PRIVACY_SANDBOX_NOTICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class FakePrivacySandboxBridge implements PrivacySandboxBridge.Natives {
private final Set<Topic> mCurrentTopTopics = new HashSet<>();
private final Set<Topic> mBlockedTopics = new HashSet<>();
private @PromptType int mPromptType = PromptType.NONE;
private Integer mLastPromptAction;
private Integer mLastDialogAction;

public FakePrivacySandboxBridge() {
setCurrentTopTopics("Foo", "Bar");
Expand Down Expand Up @@ -155,15 +155,15 @@ public int getRequiredPromptType() {
}

@Override
public void promptActionOccurred(@PromptAction int action) {
mLastPromptAction = action;
public void dialogActionOccurred(@DialogAction int action) {
mLastDialogAction = action;
}

public Integer getLastPromptAction() {
return mLastPromptAction;
public Integer getLastDialogAction() {
return mLastDialogAction;
}

public void resetLastPromptAction() {
mLastPromptAction = null;
public void resetLastDialogAction() {
mLastDialogAction = null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,31 +214,31 @@ public void testControllerShowsConsent() throws IOException {
launchDialog();
// Verify that the consent is shown and the action is recorded.
onViewWaiting(withId(R.id.privacy_sandbox_consent_title));
assertEquals("Last dialog action", PromptAction.CONSENT_SHOWN,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.CONSENT_SHOWN,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
// Accept the consent and verify it worked correctly.
onView(withText(R.string.privacy_sandbox_dialog_yes_button)).perform(click());
assertEquals("Last dialog action", PromptAction.CONSENT_ACCEPTED,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.CONSENT_ACCEPTED,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
onView(withId(R.id.privacy_sandbox_consent_title)).check(doesNotExist());

launchDialog();
// Click on the expanding section and verify it worked correctly.
onViewWaiting(withId(R.id.privacy_sandbox_consent_title));
onView(withId(R.id.dropdown_element)).perform(scrollTo(), click());
assertEquals("Last dialog action", PromptAction.CONSENT_MORE_INFO_OPENED,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.CONSENT_MORE_INFO_OPENED,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
onView(withId(R.id.privacy_sandbox_consent_dropdown)).perform(scrollTo());
onView(withId(R.id.privacy_sandbox_consent_dropdown)).check(matches(isDisplayed()));
onView(withId(R.id.dropdown_element)).perform(scrollTo(), click());
assertEquals("Last dialog action", PromptAction.CONSENT_MORE_INFO_CLOSED,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.CONSENT_MORE_INFO_CLOSED,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
onView(withId(R.id.privacy_sandbox_consent_dropdown)).check(doesNotExist());

// Decline the consent and verify it worked correctly.
onView(withText(R.string.privacy_sandbox_dialog_no_button)).perform(click());
assertEquals("Last dialog action", PromptAction.CONSENT_DECLINED,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.CONSENT_DECLINED,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
onView(withId(R.id.privacy_sandbox_consent_title)).check(doesNotExist());
}

Expand All @@ -249,20 +249,20 @@ public void testControllerShowsNotice() throws IOException, InterruptedException
launchDialog();
// Verify that the consent is shown and the action is recorded.
onViewWaiting(withId(R.id.privacy_sandbox_notice_title));
assertEquals("Last dialog action", PromptAction.NOTICE_SHOWN,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.NOTICE_SHOWN,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
// Acknowledge the notice and verify it worked correctly.
onView(withText(R.string.privacy_sandbox_dialog_acknowledge_button)).perform(click());
assertEquals("Last dialog action", PromptAction.NOTICE_ACKNOWLEDGE,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.NOTICE_ACKNOWLEDGE,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
onView(withId(R.id.privacy_sandbox_notice_title)).check(doesNotExist());

launchDialog();
// Click on the settings button and verify it worked correctly.
onViewWaiting(withId(R.id.privacy_sandbox_notice_title));
onView(withText(R.string.privacy_sandbox_dialog_settings_button)).perform(click());
assertEquals("Last dialog action", PromptAction.NOTICE_OPEN_SETTINGS,
(int) mFakePrivacySandboxBridge.getLastPromptAction());
assertEquals("Last dialog action", DialogAction.NOTICE_OPEN_SETTINGS,
(int) mFakePrivacySandboxBridge.getLastDialogAction());
onView(withId(R.id.privacy_sandbox_notice_title)).check(doesNotExist());
Context ctx = (Context) sActivityTestRule.getActivity();
Mockito.verify(mSettingsLauncher)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ static jint JNI_PrivacySandboxBridge_GetRequiredPromptType(JNIEnv* env) {
->GetRequiredPromptType());
}

static void JNI_PrivacySandboxBridge_PromptActionOccurred(JNIEnv* env,
static void JNI_PrivacySandboxBridge_DialogActionOccurred(JNIEnv* env,
jint action) {
PrivacySandboxServiceFactory::GetForProfile(
ProfileManager::GetActiveUserProfile())
->PromptActionOccurred(
static_cast<PrivacySandboxService::PromptAction>(action));
->DialogActionOccurred(
static_cast<PrivacySandboxService::DialogAction>(action));
}
4 changes: 2 additions & 2 deletions chrome/browser/privacy_sandbox/mock_privacy_sandbox_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class MockPrivacySandboxService : public PrivacySandboxService {
~MockPrivacySandboxService() override;

MOCK_METHOD(void,
PromptActionOccurred,
(PrivacySandboxService::PromptAction),
DialogActionOccurred,
(PrivacySandboxService::DialogAction),
(override));
};

Expand Down
42 changes: 21 additions & 21 deletions chrome/browser/privacy_sandbox/privacy_sandbox_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ PrivacySandboxService::GetRequiredPromptType() {
third_party_cookies_blocked);
}

void PrivacySandboxService::PromptActionOccurred(
PrivacySandboxService::PromptAction action) {
void PrivacySandboxService::DialogActionOccurred(
PrivacySandboxService::DialogAction action) {
InformSentimentService(action);
switch (action) {
case (PromptAction::kNoticeShown): {
case (DialogAction::kNoticeShown): {
DCHECK_EQ(PromptType::kNotice, GetRequiredPromptType());
// The new Privacy Sandbox pref can be enabled when the notice has been
// shown. Note that a notice will not have been shown if the user disabled
Expand All @@ -236,58 +236,58 @@ void PrivacySandboxService::PromptActionOccurred(
base::UserMetricsAction("Settings.PrivacySandbox.Notice.Shown"));
break;
}
case (PromptAction::kNoticeOpenSettings): {
case (DialogAction::kNoticeOpenSettings): {
base::RecordAction(base::UserMetricsAction(
"Settings.PrivacySandbox.Notice.OpenedSettings"));
break;
}
case (PromptAction::kNoticeAcknowledge): {
case (DialogAction::kNoticeAcknowledge): {
base::RecordAction(base::UserMetricsAction(
"Settings.PrivacySandbox.Notice.Acknowledged"));
break;
}
case (PromptAction::kNoticeDismiss): {
case (DialogAction::kNoticeDismiss): {
base::RecordAction(
base::UserMetricsAction("Settings.PrivacySandbox.Notice.Dismissed"));
break;
}
case (PromptAction::kNoticeClosedNoInteraction): {
case (DialogAction::kNoticeClosedNoInteraction): {
base::RecordAction(base::UserMetricsAction(
"Settings.PrivacySandbox.Notice.ClosedNoInteraction"));
break;
}
case (PromptAction::kConsentShown): {
case (DialogAction::kConsentShown): {
base::RecordAction(
base::UserMetricsAction("Settings.PrivacySandbox.Consent.Shown"));
break;
}
case (PromptAction::kConsentAccepted): {
case (DialogAction::kConsentAccepted): {
pref_service_->SetBoolean(prefs::kPrivacySandboxApisEnabledV2, true);
pref_service_->SetBoolean(prefs::kPrivacySandboxConsentDecisionMade,
true);
base::RecordAction(
base::UserMetricsAction("Settings.PrivacySandbox.Consent.Accepted"));
break;
}
case (PromptAction::kConsentDeclined): {
case (DialogAction::kConsentDeclined): {
pref_service_->SetBoolean(prefs::kPrivacySandboxApisEnabledV2, false);
pref_service_->SetBoolean(prefs::kPrivacySandboxConsentDecisionMade,
true);
base::RecordAction(
base::UserMetricsAction("Settings.PrivacySandbox.Consent.Declined"));
break;
}
case (PromptAction::kConsentMoreInfoOpened): {
case (DialogAction::kConsentMoreInfoOpened): {
base::RecordAction(base::UserMetricsAction(
"Settings.PrivacySandbox.Consent.LearnMoreExpanded"));
break;
}
case (PromptAction::kConsentClosedNoDecision): {
case (DialogAction::kConsentClosedNoDecision): {
base::RecordAction(base::UserMetricsAction(
"Settings.PrivacySandbox.Consent.ClosedNoInteraction"));
break;
}
case (PromptAction::kNoticeLearnMore): {
case (DialogAction::kNoticeLearnMore): {
base::RecordAction(
base::UserMetricsAction("Settings.PrivacySandbox.Notice.LearnMore"));
break;
Expand Down Expand Up @@ -1057,7 +1057,7 @@ PrivacySandboxService::GetRequiredPromptTypeInternal(
// However, this may not be the first time that this function is being
// called. The API for this service guarantees, and clients depend, on
// successive calls to this function returning the same value. Browser
// restarts & updates via PromptActionOccurred() notwithstanding. To achieve
// restarts & updates via DialogActionOccurred() notwithstanding. To achieve
// this, we need to distinguish between the case where the user themselves
// previously disabled the APIs, and when this logic disabled them
// previously due to having insufficient confirmation.
Expand Down Expand Up @@ -1104,33 +1104,33 @@ PrivacySandboxService::GetRequiredPromptTypeInternal(
}

void PrivacySandboxService::InformSentimentService(
PrivacySandboxService::PromptAction action) {
PrivacySandboxService::DialogAction action) {
#if !BUILDFLAG(IS_ANDROID)
if (!sentiment_service_)
return;

TrustSafetySentimentService::FeatureArea area;
switch (action) {
case PromptAction::kNoticeOpenSettings:
case DialogAction::kNoticeOpenSettings:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeSettings;
break;
case PromptAction::kNoticeAcknowledge:
case DialogAction::kNoticeAcknowledge:
area = TrustSafetySentimentService::FeatureArea::kPrivacySandbox3NoticeOk;
break;
case PromptAction::kNoticeDismiss:
case DialogAction::kNoticeDismiss:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeDismiss;
break;
case PromptAction::kNoticeLearnMore:
case DialogAction::kNoticeLearnMore:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3NoticeLearnMore;
break;
case PromptAction::kConsentAccepted:
case DialogAction::kConsentAccepted:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3ConsentAccept;
break;
case PromptAction::kConsentDeclined:
case DialogAction::kConsentDeclined:
area = TrustSafetySentimentService::FeatureArea::
kPrivacySandbox3ConsentDecline;
break;
Expand Down
14 changes: 8 additions & 6 deletions chrome/browser/privacy_sandbox/privacy_sandbox_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ class PrivacySandboxService : public KeyedService,
};

// An exhaustive list of actions related to showing & interacting with the
// prompt. Includes actions which do not impact consent / notice state.
// dialog. Includes actions which do not impact consent / notice state.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.privacy_sandbox
enum class PromptAction {
// TODO(crbug.com/1321587): Rename to PromptAction as the UI can be presented
// as a bubble, a dialog or a bottomsheet.
enum class DialogAction {
// Notice Interactions:
kNoticeShown = 0,
kNoticeOpenSettings = 1,
Expand Down Expand Up @@ -118,13 +120,13 @@ class PrivacySandboxService : public KeyedService,
// Virtual to allow mocking in tests.
virtual PromptType GetRequiredPromptType();

// Informs the service that |action| occurred with the prompt. This allows
// Informs the service that |action| occurred with the dialog. This allows
// the service to record this information in preferences such that future
// calls to GetRequiredPromptType() are correct. This is expected to be
// called appropriately by all locations showing the prompt. Metrics shared
// called appropriately by all locations showing the dialog. Metrics shared
// between platforms will also be recorded.
// This method is virtual for mocking in tests.
virtual void PromptActionOccurred(PromptAction action);
virtual void DialogActionOccurred(DialogAction action);

// Returns whether |url| is suitable to display the Privacy Sandbox dialog
// over. Only about:blank and certain chrome:// URLs are considered suitable.
Expand Down Expand Up @@ -493,7 +495,7 @@ class PrivacySandboxService : public KeyedService,
// Informs the TrustSafetySentimentService, if it exists, that a
// Privacy Sandbox 3 interaction for an area has occurred The area is
// determined by |action|. Only a subset of actions has a corresponding area.
void InformSentimentService(PrivacySandboxService::PromptAction action);
void InformSentimentService(PrivacySandboxService::DialogAction action);

base::WeakPtrFactory<PrivacySandboxService> weak_factory_{this};
};
Expand Down

0 comments on commit f33a95f

Please sign in to comment.