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 {
.setHideLargeIcon(notificationType == NotificationType.PERMISSION_REQUEST);
if (notificationType == NotificationType.PERMISSION_REQUEST) {
assert false; // Notification permission requests are not used anymore.
@PermissionFieldTrial.UIFlavor
int ui_flavor = PermissionFieldTrial.uiFlavorToUse();
......
......@@ -179,16 +179,6 @@ public class ChannelDefinitions {
NotificationManager.IMPORTANCE_LOW, ChannelGroupId.GENERAL,
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);
STARTUP = Collections.unmodifiableSet(startup);
}
......@@ -200,7 +190,9 @@ public class ChannelDefinitions {
* channel ids so they aren't accidentally reused.
*/
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.
......
......@@ -20,18 +20,12 @@ import java.lang.annotation.RetentionPolicy;
*/
public class PermissionFieldTrial {
// 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";
@IntDef({UIFlavor.NONE, UIFlavor.QUIET_NOTIFICATION, UIFlavor.HEADS_UP_NOTIFICATION,
UIFlavor.MINI_INFOBAR})
@IntDef({UIFlavor.NONE, UIFlavor.MINI_INFOBAR})
@Retention(RetentionPolicy.SOURCE)
public @interface UIFlavor {
int NONE = 0;
int QUIET_NOTIFICATION = 1;
int HEADS_UP_NOTIFICATION = 2;
int MINI_INFOBAR = 3;
}
......@@ -40,45 +34,18 @@ public class PermissionFieldTrial {
return UIFlavor.NONE;
}
switch (ChromeFeatureList.getFieldTrialParamByFeature(
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() {
switch (uiFlavorToUse()) {
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() {
if (uiFlavorToUse() == UIFlavor.HEADS_UP_NOTIFICATION) {
return NotificationCompat.PRIORITY_MAX;
}
return NotificationCompat.PRIORITY_LOW;
}
public static @NotificationUmaTracker.SystemNotificationType int systemNotificationTypeToUse() {
switch (uiFlavorToUse()) {
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
#endif // 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[] =
{
{kQuietNotificationPromptsUIFlavorParameterName,
......@@ -1333,15 +1319,10 @@ const FeatureEntry::FeatureParam kQuietNotificationPromptsForceMiniInfobars[] =
kQuietNotificationPromptsActivationAlways},
};
// The "default" option that only shows "Enabled" will be "quiet notifications",
// triggered after 3 consecutive denies.
// The default "Enabled" option has the semantics of showing "mini-infobars"
// 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[] = {
{"(force quiet notifications)",
kQuietNotificationPromptsForceQuietNotifications,
base::size(kQuietNotificationPromptsForceQuietNotifications), nullptr},
{"(force heads-up notifications)",
kQuietNotificationPromptsForceHeadsUpNotifications,
base::size(kQuietNotificationPromptsForceHeadsUpNotifications), nullptr},
{"(force mini-infobars)", kQuietNotificationPromptsForceMiniInfobars,
base::size(kQuietNotificationPromptsForceMiniInfobars), nullptr},
};
......
......@@ -32,19 +32,13 @@ QuietNotificationsPromptConfig::UIFlavorToUse() {
if (!base::FeatureList::IsEnabled(features::kQuietNotificationPrompts))
return UIFlavor::NONE;
#if defined(OS_ANDROID)
return UIFlavor::MINI_INFOBAR;
#else // OS_ANDROID
std::string ui_flavor = base::GetFieldTrialParamValueByFeature(
features::kQuietNotificationPrompts,
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) {
return UIFlavor::STATIC_ICON;
} else if (ui_flavor == kQuietNotificationPromptsAnimatedIcon) {
......
......@@ -190,7 +190,7 @@ TEST_F(PermissionRequestNotificationAndroidTest, ShouldShowAsNotification) {
AdaptiveNotificationPermissionUiSelector::GetForProfile(profile())
->set_should_show_quiet_ui_for_testing(true);
EXPECT_TRUE(PermissionRequestNotificationAndroid::ShouldShowAsNotification(
EXPECT_FALSE(PermissionRequestNotificationAndroid::ShouldShowAsNotification(
profile(), ContentSettingsType::NOTIFICATIONS));
EXPECT_FALSE(PermissionRequestNotificationAndroid::ShouldShowAsNotification(
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