Commit 6fa012a7 authored by Andy Paicu's avatar Andy Paicu Committed by Commit Bot

Remove unused UI flavors of notifications permission prompts

This CL removes the HEADS_UP_NOTIFICATION and QUIET_NOTIFICATION
user-facing UI surfaces, namely the "chrome://flags" screen and
the chrome notification channels settings screen.

This ensure that either by user-intervention or auto-embargo
logic, only the mini-infobar will be selected when a quiet
UI needs to be shown.

Follow-up CL will remove/refactor all the code that has now
become useless, related to the ability to display the
permission request prompt as a notification.

Bug: 1029718
Change-Id: Ib01e50209184c81abb53770e21a3deda9a2228ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1946469
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720509}
parent e9284683
...@@ -592,6 +592,7 @@ public class NotificationPlatformBridge { ...@@ -592,6 +592,7 @@ public class NotificationPlatformBridge {
.setHideLargeIcon(notificationType == NotificationType.PERMISSION_REQUEST); .setHideLargeIcon(notificationType == NotificationType.PERMISSION_REQUEST);
if (notificationType == NotificationType.PERMISSION_REQUEST) { if (notificationType == NotificationType.PERMISSION_REQUEST) {
assert false; // Notification permission requests are not used anymore.
@PermissionFieldTrial.UIFlavor @PermissionFieldTrial.UIFlavor
int ui_flavor = PermissionFieldTrial.uiFlavorToUse(); int ui_flavor = PermissionFieldTrial.uiFlavorToUse();
......
...@@ -179,16 +179,6 @@ public class ChannelDefinitions { ...@@ -179,16 +179,6 @@ public class ChannelDefinitions {
NotificationManager.IMPORTANCE_LOW, ChannelGroupId.GENERAL, NotificationManager.IMPORTANCE_LOW, ChannelGroupId.GENERAL,
true /* showNotificationBadges */)); true /* showNotificationBadges */));
map.put(ChannelId.PERMISSION_REQUESTS,
new PredefinedChannel(ChannelId.PERMISSION_REQUESTS,
R.string.notification_category_permission_requests,
NotificationManager.IMPORTANCE_LOW, ChannelGroupId.GENERAL));
map.put(ChannelId.PERMISSION_REQUESTS_HIGH,
new PredefinedChannel(ChannelId.PERMISSION_REQUESTS_HIGH,
R.string.notification_category_permission_requests,
NotificationManager.IMPORTANCE_HIGH, ChannelGroupId.GENERAL));
MAP = Collections.unmodifiableMap(map); MAP = Collections.unmodifiableMap(map);
STARTUP = Collections.unmodifiableSet(startup); STARTUP = Collections.unmodifiableSet(startup);
} }
...@@ -200,7 +190,9 @@ public class ChannelDefinitions { ...@@ -200,7 +190,9 @@ public class ChannelDefinitions {
* channel ids so they aren't accidentally reused. * channel ids so they aren't accidentally reused.
*/ */
private static final String[] LEGACY_CHANNEL_IDS = { private static final String[] LEGACY_CHANNEL_IDS = {
ChannelDefinitions.ChannelId.SITES ChannelDefinitions.ChannelId.SITES,
ChannelDefinitions.ChannelId.PERMISSION_REQUESTS,
ChannelDefinitions.ChannelId.PERMISSION_REQUESTS_HIGH,
}; };
// Map defined in static inner class so it's only initialized lazily. // Map defined in static inner class so it's only initialized lazily.
......
...@@ -20,18 +20,12 @@ import java.lang.annotation.RetentionPolicy; ...@@ -20,18 +20,12 @@ import java.lang.annotation.RetentionPolicy;
*/ */
public class PermissionFieldTrial { public class PermissionFieldTrial {
// Keep in sync with "chrome/browser/permissions/permission_features.h" // Keep in sync with "chrome/browser/permissions/permission_features.h"
private static final String QUIET_NOTIFICATION_PROMPTS_UI_FLAVOR_PARAMETER_NAME = "ui_flavour";
private static final String QUIET_NOTIFICATION_PROMPTS_HEADS_UP_NOTIFICATION =
"heads_up_notification";
private static final String QUIET_NOTIFICATION_PROMPTS_MINI_INFOBAR = "mini_infobar"; private static final String QUIET_NOTIFICATION_PROMPTS_MINI_INFOBAR = "mini_infobar";
@IntDef({UIFlavor.NONE, UIFlavor.QUIET_NOTIFICATION, UIFlavor.HEADS_UP_NOTIFICATION, @IntDef({UIFlavor.NONE, UIFlavor.MINI_INFOBAR})
UIFlavor.MINI_INFOBAR})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface UIFlavor { public @interface UIFlavor {
int NONE = 0; int NONE = 0;
int QUIET_NOTIFICATION = 1;
int HEADS_UP_NOTIFICATION = 2;
int MINI_INFOBAR = 3; int MINI_INFOBAR = 3;
} }
...@@ -40,45 +34,18 @@ public class PermissionFieldTrial { ...@@ -40,45 +34,18 @@ public class PermissionFieldTrial {
return UIFlavor.NONE; return UIFlavor.NONE;
} }
switch (ChromeFeatureList.getFieldTrialParamByFeature( return UIFlavor.MINI_INFOBAR;
ChromeFeatureList.QUIET_NOTIFICATION_PROMPTS,
PermissionFieldTrial.QUIET_NOTIFICATION_PROMPTS_UI_FLAVOR_PARAMETER_NAME)) {
case PermissionFieldTrial.QUIET_NOTIFICATION_PROMPTS_HEADS_UP_NOTIFICATION:
return UIFlavor.HEADS_UP_NOTIFICATION;
case PermissionFieldTrial.QUIET_NOTIFICATION_PROMPTS_MINI_INFOBAR:
return UIFlavor.MINI_INFOBAR;
default:
return UIFlavor.QUIET_NOTIFICATION;
}
} }
public static @ChannelDefinitions.ChannelId String notificationChannelIdToUse() { public static @ChannelDefinitions.ChannelId String notificationChannelIdToUse() {
switch (uiFlavorToUse()) { return ChannelDefinitions.ChannelId.BROWSER;
case UIFlavor.QUIET_NOTIFICATION:
return ChannelDefinitions.ChannelId.PERMISSION_REQUESTS;
case UIFlavor.HEADS_UP_NOTIFICATION:
return ChannelDefinitions.ChannelId.PERMISSION_REQUESTS_HIGH;
default:
return ChannelDefinitions.ChannelId.BROWSER;
}
} }
public static int notificationPriorityToUse() { public static int notificationPriorityToUse() {
if (uiFlavorToUse() == UIFlavor.HEADS_UP_NOTIFICATION) {
return NotificationCompat.PRIORITY_MAX;
}
return NotificationCompat.PRIORITY_LOW; return NotificationCompat.PRIORITY_LOW;
} }
public static @NotificationUmaTracker.SystemNotificationType int systemNotificationTypeToUse() { public static @NotificationUmaTracker.SystemNotificationType int systemNotificationTypeToUse() {
switch (uiFlavorToUse()) { return NotificationUmaTracker.SystemNotificationType.UNKNOWN;
case UIFlavor.QUIET_NOTIFICATION:
return NotificationUmaTracker.SystemNotificationType.PERMISSION_REQUESTS;
case UIFlavor.HEADS_UP_NOTIFICATION:
return NotificationUmaTracker.SystemNotificationType.PERMISSION_REQUESTS_HIGH;
default:
return NotificationUmaTracker.SystemNotificationType.UNKNOWN;
}
} }
} }
...@@ -1311,20 +1311,6 @@ const FeatureEntry::FeatureVariation ...@@ -1311,20 +1311,6 @@ const FeatureEntry::FeatureVariation
#endif // OS_ANDROID #endif // OS_ANDROID
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
const FeatureEntry::FeatureParam
kQuietNotificationPromptsForceQuietNotifications[] = {
{kQuietNotificationPromptsUIFlavorParameterName,
kQuietNotificationPromptsQuietNotification},
{kQuietNotificationPromptsActivationParameterName,
kQuietNotificationPromptsActivationAlways},
};
const FeatureEntry::FeatureParam
kQuietNotificationPromptsForceHeadsUpNotifications[] = {
{kQuietNotificationPromptsUIFlavorParameterName,
kQuietNotificationPromptsHeadsUpNotification},
{kQuietNotificationPromptsActivationParameterName,
kQuietNotificationPromptsActivationAlways},
};
const FeatureEntry::FeatureParam kQuietNotificationPromptsForceMiniInfobars[] = const FeatureEntry::FeatureParam kQuietNotificationPromptsForceMiniInfobars[] =
{ {
{kQuietNotificationPromptsUIFlavorParameterName, {kQuietNotificationPromptsUIFlavorParameterName,
...@@ -1333,15 +1319,10 @@ const FeatureEntry::FeatureParam kQuietNotificationPromptsForceMiniInfobars[] = ...@@ -1333,15 +1319,10 @@ const FeatureEntry::FeatureParam kQuietNotificationPromptsForceMiniInfobars[] =
kQuietNotificationPromptsActivationAlways}, kQuietNotificationPromptsActivationAlways},
}; };
// The "default" option that only shows "Enabled" will be "quiet notifications", // The default "Enabled" option has the semantics of showing "mini-infobars"
// triggered after 3 consecutive denies. // adaptively after 3 consecutive denies (or when enabled in settings). In
// addition to that, expose an option to force-enable "mini-infobars".
const FeatureEntry::FeatureVariation kQuietNotificationPromptsVariations[] = { const FeatureEntry::FeatureVariation kQuietNotificationPromptsVariations[] = {
{"(force quiet notifications)",
kQuietNotificationPromptsForceQuietNotifications,
base::size(kQuietNotificationPromptsForceQuietNotifications), nullptr},
{"(force heads-up notifications)",
kQuietNotificationPromptsForceHeadsUpNotifications,
base::size(kQuietNotificationPromptsForceHeadsUpNotifications), nullptr},
{"(force mini-infobars)", kQuietNotificationPromptsForceMiniInfobars, {"(force mini-infobars)", kQuietNotificationPromptsForceMiniInfobars,
base::size(kQuietNotificationPromptsForceMiniInfobars), nullptr}, base::size(kQuietNotificationPromptsForceMiniInfobars), nullptr},
}; };
......
...@@ -32,19 +32,13 @@ QuietNotificationsPromptConfig::UIFlavorToUse() { ...@@ -32,19 +32,13 @@ QuietNotificationsPromptConfig::UIFlavorToUse() {
if (!base::FeatureList::IsEnabled(features::kQuietNotificationPrompts)) if (!base::FeatureList::IsEnabled(features::kQuietNotificationPrompts))
return UIFlavor::NONE; return UIFlavor::NONE;
#if defined(OS_ANDROID)
return UIFlavor::MINI_INFOBAR;
#else // OS_ANDROID
std::string ui_flavor = base::GetFieldTrialParamValueByFeature( std::string ui_flavor = base::GetFieldTrialParamValueByFeature(
features::kQuietNotificationPrompts, features::kQuietNotificationPrompts,
kQuietNotificationPromptsUIFlavorParameterName); kQuietNotificationPromptsUIFlavorParameterName);
#if defined(OS_ANDROID)
if (ui_flavor == kQuietNotificationPromptsHeadsUpNotification) {
return UIFlavor::HEADS_UP_NOTIFICATION;
} else if (ui_flavor == kQuietNotificationPromptsMiniInfobar) {
return UIFlavor::MINI_INFOBAR;
} else {
return UIFlavor::QUIET_NOTIFICATION;
}
#else // OS_ANDROID
if (ui_flavor == kQuietNotificationPromptsStaticIcon) { if (ui_flavor == kQuietNotificationPromptsStaticIcon) {
return UIFlavor::STATIC_ICON; return UIFlavor::STATIC_ICON;
} else if (ui_flavor == kQuietNotificationPromptsAnimatedIcon) { } else if (ui_flavor == kQuietNotificationPromptsAnimatedIcon) {
......
...@@ -190,7 +190,7 @@ TEST_F(PermissionRequestNotificationAndroidTest, ShouldShowAsNotification) { ...@@ -190,7 +190,7 @@ TEST_F(PermissionRequestNotificationAndroidTest, ShouldShowAsNotification) {
AdaptiveNotificationPermissionUiSelector::GetForProfile(profile()) AdaptiveNotificationPermissionUiSelector::GetForProfile(profile())
->set_should_show_quiet_ui_for_testing(true); ->set_should_show_quiet_ui_for_testing(true);
EXPECT_TRUE(PermissionRequestNotificationAndroid::ShouldShowAsNotification( EXPECT_FALSE(PermissionRequestNotificationAndroid::ShouldShowAsNotification(
profile(), ContentSettingsType::NOTIFICATIONS)); profile(), ContentSettingsType::NOTIFICATIONS));
EXPECT_FALSE(PermissionRequestNotificationAndroid::ShouldShowAsNotification( EXPECT_FALSE(PermissionRequestNotificationAndroid::ShouldShowAsNotification(
profile(), ContentSettingsType::GEOLOCATION)); profile(), ContentSettingsType::GEOLOCATION));
......
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