Commit 484447e0 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Check UnifiedConsentService and maybe show consent bump

This CL adds JNI bridge for UnifiedConsentService::ShouldShowConsentBump
and shows the consent bump if necessary.

Bug: 869426
Change-Id: I7f1ca38673c330a86effd376f3120dae6029bb61
Reviewed-on: https://chromium-review.googlesource.com/1167846Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581890}
parent 86c31f35
......@@ -589,11 +589,7 @@ public class ChromeTabbedActivity
// launching into VR.
&& !VrModuleProvider.getIntentDelegate().isLaunchingIntoVr(this, getIntent())
&& !isLegacyMultiWindow) {
// Data reduction promo should be temporarily suppressed if the sign in promo is
// shown to avoid nagging users too much.
isShowingPromo = SigninPromoUtil.launchSigninPromoIfNeeded(this)
|| DataReductionPromoScreen.launchDataReductionPromo(
this, mTabModelSelectorImpl.getCurrentModel().isIncognito());
isShowingPromo = maybeShowPromo();
} else {
preferenceManager.writeBoolean(
ChromePreferenceManager.PROMOS_SKIPPED_ON_FIRST_START, true);
......@@ -609,6 +605,14 @@ public class ChromeTabbedActivity
}
}
private boolean maybeShowPromo() {
// Only one promo can be shown in one run to avoid nagging users too much.
if (SigninPromoUtil.launchConsentBumpIfNeeded(this)) return true;
if (SigninPromoUtil.launchSigninPromoIfNeeded(this)) return true;
return DataReductionPromoScreen.launchDataReductionPromo(
this, mTabModelSelectorImpl.getCurrentModel().isIncognito());
}
/**
* Determine whether the incognito profile needs to be destroyed as part of startup. This is
* only needed on L+ when it is possible to swipe away tasks from Android recents without
......
......@@ -9,6 +9,7 @@ import android.text.TextUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.ChromeVersionInfo;
import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
import org.chromium.chrome.browser.preferences.PrefServiceBridge;
......@@ -25,6 +26,21 @@ import java.util.Set;
public class SigninPromoUtil {
private SigninPromoUtil() {}
/**
* Launches the consent bump screen if it needs to be displayed.
* @param activity The parent activity.
* @return Whether the consent bump screen is shown.
*/
public static boolean launchConsentBumpIfNeeded(final Activity activity) {
String accountName = ChromeSigninController.get().getSignedInAccountName();
if (accountName == null || !ChromeFeatureList.isEnabled(ChromeFeatureList.UNIFIED_CONSENT)
|| !UnifiedConsentServiceBridge.shouldShowConsentBump()) {
return false;
}
activity.startActivity(SigninActivity.createIntentForConsentBump(activity, accountName));
return true;
}
/**
* Launches the signin promo if it needs to be displayed.
* @param activity The parent activity.
......
// Copyright 2018 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.signin;
import org.chromium.chrome.browser.profiles.Profile;
/**
* Bridge to UnifiedConsentService.
*/
public class UnifiedConsentServiceBridge {
private UnifiedConsentServiceBridge() {}
/**
* Returns whether the consent bump should be shown as part of the migration to Unified Consent.
*/
public static boolean shouldShowConsentBump() {
return nativeShouldShowConsentBump(Profile.getLastUsedProfile());
}
private static native boolean nativeShouldShowConsentBump(Profile profile);
}
......@@ -1298,6 +1298,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/signin/SigninUtils.java",
"java/src/org/chromium/chrome/browser/signin/SigninView.java",
"java/src/org/chromium/chrome/browser/signin/SyncPromoView.java",
"java/src/org/chromium/chrome/browser/signin/UnifiedConsentServiceBridge.java",
"java/src/org/chromium/chrome/browser/snackbar/BottomContainer.java",
"java/src/org/chromium/chrome/browser/snackbar/DataReductionPromoSnackbarController.java",
"java/src/org/chromium/chrome/browser/snackbar/Snackbar.java",
......
......@@ -2264,6 +2264,7 @@ jumbo_split_static_library("browser") {
"android/signin/signin_manager_android.h",
"android/signin/signin_promo_util_android.cc",
"android/signin/signin_promo_util_android.h",
"android/signin/unified_consent_service_bridge.cc",
"android/subresource_filter/test_subresource_filter_publisher.cc",
"android/tab_android.cc",
"android/tab_android.h",
......@@ -4593,6 +4594,7 @@ if (is_android) {
"../android/java/src/org/chromium/chrome/browser/signin/SigninInvestigator.java",
"../android/java/src/org/chromium/chrome/browser/signin/SigninManager.java",
"../android/java/src/org/chromium/chrome/browser/signin/SigninPromoUtil.java",
"../android/java/src/org/chromium/chrome/browser/signin/UnifiedConsentServiceBridge.java",
"../android/java/src/org/chromium/chrome/browser/snackbar/smartlockautosignin/AutoSigninSnackbarController.java",
"../android/java/src/org/chromium/chrome/browser/ssl/CaptivePortalHelper.java",
"../android/java/src/org/chromium/chrome/browser/ssl/SecurityStateModel.java",
......
// Copyright 2018 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/jni_android.h"
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/unified_consent/unified_consent_service_factory.h"
#include "components/unified_consent/unified_consent_service.h"
#include "jni/UnifiedConsentServiceBridge_jni.h"
using base::android::JavaParamRef;
static jboolean JNI_UnifiedConsentServiceBridge_ShouldShowConsentBump(
JNIEnv* env,
const base::android::JavaParamRef<jclass>& jcaller,
const base::android::JavaParamRef<jobject>& profileAndroid) {
Profile* profile = ProfileAndroid::FromProfileAndroid(profileAndroid);
auto* unifiedConsentService =
UnifiedConsentServiceFactory::GetForProfile(profile);
return unifiedConsentService->ShouldShowConsentBump();
}
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