Files
cromite/build/patches/Welcome-screen.patch
T
2023-04-27 15:17:21 +02:00

333 lines
18 KiB
Diff

From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Fri, 29 Apr 2022 00:31:49 +0200
Subject: Welcome screen
Allow toggling automatic updates
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
.../firstrun/ChildAccountStatusSupplier.java | 14 +----
.../browser/firstrun/FirstRunActivity.java | 18 -------
.../firstrun/FirstRunActivityBase.java | 6 +--
.../firstrun/FirstRunFlowSequencer.java | 52 +++++--------------
.../browser/firstrun/FirstRunUtils.java | 16 ++----
.../strings/android_chrome_strings.grd | 24 ++++++++-
6 files changed, 40 insertions(+), 90 deletions(-)
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ChildAccountStatusSupplier.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ChildAccountStatusSupplier.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ChildAccountStatusSupplier.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/ChildAccountStatusSupplier.java
@@ -12,8 +12,6 @@ import org.chromium.base.Callback;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.supplier.OneshotSupplier;
import org.chromium.base.supplier.OneshotSupplierImpl;
-import org.chromium.components.signin.AccountManagerFacade;
-import org.chromium.components.signin.AccountUtils;
/**
* Fetches the child account status to be used by other FRE components.
@@ -40,18 +38,8 @@ public class ChildAccountStatusSupplier implements OneshotSupplier<Boolean> {
* {@link ChildAccountStatusSupplier} will ignore app restrictions and rely solely on
* {@link AccountManagerFacade}.
*/
- public ChildAccountStatusSupplier(AccountManagerFacade accountManagerFacade,
- @Nullable FirstRunAppRestrictionInfo appRestrictionInfo) {
+ public ChildAccountStatusSupplier() {
mChildAccountStatusStartTime = SystemClock.elapsedRealtime();
-
- if (appRestrictionInfo != null) {
- appRestrictionInfo.getHasAppRestriction(this::onAppRestrictionDetected);
- }
-
- accountManagerFacade.getAccounts().then(accounts -> {
- AccountUtils.checkChildAccountStatus(accountManagerFacade, accounts,
- (isChild, account) -> onChildAccountStatusReady(isChild));
- });
}
@Override
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivity.java
@@ -28,9 +28,6 @@ import org.chromium.chrome.browser.fonts.FontPreloader;
import org.chromium.chrome.browser.metrics.UmaUtils;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
-import org.chromium.chrome.browser.signin.SigninCheckerProvider;
-import org.chromium.chrome.browser.signin.SigninFirstRunFragment;
-import org.chromium.chrome.browser.signin.services.FREMobileIdentityConsistencyFieldTrial;
import org.chromium.components.browser_ui.modaldialog.AppModalPresenter;
import org.chromium.components.metrics.LowEntropySource;
import org.chromium.ui.base.LocalizationUtils;
@@ -140,13 +137,11 @@ public class FirstRunActivity extends FirstRunActivityBase implements FirstRunPa
//
// TODO(b/245912657): explicitly sign in supervised users in {@link
// SigninFirstRunMediator#handleContinueWithNative} rather than relying on SigninChecker.
- SigninCheckerProvider.get();
mFirstRunFlowSequencer.updateFirstRunProperties(mFreProperties);
BooleanSupplier showSearchEnginePromo =
() -> mFreProperties.getBoolean(SHOW_SEARCH_ENGINE_PAGE);
- BooleanSupplier showSyncConsent = () -> mFreProperties.getBoolean(SHOW_SYNC_CONSENT_PAGE);
// An optional page to select a default search engine.
if (showSearchEnginePromo.getAsBoolean()) {
@@ -155,11 +150,6 @@ public class FirstRunActivity extends FirstRunActivityBase implements FirstRunPa
mFreProgressStates.add(MobileFreProgress.DEFAULT_SEARCH_ENGINE_SHOWN);
}
- // An optional sync consent page, the visibility of this page will be decided on the fly
- // according to the situation.
- mPages.add(new FirstRunPage<>(SyncConsentFirstRunFragment.class, showSyncConsent));
- mFreProgressStates.add(MobileFreProgress.SYNC_CONSENT_SHOWN);
-
if (mPagerAdapter != null) {
mPagerAdapter.notifyDataSetChanged();
}
@@ -204,10 +194,6 @@ public class FirstRunActivity extends FirstRunActivityBase implements FirstRunPa
@Override
public void triggerLayoutInflation() {
- // Generate trial group as early as possible to guarantee it's available by the time native
- // needs to register the synthetic trial group. See https://crbug.com/1295692 for details.
- FREMobileIdentityConsistencyFieldTrial.createFirstRunVariationsTrial();
-
super.triggerLayoutInflation();
initializeStateFromLaunchData();
@@ -488,10 +474,6 @@ public class FirstRunActivity extends FirstRunActivityBase implements FirstRunPa
public void acceptTermsOfService(boolean allowMetricsAndCrashUploading) {
assert mNativeInitializationPromise.isFulfilled();
- // If default is true then it corresponds to opt-out and false corresponds to opt-in.
- UmaUtils.recordMetricsReportingDefaultOptIn(!DEFAULT_METRICS_AND_CRASH_REPORTING);
- RecordHistogram.recordMediumTimesHistogram("MobileFre.FromLaunch.TosAccepted",
- SystemClock.elapsedRealtime() - mIntentCreationElapsedRealtimeMs);
FirstRunUtils.acceptTermsOfService(allowMetricsAndCrashUploading);
FirstRunStatus.setSkipWelcomePage(true);
flushPersistentData();
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivityBase.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivityBase.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivityBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunActivityBase.java
@@ -31,8 +31,6 @@ import org.chromium.chrome.browser.policy.PolicyServiceFactory;
import org.chromium.chrome.browser.profiles.ProfileManagerUtils;
import org.chromium.components.browser_ui.widget.gesture.BackPressHandler;
import org.chromium.components.policy.PolicyService;
-import org.chromium.components.signin.AccountManagerFacade;
-import org.chromium.components.signin.AccountManagerFacadeProvider;
/** Base class for First Run Experience. */
public abstract class FirstRunActivityBase
@@ -100,9 +98,7 @@ public abstract class FirstRunActivityBase
@Override
@CallSuper
public void triggerLayoutInflation() {
- AccountManagerFacade accountManagerFacade = AccountManagerFacadeProvider.getInstance();
- mChildAccountStatusSupplier =
- new ChildAccountStatusSupplier(accountManagerFacade, mFirstRunAppRestrictionInfo);
+ mChildAccountStatusSupplier = new ChildAccountStatusSupplier();
}
@Override
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunFlowSequencer.java
@@ -25,14 +25,9 @@ import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.locale.LocaleManager;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.SearchEnginePromoType;
-import org.chromium.chrome.browser.signin.services.IdentityServicesProvider;
-import org.chromium.chrome.browser.signin.services.SigninManager;
import org.chromium.components.crash.CrashKeyIndex;
import org.chromium.components.crash.CrashKeys;
import org.chromium.components.embedder_support.util.UrlConstants;
-import org.chromium.components.signin.AccountManagerFacadeProvider;
-import org.chromium.components.signin.identitymanager.ConsentLevel;
-import org.chromium.components.signin.identitymanager.IdentityManager;
import java.util.List;
@@ -57,38 +52,19 @@ public abstract class FirstRunFlowSequencer {
/** Returns true if the sync consent promo page should be shown. */
boolean shouldShowSyncConsentPage(
Activity activity, List<Account> accounts, boolean isChild) {
- if (isChild) {
- // Always show the sync consent page for child account.
- return true;
- }
- final IdentityManager identityManager =
- IdentityServicesProvider.get().getIdentityManager(
- Profile.getLastUsedRegularProfile());
- if (identityManager.hasPrimaryAccount(ConsentLevel.SYNC) || !isSyncAllowed()) {
- // No need to show the sync consent page if users already consented to sync or
- // if sync is not allowed.
return false;
- }
- // Show the sync consent page only to the signed-in users.
- return identityManager.hasPrimaryAccount(ConsentLevel.SIGNIN);
}
/** @return true if the Search Engine promo page should be shown. */
@VisibleForTesting
public boolean shouldShowSearchEnginePage() {
- @SearchEnginePromoType
- int searchPromoType = LocaleManager.getInstance().getSearchEnginePromoShowType();
- return searchPromoType == SearchEnginePromoType.SHOW_NEW
- || searchPromoType == SearchEnginePromoType.SHOW_EXISTING;
+ return false;
}
/** @return true if Sync is allowed for the current user. */
@VisibleForTesting
protected boolean isSyncAllowed() {
- SigninManager signinManager = IdentityServicesProvider.get().getSigninManager(
- Profile.getLastUsedRegularProfile());
- return FirstRunUtils.canAllowSync() && !signinManager.isSigninDisabledByPolicy()
- && signinManager.isSigninSupported();
+ return false;
}
}
@@ -132,12 +108,8 @@ public abstract class FirstRunFlowSequencer {
* method.
*/
void start() {
- AccountManagerFacadeProvider.getInstance().getAccounts().then(accounts -> {
- RecordHistogram.recordCount1MHistogram(
- "Signin.AndroidDeviceAccountsNumberWhenEnteringFRE",
- Math.min(accounts.size(), 2));
- setAccountList(accounts);
- });
+ mIsChild = false;
+ maybeProcessFreEnvironmentPreNative();
}
@VisibleForTesting
@@ -162,14 +134,10 @@ public abstract class FirstRunFlowSequencer {
}
private void maybeProcessFreEnvironmentPreNative() {
- // Wait till both child account status and the list of accounts are available.
- if (mIsChild == null || mGoogleAccounts == null) return;
-
if (mIsFlowKnown) return;
mIsFlowKnown = true;
Bundle freProperties = new Bundle();
- freProperties.putBoolean(SyncConsentFirstRunFragment.IS_CHILD_ACCOUNT, mIsChild);
onFlowIsKnown(freProperties);
}
@@ -180,8 +148,8 @@ public abstract class FirstRunFlowSequencer {
* @param freProperties Resulting FRE properties bundle.
*/
public void updateFirstRunProperties(Bundle freProperties) {
- freProperties.putBoolean(
- FirstRunActivity.SHOW_SYNC_CONSENT_PAGE, shouldShowSyncConsentPage());
+ if (freProperties == null)
+ throw new RuntimeException("attempting to update null FRE properties");
freProperties.putBoolean(
FirstRunActivity.SHOW_SEARCH_ENGINE_PAGE, shouldShowSearchEnginePage());
}
@@ -282,13 +250,17 @@ public abstract class FirstRunFlowSequencer {
if (!(caller instanceof Activity)) {
freIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
- IntentUtils.safeStartActivity(caller, freIntent);
+ if (!IntentUtils.safeStartActivity(caller, freIntent)) {
+ throw new RuntimeException("Cannot start FirstRunExperience activity");
+ }
} else {
// First Run requires that the Intent contains NEW_TASK so that it doesn't sit on top
// of something else.
Intent newIntent = new Intent(fromIntent);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- IntentUtils.safeStartActivity(caller, newIntent);
+ if (!IntentUtils.safeStartActivity(caller, newIntent)) {
+ throw new RuntimeException("Cannot start FirstRunExperience activity");
+ }
}
return true;
}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunUtils.java
--- a/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunUtils.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/firstrun/FirstRunUtils.java
@@ -18,9 +18,6 @@ import org.chromium.chrome.browser.metrics.UmaSessionStats;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.util.ChromeAccessibilityUtil;
-import org.chromium.components.signin.AccountManagerFacade;
-import org.chromium.components.signin.AccountManagerFacadeProvider;
-import org.chromium.components.signin.AccountUtils;
/** Provides first run related utility functions. */
public class FirstRunUtils {
@@ -83,16 +80,12 @@ public class FirstRunUtils {
* @return Whether or not sync is allowed on this device.
*/
static boolean canAllowSync() {
- return (hasGoogleAccountAuthenticator() && hasSyncPermissions()) || hasGoogleAccounts();
+ return false;
}
@VisibleForTesting
static boolean hasGoogleAccountAuthenticator() {
- if (sHasGoogleAccountAuthenticator == null) {
- AccountManagerFacade accountHelper = AccountManagerFacadeProvider.getInstance();
- sHasGoogleAccountAuthenticator = accountHelper.hasGoogleAccountAuthenticator();
- }
- return sHasGoogleAccountAuthenticator;
+ return false;
}
@VisibleForTesting
@@ -102,10 +95,7 @@ public class FirstRunUtils {
@VisibleForTesting
static boolean hasGoogleAccounts() {
- return !AccountUtils
- .getAccountsIfFulfilledOrEmpty(
- AccountManagerFacadeProvider.getInstance().getAccounts())
- .isEmpty();
+ return false;
}
@SuppressLint("InlinedApi")
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -3077,7 +3077,29 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<ph name="APP_NAME">%1$s<ex>Google Maps</ex></ph> will open in Chrome. By continuing, you agree to the <ph name="BEGIN_LINK1">&lt;LINK1&gt;</ph>Google Terms of Service<ph name="END_LINK1">&lt;/LINK1&gt;</ph>, and the <ph name="BEGIN_LINK2">&lt;LINK2&gt;</ph>Google Chrome and ChromeOS Additional Terms of Service<ph name="END_LINK2">&lt;/LINK2&gt;</ph>. The <ph name="BEGIN_LINK3">&lt;LINK3&gt;</ph>Privacy Policy<ph name="END_LINK3">&lt;/LINK3&gt;</ph> also applies.
</message>
<message name="IDS_FRE_ACCEPT_CONTINUE" desc="Text for first page accept and continue button [CHAR_LIMIT=20]">
- Accept &amp; continue
+ Continue
+ </message>
+ <message name="IDS_ADBLOCK_UPDATER_PRIVACY_POLICY_URL" desc="URL for privacy policy for the ad block updater" translateable="false">
+ https://docs.github.com/en/github/site-policy/github-privacy-statement#github-pages
+ </message>
+ <message name="IDS_BROMITE_UPDATER_PRIVACY_POLICY_URL" desc="URL for privacy policy for the Bromite auto updater" translateable="false">
+ https://docs.github.com/en/github/site-policy/github-privacy-statement#github-pages
+ </message>
+ <message name="IDS_BROMITE_FRE_FOOTER_PRIVACY_POLICY" desc="Message explaining the privacy policy of the file hosting service provider for adblock updates and Bromite app automatic updates">
+ <ph name="BEGIN_PRIVACY_LINK1">&lt;PRIVACY_LINK1&gt;</ph>Automatic ad block filters updates<ph name="END_PRIVACY_LINK1">&lt;/PRIVACY_LINK1&gt;</ph> are subject to the <ph name="BEGIN_PRIVACY_LINK2">&lt;PRIVACY_LINK2&gt;</ph>GitHub Privacy statement<ph name="END_PRIVACY_LINK2">&lt;/PRIVACY_LINK2&gt;</ph>; they cannot be disabled.
+ The following checkbox controls instead <ph name="BEGIN_PRIVACY_LINK3">&lt;PRIVACY_LINK3&gt;</ph>automatic app updates<ph name="END_PRIVACY_LINK3">&lt;/PRIVACY_LINK3&gt;</ph> which are also subject to the <ph name="BEGIN_PRIVACY_LINK4">&lt;PRIVACY_LINK4&gt;</ph>GitHub Privacy statement<ph name="END_PRIVACY_LINK4">&lt;/PRIVACY_LINK4&gt;</ph>.
+ </message>
+ <message name="IDS_AUTO_UPDATER_CHECK" desc="Message for the checkbox for automatic Bromite updates">
+ Automatic checks for Bromite app updates
+ </message>
+ <message name="IDS_UPDATER_PRIVACY_POLICY_URL" desc="URL for GitHub privacy statement" translateable="false">
+ https://docs.github.com/en/github/site-policy/github-privacy-statement#github-pages
+ </message>
+ <message name="IDS_ADBLOCK_WIKI_URL" desc="URL for Bromite wiki page about ad blocking" translateable="false">
+ https://github.com/bromite/bromite/wiki/AdBlocking
+ </message>
+ <message name="IDS_AUTO_UPDATES_WIKI_URL" desc="URL for Bromite wiki page about automatic updates" translateable="false">
+ https://github.com/bromite/bromite/wiki/AutomaticUpdates
</message>
<message name="IDS_FRE_WELCOME" desc="Text for greeting the user on Chrome First Run">
Welcome to Chrome
--
2.25.1