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

Added IPH for the mini-infobar notification permission prompt (android)

As part of the new quieter notification prompt, add IPH for the android
quieter notification permission prompt. To be shown the first time
the setting is enabled.

This is controlled by using the functions:
* AdaptiveNotificationPermissionUiSelector::ShouldShowPromo
* AdaptiveNotificationPermissionUiSelector::PromoWasShown

Quick mock of how this is supposed to look:
https://docs.google.com/document/d/1hsp1j08yzIK6M6G7pbsdEihU8CLN7QQ3V2iAxESrqQM/edit?usp=sharing

Bug: 1029595
Change-Id: I3c90dda846a70396f1130c2ad6dcfc3622b9b25f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1944173
Commit-Queue: Andy Paicu <andypaicu@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarKamila Hasanbega <hkamila@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#721442}
parent 827b6468
...@@ -2682,6 +2682,7 @@ generate_jni("chrome_jni_headers") { ...@@ -2682,6 +2682,7 @@ generate_jni("chrome_jni_headers") {
"java/src/org/chromium/chrome/browser/payments/SslValidityChecker.java", "java/src/org/chromium/chrome/browser/payments/SslValidityChecker.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionDialogController.java", "java/src/org/chromium/chrome/browser/permissions/PermissionDialogController.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionDialogDelegate.java", "java/src/org/chromium/chrome/browser/permissions/PermissionDialogDelegate.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionSettingsBridge.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionUmaUtil.java", "java/src/org/chromium/chrome/browser/permissions/PermissionUmaUtil.java",
"java/src/org/chromium/chrome/browser/photo_picker/DecoderService.java", "java/src/org/chromium/chrome/browser/photo_picker/DecoderService.java",
"java/src/org/chromium/chrome/browser/policy/PolicyAuditor.java", "java/src/org/chromium/chrome/browser/policy/PolicyAuditor.java",
......
...@@ -1260,6 +1260,7 @@ chrome_java_sources = [ ...@@ -1260,6 +1260,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/permissions/PermissionDialogController.java", "java/src/org/chromium/chrome/browser/permissions/PermissionDialogController.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionDialogDelegate.java", "java/src/org/chromium/chrome/browser/permissions/PermissionDialogDelegate.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionFieldTrial.java", "java/src/org/chromium/chrome/browser/permissions/PermissionFieldTrial.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionSettingsBridge.java",
"java/src/org/chromium/chrome/browser/permissions/PermissionUmaUtil.java", "java/src/org/chromium/chrome/browser/permissions/PermissionUmaUtil.java",
"java/src/org/chromium/chrome/browser/photo_picker/BitmapScalerTask.java", "java/src/org/chromium/chrome/browser/photo_picker/BitmapScalerTask.java",
"java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java", "java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java",
......
...@@ -9,13 +9,16 @@ import android.view.View; ...@@ -9,13 +9,16 @@ import android.view.View;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.download.DownloadInfoBarController; import org.chromium.chrome.browser.download.DownloadInfoBarController;
import org.chromium.chrome.browser.download.DownloadManagerService; import org.chromium.chrome.browser.download.DownloadManagerService;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.PopupState; import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.PopupState;
import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.TrackerParameters; import org.chromium.chrome.browser.infobar.IPHInfoBarSupport.TrackerParameters;
import org.chromium.chrome.browser.permissions.PermissionSettingsBridge;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.ui.widget.textbubble.TextBubble; import org.chromium.chrome.browser.ui.widget.textbubble.TextBubble;
import org.chromium.components.feature_engagement.FeatureConstants;
import org.chromium.components.feature_engagement.Tracker; import org.chromium.components.feature_engagement.Tracker;
/** /**
...@@ -61,6 +64,14 @@ class IPHBubbleDelegateImpl implements IPHInfoBarSupport.IPHBubbleDelegate { ...@@ -61,6 +64,14 @@ class IPHBubbleDelegateImpl implements IPHInfoBarSupport.IPHBubbleDelegate {
DownloadManagerService.getDownloadManagerService() DownloadManagerService.getDownloadManagerService()
.getInfoBarController(Profile.getLastUsedProfile().isOffTheRecord()); .getInfoBarController(Profile.getLastUsedProfile().isOffTheRecord());
return controller != null ? controller.getTrackerParameters() : null; return controller != null ? controller.getTrackerParameters() : null;
case InfoBarIdentifier.GROUPED_PERMISSION_INFOBAR_DELEGATE_ANDROID:
if (PermissionSettingsBridge.shouldShowNotificationsPromo()) {
PermissionSettingsBridge.didShowNotificationsPromo();
return new IPHInfoBarSupport.TrackerParameters(
FeatureConstants.QUIET_NOTIFICATION_PROMPTS_FEATURE,
R.string.notifications_iph, R.string.notifications_iph);
}
return null;
default: default:
return null; return null;
} }
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package org.chromium.chrome.browser.permissions;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.profiles.Profile;
/**
* Utility class that interacts with native to retrieve and set permission-related settings.
*/
public class PermissionSettingsBridge {
public static boolean shouldShowNotificationsPromo() {
return PermissionSettingsBridgeJni.get().shouldShowNotificationsPromo(getProfile());
}
public static void didShowNotificationsPromo() {
PermissionSettingsBridgeJni.get().didShowNotificationsPromo(getProfile());
}
private static Profile getProfile() {
return Profile.getLastUsedProfile().getOriginalProfile();
}
@NativeMethods
public interface Natives {
boolean shouldShowNotificationsPromo(Profile profile);
void didShowNotificationsPromo(Profile profile);
}
}
...@@ -2575,6 +2575,7 @@ jumbo_static_library("browser") { ...@@ -2575,6 +2575,7 @@ jumbo_static_library("browser") {
"android/password_ui_view_android.cc", "android/password_ui_view_android.cc",
"android/password_ui_view_android.h", "android/password_ui_view_android.h",
"android/payments/service_worker_payment_app_bridge.cc", "android/payments/service_worker_payment_app_bridge.cc",
"android/permissions/permission_settings_bridge.cc",
"android/photo_picker_sandbox_bridge.cc", "android/photo_picker_sandbox_bridge.cc",
"android/policy/policy_auditor.cc", "android/policy/policy_auditor.cc",
"android/preferences/about_settings_bridge.cc", "android/preferences/about_settings_bridge.cc",
......
file://chrome/browser/permissions/PERMISSIONS_OWNERS
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/android/scoped_java_ref.h"
#include "chrome/android/chrome_jni_headers/PermissionSettingsBridge_jni.h"
#include "chrome/browser/permissions/adaptive_notification_permission_ui_selector.h"
#include "chrome/browser/profiles/profile_android.h"
using base::android::JavaParamRef;
static jboolean JNI_PermissionSettingsBridge_ShouldShowNotificationsPromo(
JNIEnv* env,
const JavaParamRef<jobject>& jprofile) {
return AdaptiveNotificationPermissionUiSelector::GetForProfile(
ProfileAndroid::FromProfileAndroid(jprofile))
->ShouldShowPromo();
}
static void JNI_PermissionSettingsBridge_DidShowNotificationsPromo(
JNIEnv* env,
const JavaParamRef<jobject>& jprofile) {
AdaptiveNotificationPermissionUiSelector::GetForProfile(
ProfileAndroid::FromProfileAndroid(jprofile))
->PromoWasShown();
}
...@@ -1147,8 +1147,8 @@ Your Google account may have other forms of browsing history like searches and a ...@@ -1147,8 +1147,8 @@ Your Google account may have other forms of browsing history like searches and a
<message name="IDS_WEBSITE_SETTINGS_CATEGORY_NOTIFICATIONS_QUIET_SUMMARY_DISABLED" desc="A summary explaining how quiet notifications work, when the setting is disabled."> <message name="IDS_WEBSITE_SETTINGS_CATEGORY_NOTIFICATIONS_QUIET_SUMMARY_DISABLED" desc="A summary explaining how quiet notifications work, when the setting is disabled.">
Enable to automatically block sites from asking to show you notifications. If a site requests notifications, an infobar will appear at the bottom of the page. Enable to automatically block sites from asking to show you notifications. If a site requests notifications, an infobar will appear at the bottom of the page.
</message> </message>
<message name="IDS_NOTIFICATIONS_IPH" desc="A message that explains to the users that notification permission requests will appear as an infobar from now on."> <message name="IDS_NOTIFICATIONS_IPH" desc="A message that explains to the users that notification permission requests will appear as an infobar from now on because the user repeatedly denied the notification permission in the past.">
Got it. By default new notification requests will appear here. You usually block notifications. To allow, tap Details.
</message> </message>
<message name="IDS_WEBSITE_SETTINGS_CATEGORY_CAMERA_ASK" desc="Summary text explaining that sites need to ask for permission before accessing the camera and that it is the recommended setting."> <message name="IDS_WEBSITE_SETTINGS_CATEGORY_CAMERA_ASK" desc="Summary text explaining that sites need to ask for permission before accessing the camera and that it is the recommended setting.">
Ask first before allowing sites to use your camera (recommended) Ask first before allowing sites to use your camera (recommended)
......
...@@ -36,7 +36,8 @@ import java.lang.annotation.RetentionPolicy; ...@@ -36,7 +36,8 @@ import java.lang.annotation.RetentionPolicy;
FeatureConstants.TAB_GROUPS_TAP_TO_SEE_ANOTHER_TAB_FEATURE, FeatureConstants.TAB_GROUPS_TAP_TO_SEE_ANOTHER_TAB_FEATURE,
FeatureConstants.TAB_GROUPS_YOUR_TABS_ARE_TOGETHER_FEATURE, FeatureConstants.TAB_GROUPS_YOUR_TABS_ARE_TOGETHER_FEATURE,
FeatureConstants.FEED_CARD_MENU_FEATURE, FeatureConstants.IDENTITY_DISC_FEATURE, FeatureConstants.FEED_CARD_MENU_FEATURE, FeatureConstants.IDENTITY_DISC_FEATURE,
FeatureConstants.TAB_GROUPS_DRAG_AND_DROP_FEATURE}) FeatureConstants.TAB_GROUPS_DRAG_AND_DROP_FEATURE,
FeatureConstants.QUIET_NOTIFICATION_PROMPTS_FEATURE})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface FeatureConstants { public @interface FeatureConstants {
String DOWNLOAD_PAGE_FEATURE = "IPH_DownloadPage"; String DOWNLOAD_PAGE_FEATURE = "IPH_DownloadPage";
...@@ -126,4 +127,10 @@ public @interface FeatureConstants { ...@@ -126,4 +127,10 @@ public @interface FeatureConstants {
* services" preferences. * services" preferences.
*/ */
String IDENTITY_DISC_FEATURE = "IPH_IdentityDisc"; String IDENTITY_DISC_FEATURE = "IPH_IdentityDisc";
/**
* An IPH feature showing up the first time the user is presented with the quieter version of
* the permission prompt (for notifications).
*/
String QUIET_NOTIFICATION_PROMPTS_FEATURE = "IPH_QuietNotificationPrompts";
} }
...@@ -71,6 +71,8 @@ const base::Feature kIPHDownloadInfoBarDownloadContinuingFeature{ ...@@ -71,6 +71,8 @@ const base::Feature kIPHDownloadInfoBarDownloadContinuingFeature{
"IPH_DownloadInfoBarDownloadContinuing", base::FEATURE_DISABLED_BY_DEFAULT}; "IPH_DownloadInfoBarDownloadContinuing", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHDownloadInfoBarDownloadsAreFasterFeature{ const base::Feature kIPHDownloadInfoBarDownloadsAreFasterFeature{
"IPH_DownloadInfoBarDownloadsAreFaster", base::FEATURE_DISABLED_BY_DEFAULT}; "IPH_DownloadInfoBarDownloadsAreFaster", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHQuietNotificationPromptsFeature{
"IPH_QuietNotificationPrompts", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHFeedCardMenuFeature{"IPH_FeedCardMenu", const base::Feature kIPHFeedCardMenuFeature{"IPH_FeedCardMenu",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHIdentityDiscFeature{"IPH_IdentityDisc", const base::Feature kIPHIdentityDiscFeature{"IPH_IdentityDisc",
......
...@@ -62,6 +62,7 @@ extern const base::Feature kIPHKeyboardAccessoryPasswordFillingFeature; ...@@ -62,6 +62,7 @@ extern const base::Feature kIPHKeyboardAccessoryPasswordFillingFeature;
extern const base::Feature kIPHKeyboardAccessoryPaymentFillingFeature; extern const base::Feature kIPHKeyboardAccessoryPaymentFillingFeature;
extern const base::Feature kIPHNewTabPageButtonFeature; extern const base::Feature kIPHNewTabPageButtonFeature;
extern const base::Feature kIPHPreviewsOmniboxUIFeature; extern const base::Feature kIPHPreviewsOmniboxUIFeature;
extern const base::Feature kIPHQuietNotificationPromptsFeature;
extern const base::Feature kIPHTabGroupsQuicklyComparePagesFeature; extern const base::Feature kIPHTabGroupsQuicklyComparePagesFeature;
extern const base::Feature kIPHTabGroupsTapToSeeAnotherTabFeature; extern const base::Feature kIPHTabGroupsTapToSeeAnotherTabFeature;
extern const base::Feature kIPHTabGroupsYourTabsAreTogetherFeature; extern const base::Feature kIPHTabGroupsYourTabsAreTogetherFeature;
......
...@@ -41,6 +41,7 @@ const base::Feature* const kAllFeatures[] = { ...@@ -41,6 +41,7 @@ const base::Feature* const kAllFeatures[] = {
&kIPHKeyboardAccessoryPasswordFillingFeature, &kIPHKeyboardAccessoryPasswordFillingFeature,
&kIPHKeyboardAccessoryPaymentFillingFeature, &kIPHKeyboardAccessoryPaymentFillingFeature,
&kIPHPreviewsOmniboxUIFeature, &kIPHPreviewsOmniboxUIFeature,
&kIPHQuietNotificationPromptsFeature,
&kIPHTabGroupsQuicklyComparePagesFeature, &kIPHTabGroupsQuicklyComparePagesFeature,
&kIPHTabGroupsTapToSeeAnotherTabFeature, &kIPHTabGroupsTapToSeeAnotherTabFeature,
&kIPHTabGroupsYourTabsAreTogetherFeature, &kIPHTabGroupsYourTabsAreTogetherFeature,
......
...@@ -85,6 +85,8 @@ DEFINE_VARIATION_PARAM(kIPHKeyboardAccessoryPasswordFillingFeature, ...@@ -85,6 +85,8 @@ DEFINE_VARIATION_PARAM(kIPHKeyboardAccessoryPasswordFillingFeature,
DEFINE_VARIATION_PARAM(kIPHKeyboardAccessoryPaymentFillingFeature, DEFINE_VARIATION_PARAM(kIPHKeyboardAccessoryPaymentFillingFeature,
"IPH_KeyboardAccessoryPaymentFilling"); "IPH_KeyboardAccessoryPaymentFilling");
DEFINE_VARIATION_PARAM(kIPHPreviewsOmniboxUIFeature, "IPH_PreviewsOmniboxUI"); DEFINE_VARIATION_PARAM(kIPHPreviewsOmniboxUIFeature, "IPH_PreviewsOmniboxUI");
DEFINE_VARIATION_PARAM(kIPHQuietNotificationPromptsFeature,
"IPH_QuietNotificationPrompts");
DEFINE_VARIATION_PARAM(kIPHTabGroupsQuicklyComparePagesFeature, DEFINE_VARIATION_PARAM(kIPHTabGroupsQuicklyComparePagesFeature,
"IPH_TabGroupsQuicklyComparePages"); "IPH_TabGroupsQuicklyComparePages");
DEFINE_VARIATION_PARAM(kIPHTabGroupsTapToSeeAnotherTabFeature, DEFINE_VARIATION_PARAM(kIPHTabGroupsTapToSeeAnotherTabFeature,
...@@ -153,6 +155,7 @@ constexpr flags_ui::FeatureEntry::FeatureVariation ...@@ -153,6 +155,7 @@ constexpr flags_ui::FeatureEntry::FeatureVariation
VARIATION_ENTRY(kIPHKeyboardAccessoryPasswordFillingFeature), VARIATION_ENTRY(kIPHKeyboardAccessoryPasswordFillingFeature),
VARIATION_ENTRY(kIPHKeyboardAccessoryPaymentFillingFeature), VARIATION_ENTRY(kIPHKeyboardAccessoryPaymentFillingFeature),
VARIATION_ENTRY(kIPHPreviewsOmniboxUIFeature), VARIATION_ENTRY(kIPHPreviewsOmniboxUIFeature),
VARIATION_ENTRY(kIPHQuietNotificationPromptsFeature),
VARIATION_ENTRY(kIPHTabGroupsQuicklyComparePagesFeature), VARIATION_ENTRY(kIPHTabGroupsQuicklyComparePagesFeature),
VARIATION_ENTRY(kIPHTabGroupsTapToSeeAnotherTabFeature), VARIATION_ENTRY(kIPHTabGroupsTapToSeeAnotherTabFeature),
VARIATION_ENTRY(kIPHTabGroupsYourTabsAreTogetherFeature), VARIATION_ENTRY(kIPHTabGroupsYourTabsAreTogetherFeature),
......
...@@ -395,6 +395,26 @@ ...@@ -395,6 +395,26 @@
] ]
} }
], ],
"AndroidInProductHelpQuietNotificationPrompts": [
{
"platforms": [
"android"
],
"experiments": [
{
"name": "Enabled",
"params": {
"availability": "any",
"event_trigger": "name:tabgroups_dummy;comparator:any;window:1;storage:1",
"event_used": "name:tabgroups_dummy;comparator:any;window:1;storage:1"
},
"enable_features": [
"IPH_QuietNotificationPrompts"
]
}
]
}
],
"AndroidInlineUpdateFlowStudy": [ "AndroidInlineUpdateFlowStudy": [
{ {
"platforms": [ "platforms": [
......
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