[gbb-cct] Add alternative privace notice message.
Without param set: http://screen/Bxv6DvABLWdKrKm With param set: http://screen/6NzvFq277eyzmdB Bug: 324042215 Bug: b/324041716 Change-Id: Ic9984665c4e741cdbe2ff6d79c903932a01d84a5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5272405 Reviewed-by: Jinsuk Kim <jinsukkim@chromium.org> Commit-Queue: Edmund Wright <edmundw@google.com> Cr-Commit-Position: refs/heads/main@{#1257252}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
ae73cc40ca
commit
6756c50f6d
chrome/browser/ui/android
@ -55,7 +55,6 @@ import org.chromium.components.browser_ui.bottomsheet.EmptyBottomSheetObserver;
|
||||
import org.chromium.components.browser_ui.bottomsheet.ExpandedSheetHelper;
|
||||
import org.chromium.components.browser_ui.bottomsheet.ManagedBottomSheetController;
|
||||
import org.chromium.components.browser_ui.widget.gesture.BackPressHandler;
|
||||
import org.chromium.components.embedder_support.util.UrlConstants;
|
||||
import org.chromium.content_public.browser.LoadUrlParams;
|
||||
import org.chromium.content_public.browser.NavigationController;
|
||||
import org.chromium.content_public.browser.NavigationEntry;
|
||||
@ -254,7 +253,7 @@ public class PageInsightsMediator extends EmptyTabObserver implements BottomShee
|
||||
mContext,
|
||||
intentParams,
|
||||
layoutView,
|
||||
view -> loadMyActivityUrl(tabObservable),
|
||||
this::loadUrl,
|
||||
this::handleBackPress,
|
||||
mWillHandleBackPressSupplier,
|
||||
mOnBottomSheetTouchHandler);
|
||||
@ -648,10 +647,10 @@ public class PageInsightsMediator extends EmptyTabObserver implements BottomShee
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMyActivityUrl(Supplier<Tab> currTabObserver) {
|
||||
Tab currTab = currTabObserver.get();
|
||||
if (currTab != null) {
|
||||
currTab.loadUrl(new LoadUrlParams(UrlConstants.MY_ACTIVITY_HOME_URL));
|
||||
private void loadUrl(String url) {
|
||||
Tab tab = mTabObservable.get();
|
||||
if (tab != null) {
|
||||
tab.loadUrl(new LoadUrlParams(url));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import org.chromium.chrome.browser.page_insights.proto.IntentParams.PageInsights
|
||||
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
|
||||
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
|
||||
import org.chromium.components.browser_ui.bottomsheet.BottomSheetContent;
|
||||
import org.chromium.components.embedder_support.util.UrlConstants;
|
||||
import org.chromium.ui.text.NoUnderlineClickableSpan;
|
||||
import org.chromium.ui.text.SpanApplier;
|
||||
|
||||
@ -46,6 +47,10 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
static final String PAGE_INSIGHTS_PEEK_WITH_PRIVACY_HEIGHT_RATIO_PARAM =
|
||||
"page_insights_peek_with_privacy_height_ratio";
|
||||
|
||||
@VisibleForTesting
|
||||
static final String PAGE_INSIGHTS_ALT_PRIVACY_NOTICE_URL_PARAM =
|
||||
"page_insights_alt_privacy_notice_url";
|
||||
|
||||
interface OnBottomSheetTouchHandler {
|
||||
/** Returns true if the tap has been handled. */
|
||||
boolean handleTap();
|
||||
@ -77,6 +82,7 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
private final float mFullHeightRatio;
|
||||
private final float mPeekHeightRatio;
|
||||
private final float mPeekWithPrivacyHeightRatio;
|
||||
private final String mAltPrivacyNoticeUrl;
|
||||
|
||||
private Context mContext;
|
||||
private View mLayoutView;
|
||||
@ -84,7 +90,7 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
private ViewGroup mSheetContentView;
|
||||
private boolean mShouldPrivacyNoticeBeShown;
|
||||
private int mFullScreenHeight;
|
||||
private Callback<View> mOnPrivacyNoticeLinkClickCallback;
|
||||
private Callback<String> mLoadUrlCallback;
|
||||
private boolean mShouldHavePeekState;
|
||||
private boolean mSwipeToDismissEnabled;
|
||||
@Nullable private RecyclerView mCurrentRecyclerView;
|
||||
@ -95,7 +101,7 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
* @param context An Android context.
|
||||
* @param intentParams params specified in the custom tabs intent
|
||||
* @param layoutView the top-level view for the Window
|
||||
* @param onPrivacyNoticeLinkClickCallback callback for use on privacy notice
|
||||
* @param loadUrlCallback callback that loads the given URL
|
||||
* @param onBackPressHandler back press handler
|
||||
* @param willHandleBackPressSupplier supplier of whether we will handle back presses
|
||||
* @param onBottomSheetTouchHandler handler for touches on bottom sheet
|
||||
@ -104,7 +110,7 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
Context context,
|
||||
PageInsightsIntentParams intentParams,
|
||||
View layoutView,
|
||||
Callback<View> onPrivacyNoticeLinkClickCallback,
|
||||
Callback<String> loadUrlCallback,
|
||||
OnBackPressHandler onBackPressHandler,
|
||||
ObservableSupplierImpl<Boolean> willHandleBackPressSupplier,
|
||||
OnBottomSheetTouchHandler onBottomSheetTouchHandler) {
|
||||
@ -130,6 +136,10 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
ChromeFeatureList.CCT_PAGE_INSIGHTS_HUB,
|
||||
PAGE_INSIGHTS_PEEK_WITH_PRIVACY_HEIGHT_RATIO_PARAM,
|
||||
DEFAULT_PEEK_WITH_PRIVACY_HEIGHT_RATIO);
|
||||
mAltPrivacyNoticeUrl =
|
||||
ChromeFeatureList.getFieldTrialParamByFeature(
|
||||
ChromeFeatureList.CCT_PAGE_INSIGHTS_HUB,
|
||||
PAGE_INSIGHTS_ALT_PRIVACY_NOTICE_URL_PARAM);
|
||||
mLayoutView = layoutView;
|
||||
mToolbarView =
|
||||
(ViewGroup)
|
||||
@ -152,7 +162,7 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
mToolbarView.setOnClickListener((view) -> onBottomSheetTouchHandler.handleTap());
|
||||
|
||||
mContext = context;
|
||||
mOnPrivacyNoticeLinkClickCallback = onPrivacyNoticeLinkClickCallback;
|
||||
mLoadUrlCallback = loadUrlCallback;
|
||||
mOnBackPressHandler = onBackPressHandler;
|
||||
mWillHandleBackPressSupplier = willHandleBackPressSupplier;
|
||||
mFullScreenHeight = context.getResources().getDisplayMetrics().heightPixels;
|
||||
@ -483,19 +493,34 @@ public class PageInsightsSheetContent implements BottomSheetContent, View.OnLayo
|
||||
mSheetContentView
|
||||
.findViewById(R.id.page_insights_privacy_notice_close_button)
|
||||
.setOnClickListener((view) -> onPrivacyNoticeClosed());
|
||||
TextView privacyNoticeMessage =
|
||||
TextView privacyNoticeTextView =
|
||||
mSheetContentView.findViewById(R.id.page_insights_privacy_notice_message);
|
||||
privacyNoticeMessage.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
privacyNoticeMessage.setText(
|
||||
privacyNoticeTextView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
if (mAltPrivacyNoticeUrl.isEmpty()) {
|
||||
preparePrivacyNoticeText(
|
||||
privacyNoticeTextView,
|
||||
R.string.page_insights_hub_privacy_notice,
|
||||
UrlConstants.MY_ACTIVITY_HOME_URL);
|
||||
} else {
|
||||
preparePrivacyNoticeText(
|
||||
privacyNoticeTextView,
|
||||
R.string.page_insights_hub_alt_privacy_notice,
|
||||
mAltPrivacyNoticeUrl);
|
||||
}
|
||||
}
|
||||
|
||||
private void preparePrivacyNoticeText(
|
||||
TextView privacyNoticeTextView, int resourceId, String url) {
|
||||
privacyNoticeTextView.setText(
|
||||
SpanApplier.applySpans(
|
||||
mContext.getString(R.string.page_insights_hub_privacy_notice),
|
||||
mContext.getString(resourceId),
|
||||
new SpanApplier.SpanInfo(
|
||||
"<link>",
|
||||
"</link>",
|
||||
new NoUnderlineClickableSpan(
|
||||
mContext,
|
||||
R.color.default_bg_color_blue,
|
||||
mOnPrivacyNoticeLinkClickCallback))));
|
||||
view -> mLoadUrlCallback.onResult(url)))));
|
||||
}
|
||||
|
||||
private void updateCurrentRecyclerView(View currentPageView) {
|
||||
|
@ -136,7 +136,7 @@ public class PageInsightsSheetContentTest {
|
||||
sTestRule.getActivity(),
|
||||
intentParams,
|
||||
new View(sTestRule.getActivity()),
|
||||
view -> {},
|
||||
url -> {},
|
||||
() -> {
|
||||
mBackPressHandlerCalled = true;
|
||||
return mBackPressHandlerResult;
|
||||
@ -418,6 +418,44 @@ public class PageInsightsSheetContentTest {
|
||||
- getContentViewById(R.id.page_insights_privacy_notice)
|
||||
.getHeight(),
|
||||
getContentViewById(R.id.page_insights_feed_content).getHeight());
|
||||
assertFalse(
|
||||
((TextView)
|
||||
getContentViewById(
|
||||
R.id.page_insights_privacy_notice_message))
|
||||
.getText()
|
||||
.toString()
|
||||
.contains("Learn how to manage this"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
public void privacyNoticeShownForFirstTime_altPrivacyNotice_hasCorrectText() {
|
||||
TestValues testValues = new TestValues();
|
||||
testValues.addFeatureFlagOverride(ChromeFeatureList.CCT_PAGE_INSIGHTS_HUB, true);
|
||||
testValues.addFieldTrialParamOverride(
|
||||
ChromeFeatureList.CCT_PAGE_INSIGHTS_HUB,
|
||||
PageInsightsSheetContent.PAGE_INSIGHTS_ALT_PRIVACY_NOTICE_URL_PARAM,
|
||||
"https//help.google.com/1234");
|
||||
createSheetContent(testValues);
|
||||
TestThreadUtils.runOnUiThreadBlocking(
|
||||
() -> {
|
||||
View testView = new View(sTestRule.getActivity());
|
||||
setPrivacyNoticePreferences(
|
||||
false, System.currentTimeMillis() - MILLIS_IN_ONE_DAY, 0);
|
||||
mSheetContent.initContent(
|
||||
testView,
|
||||
/* isPrivacyNoticeRequired= */ true,
|
||||
/* shouldHavePeekState= */ true);
|
||||
mSheetContent.showFeedPage();
|
||||
|
||||
assertTrue(
|
||||
((TextView)
|
||||
getContentViewById(
|
||||
R.id.page_insights_privacy_notice_message))
|
||||
.getText()
|
||||
.toString()
|
||||
.contains("Learn how to manage this"));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -4413,6 +4413,9 @@ To change this setting, <ph name="BEGIN_LINK"><resetlink></ph>reset sync<p
|
||||
<message name="IDS_PAGE_INSIGHTS_HUB_PRIVACY_NOTICE" desc="Text that displays privacy notice for page insights hub">
|
||||
Your activity in Page Insights is saved in your <ph name="BEGIN_LINK"><link></ph>Google Account<ph name="END_LINK"></link></ph>.
|
||||
</message>
|
||||
<message name="IDS_PAGE_INSIGHTS_HUB_ALT_PRIVACY_NOTICE" desc="Text that displays privacy notice for page insights hub">
|
||||
Your activity in Page Insights is saved in your Google Account. <ph name="BEGIN_LINK"><link></ph>Learn how to manage this<ph name="END_LINK"></link></ph>
|
||||
</message>
|
||||
<message name="IDS_PAGE_INSIGHTS_HUB_MY_ACTIVITY_LOGO" desc="Logo of privacy notice for page insights hub">
|
||||
Logo of privacy notice for page insights hub which redirects to my activity page.
|
||||
</message>
|
||||
|
1
chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_PAGE_INSIGHTS_HUB_ALT_PRIVACY_NOTICE.png.sha1
Normal file
1
chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_PAGE_INSIGHTS_HUB_ALT_PRIVACY_NOTICE.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
bcb3b34b5796f5da792a609c206dde5012ee3aea
|
Reference in New Issue
Block a user