Commit e0772519 authored by Victor Hugo Vianna Silva's avatar Victor Hugo Vianna Silva Committed by Chromium LUCI CQ

Reland "Fork SyncController.isSyncingUrlsWithKeystorePassphrase() in PSS"

This is a reland of c547b0cd

Original change's description:
> Fork SyncController.isSyncingUrlsWithKeystorePassphrase() in PSS
>
> SyncController will soon disappear, so we start moving this method to
> ProfileSyncService. The SyncController method is still exposed for the
> moment because it's called in downstream code.
>
> There should be no behavior change in the only call site:
> SyncController.get() is null iff ProfileSyncService.get() is null.
>
> Bug: 1156620
> Change-Id: Ida792cb92702f932aad3023d05e048be8aee94e8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2577227
> Reviewed-by: Marc Treib <treib@chromium.org>
> Commit-Queue: Victor Vianna <victorvianna@google.com>
> Cr-Commit-Position: refs/heads/master@{#834745}

Bug: 1156620
Change-Id: I3e15cbd0ca6d51edf340dc4339988332ecfbe190
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580074Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Victor Vianna <victorvianna@google.com>
Cr-Commit-Position: refs/heads/master@{#841514}
parent 86439789
......@@ -135,7 +135,6 @@ import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.share.ShareDelegate;
import org.chromium.chrome.browser.share.ShareDelegateImpl;
import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.chrome.browser.sync.SyncController;
import org.chromium.chrome.browser.tab.AccessibilityVisibilityHandler;
import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabHidingType;
......@@ -897,11 +896,9 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
if (!mStarted) return; // Sync state reporting should work only in started state.
if (mContextReporter != null || getActivityTab() == null) return;
final SyncController syncController = SyncController.get();
final ProfileSyncService syncService = ProfileSyncService.get();
if (syncController != null && syncController.isSyncingUrlsWithKeystorePassphrase()) {
assert syncService != null;
if (syncService != null && syncService.isSyncingUrlsWithKeystorePassphrase()) {
mContextReporter = AppHooks.get().createGsaHelper().getContextReporter(this);
if (mSyncStateChangedListener != null) {
......
......@@ -13,6 +13,7 @@ import org.json.JSONException;
import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.components.signin.base.GoogleServiceAuthError;
import org.chromium.components.sync.KeyRetrievalTriggerForUMA;
import org.chromium.components.sync.ModelType;
......@@ -567,6 +568,20 @@ public class ProfileSyncService {
mNativeProfileSyncServiceAndroid, ProfileSyncService.this, keyRetrievalTrigger);
}
/**
* @return Whether sync is enabled to sync urls or open tabs with a non custom passphrase.
*/
public boolean isSyncingUrlsWithKeystorePassphrase() {
if (ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)) {
return isEngineInitialized() && getActiveDataTypes().contains(ModelType.TYPED_URLS)
&& (getPassphraseType() == PassphraseType.KEYSTORE_PASSPHRASE
|| getPassphraseType() == PassphraseType.TRUSTED_VAULT_PASSPHRASE);
}
return isEngineInitialized() && getPreferredDataTypes().contains(ModelType.TYPED_URLS)
&& (getPassphraseType() == PassphraseType.KEYSTORE_PASSPHRASE
|| getPassphraseType() == PassphraseType.TRUSTED_VAULT_PASSPHRASE);
}
@VisibleForTesting
public long getNativeProfileSyncServiceForTest() {
return ProfileSyncServiceJni.get().getProfileSyncServiceForTest(
......
......@@ -12,12 +12,9 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.Log;
import org.chromium.base.ThreadUtils;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.uid.UniqueIdentificationGenerator;
import org.chromium.chrome.browser.uid.UniqueIdentificationGeneratorFactory;
import org.chromium.components.sync.ModelType;
import org.chromium.components.sync.PassphraseType;
import org.chromium.components.sync.StopSource;
/**
......@@ -165,19 +162,7 @@ public class SyncController
* @return Whether sync is enabled to sync urls or open tabs with a non custom passphrase.
*/
public boolean isSyncingUrlsWithKeystorePassphrase() {
if (ChromeFeatureList.isEnabled(ChromeFeatureList.MOBILE_IDENTITY_CONSISTENCY)) {
return mProfileSyncService.isEngineInitialized()
&& mProfileSyncService.getActiveDataTypes().contains(ModelType.TYPED_URLS)
&& (mProfileSyncService.getPassphraseType()
== PassphraseType.KEYSTORE_PASSPHRASE
|| mProfileSyncService.getPassphraseType()
== PassphraseType.TRUSTED_VAULT_PASSPHRASE);
}
return mProfileSyncService.isEngineInitialized()
&& mProfileSyncService.getPreferredDataTypes().contains(ModelType.TYPED_URLS)
&& (mProfileSyncService.getPassphraseType() == PassphraseType.KEYSTORE_PASSPHRASE
|| mProfileSyncService.getPassphraseType()
== PassphraseType.TRUSTED_VAULT_PASSPHRASE);
return mProfileSyncService.isSyncingUrlsWithKeystorePassphrase();
}
/**
......
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