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

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/+/2577227Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Victor Vianna <victorvianna@google.com>
Cr-Commit-Position: refs/heads/master@{#834745}
parent ea4fb26e
...@@ -134,7 +134,6 @@ import org.chromium.chrome.browser.settings.SettingsLauncherImpl; ...@@ -134,7 +134,6 @@ import org.chromium.chrome.browser.settings.SettingsLauncherImpl;
import org.chromium.chrome.browser.share.ShareDelegate; import org.chromium.chrome.browser.share.ShareDelegate;
import org.chromium.chrome.browser.share.ShareDelegateImpl; import org.chromium.chrome.browser.share.ShareDelegateImpl;
import org.chromium.chrome.browser.sync.ProfileSyncService; 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.AccessibilityVisibilityHandler;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabHidingType; import org.chromium.chrome.browser.tab.TabHidingType;
...@@ -894,11 +893,9 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent> ...@@ -894,11 +893,9 @@ public abstract class ChromeActivity<C extends ChromeActivityComponent>
if (!mStarted) return; // Sync state reporting should work only in started state. if (!mStarted) return; // Sync state reporting should work only in started state.
if (mContextReporter != null || getActivityTab() == null) return; if (mContextReporter != null || getActivityTab() == null) return;
final SyncController syncController = SyncController.get();
final ProfileSyncService syncService = ProfileSyncService.get(); final ProfileSyncService syncService = ProfileSyncService.get();
if (syncController != null && syncController.isSyncingUrlsWithKeystorePassphrase()) { if (syncService != null && syncService.isSyncingUrlsWithKeystorePassphrase()) {
assert syncService != null;
mContextReporter = AppHooks.get().createGsaHelper().getContextReporter(this); mContextReporter = AppHooks.get().createGsaHelper().getContextReporter(this);
if (mSyncStateChangedListener != null) { if (mSyncStateChangedListener != null) {
......
...@@ -573,6 +573,15 @@ public class ProfileSyncService { ...@@ -573,6 +573,15 @@ public class ProfileSyncService {
mNativeProfileSyncServiceAndroid, ProfileSyncService.this, keyRetrievalTrigger); mNativeProfileSyncServiceAndroid, ProfileSyncService.this, keyRetrievalTrigger);
} }
/**
* @return Whether sync is enabled to sync urls or open tabs with a non custom passphrase.
*/
public boolean isSyncingUrlsWithKeystorePassphrase() {
return isEngineInitialized() && getPreferredDataTypes().contains(ModelType.TYPED_URLS)
&& (getPassphraseType() == PassphraseType.KEYSTORE_PASSPHRASE
|| getPassphraseType() == PassphraseType.TRUSTED_VAULT_PASSPHRASE);
}
@VisibleForTesting @VisibleForTesting
public long getNativeProfileSyncServiceForTest() { public long getNativeProfileSyncServiceForTest() {
return ProfileSyncServiceJni.get().getProfileSyncServiceForTest( return ProfileSyncServiceJni.get().getProfileSyncServiceForTest(
......
...@@ -15,8 +15,6 @@ import org.chromium.base.metrics.RecordHistogram; ...@@ -15,8 +15,6 @@ import org.chromium.base.metrics.RecordHistogram;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.uid.UniqueIdentificationGenerator; import org.chromium.chrome.browser.uid.UniqueIdentificationGenerator;
import org.chromium.chrome.browser.uid.UniqueIdentificationGeneratorFactory; 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; import org.chromium.components.sync.StopSource;
/** /**
...@@ -164,11 +162,7 @@ public class SyncController ...@@ -164,11 +162,7 @@ public class SyncController
* @return Whether sync is enabled to sync urls or open tabs with a non custom passphrase. * @return Whether sync is enabled to sync urls or open tabs with a non custom passphrase.
*/ */
public boolean isSyncingUrlsWithKeystorePassphrase() { public boolean isSyncingUrlsWithKeystorePassphrase() {
return mProfileSyncService.isEngineInitialized() return mProfileSyncService.isSyncingUrlsWithKeystorePassphrase();
&& mProfileSyncService.getPreferredDataTypes().contains(ModelType.TYPED_URLS)
&& (mProfileSyncService.getPassphraseType() == PassphraseType.KEYSTORE_PASSPHRASE
|| mProfileSyncService.getPassphraseType()
== PassphraseType.TRUSTED_VAULT_PASSPHRASE);
} }
/** /**
......
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