Commit bd2f718e authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Signin][Android] Remove switch sync account dialog

Settings entry to switch sync accounts has been removed,
so this CL removes dialogs that are no longer used.

Bug: 1007331
Change-Id: I368b2115404696b41d355997ae297f921347b7af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821612
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Reviewed-by: default avatarAlex Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#700401}
parent 388ea4b6
...@@ -13,19 +13,14 @@ import android.support.v4.app.FragmentTransaction; ...@@ -13,19 +13,14 @@ import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.IntDef;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.preferences.ManagedPreferencesUtils; import org.chromium.chrome.browser.preferences.ManagedPreferencesUtils;
import org.chromium.chrome.browser.widget.RadioButtonWithDescription; import org.chromium.chrome.browser.widget.RadioButtonWithDescription;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
...@@ -53,25 +48,12 @@ public class ConfirmImportSyncDataDialog extends DialogFragment ...@@ -53,25 +48,12 @@ public class ConfirmImportSyncDataDialog extends DialogFragment
void onCancel(); void onCancel();
} }
/**
* The situation ConfirmImportSyncDataDialog is created for - whether the user had previously
* been signed into another account, had signed out then signed into a different one, or
* if they directly switched accounts. This changes the strings displayed.
*/
@IntDef({ImportSyncType.SWITCHING_SYNC_ACCOUNTS, ImportSyncType.PREVIOUS_DATA_FOUND})
@Retention(RetentionPolicy.SOURCE)
public @interface ImportSyncType {
int SWITCHING_SYNC_ACCOUNTS = 0;
int PREVIOUS_DATA_FOUND = 1;
}
@VisibleForTesting @VisibleForTesting
public static final String CONFIRM_IMPORT_SYNC_DATA_DIALOG_TAG = public static final String CONFIRM_IMPORT_SYNC_DATA_DIALOG_TAG =
"sync_account_switch_import_data_tag"; "sync_account_switch_import_data_tag";
private static final String KEY_OLD_ACCOUNT_NAME = "lastAccountName"; private static final String KEY_OLD_ACCOUNT_NAME = "lastAccountName";
private static final String KEY_NEW_ACCOUNT_NAME = "newAccountName"; private static final String KEY_NEW_ACCOUNT_NAME = "newAccountName";
private static final String KEY_IMPORT_SYNC_TYPE = "importSyncType";
private RadioButtonWithDescription mConfirmImportOption; private RadioButtonWithDescription mConfirmImportOption;
private RadioButtonWithDescription mKeepSeparateOption; private RadioButtonWithDescription mKeepSeparateOption;
...@@ -80,12 +62,11 @@ public class ConfirmImportSyncDataDialog extends DialogFragment ...@@ -80,12 +62,11 @@ public class ConfirmImportSyncDataDialog extends DialogFragment
private boolean mListenerCalled; private boolean mListenerCalled;
private static ConfirmImportSyncDataDialog newInstance( private static ConfirmImportSyncDataDialog newInstance(
String oldAccountName, String newAccountName, @ImportSyncType int importSyncType) { String oldAccountName, String newAccountName) {
ConfirmImportSyncDataDialog fragment = new ConfirmImportSyncDataDialog(); ConfirmImportSyncDataDialog fragment = new ConfirmImportSyncDataDialog();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString(KEY_OLD_ACCOUNT_NAME, oldAccountName); args.putString(KEY_OLD_ACCOUNT_NAME, oldAccountName);
args.putString(KEY_NEW_ACCOUNT_NAME, newAccountName); args.putString(KEY_NEW_ACCOUNT_NAME, newAccountName);
args.putInt(KEY_IMPORT_SYNC_TYPE, importSyncType);
fragment.setArguments(args); fragment.setArguments(args);
return fragment; return fragment;
} }
...@@ -96,18 +77,13 @@ public class ConfirmImportSyncDataDialog extends DialogFragment ...@@ -96,18 +77,13 @@ public class ConfirmImportSyncDataDialog extends DialogFragment
* account they were previously signed into, or to keep the data separate. * account they were previously signed into, or to keep the data separate.
* @param oldAccountName The previous sync account name. * @param oldAccountName The previous sync account name.
* @param newAccountName The potential next sync account name. * @param newAccountName The potential next sync account name.
* @param importSyncType The situation the dialog is created in - either when directly changing
* the sync account or signing in after being signed out (this changes
* displayed strings).
* @param fragmentManager FragmentManager to attach the dialog to. * @param fragmentManager FragmentManager to attach the dialog to.
* @param callback Callback to be called if the user completes the dialog (as opposed to * @param callback Callback to be called if the user completes the dialog (as opposed to
* hitting cancel). * hitting cancel).
*/ */
public static void showNewInstance(String oldAccountName, String newAccountName, public static void showNewInstance(String oldAccountName, String newAccountName,
@ImportSyncType int importSyncType, FragmentManager fragmentManager, FragmentManager fragmentManager, Listener callback) {
Listener callback) { ConfirmImportSyncDataDialog confirmSync = newInstance(oldAccountName, newAccountName);
ConfirmImportSyncDataDialog confirmSync =
newInstance(oldAccountName, newAccountName, importSyncType);
confirmSync.setListener(callback); confirmSync.setListener(callback);
FragmentTransaction transaction = fragmentManager.beginTransaction(); FragmentTransaction transaction = fragmentManager.beginTransaction();
...@@ -124,8 +100,6 @@ public class ConfirmImportSyncDataDialog extends DialogFragment ...@@ -124,8 +100,6 @@ public class ConfirmImportSyncDataDialog extends DialogFragment
} }
String oldAccountName = getArguments().getString(KEY_OLD_ACCOUNT_NAME); String oldAccountName = getArguments().getString(KEY_OLD_ACCOUNT_NAME);
String newAccountName = getArguments().getString(KEY_NEW_ACCOUNT_NAME); String newAccountName = getArguments().getString(KEY_NEW_ACCOUNT_NAME);
@ImportSyncType
int importSyncType = getArguments().getInt(KEY_IMPORT_SYNC_TYPE);
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View v = inflater.inflate(R.layout.confirm_import_sync_data, null); View v = inflater.inflate(R.layout.confirm_import_sync_data, null);
...@@ -138,14 +112,8 @@ public class ConfirmImportSyncDataDialog extends DialogFragment ...@@ -138,14 +112,8 @@ public class ConfirmImportSyncDataDialog extends DialogFragment
mConfirmImportOption.setDescriptionText(getActivity().getString( mConfirmImportOption.setDescriptionText(getActivity().getString(
R.string.sync_import_existing_data_subtext, newAccountName)); R.string.sync_import_existing_data_subtext, newAccountName));
if (importSyncType == ImportSyncType.SWITCHING_SYNC_ACCOUNTS) { mKeepSeparateOption.setDescriptionText(getActivity().getString(
mKeepSeparateOption.setDescriptionText(getActivity().getString( R.string.sync_keep_existing_data_separate_subtext_existing_data));
R.string.sync_keep_existing_data_separate_subtext_switching_accounts,
oldAccountName));
} else {
mKeepSeparateOption.setDescriptionText(getActivity().getString(
R.string.sync_keep_existing_data_separate_subtext_existing_data));
}
List<RadioButtonWithDescription> radioGroup = List<RadioButtonWithDescription> radioGroup =
Arrays.asList(mConfirmImportOption, mKeepSeparateOption); Arrays.asList(mConfirmImportOption, mKeepSeparateOption);
...@@ -158,19 +126,7 @@ public class ConfirmImportSyncDataDialog extends DialogFragment ...@@ -158,19 +126,7 @@ public class ConfirmImportSyncDataDialog extends DialogFragment
mConfirmImportOption.setOnClickListener( mConfirmImportOption.setOnClickListener(
view -> ManagedPreferencesUtils.showManagedByAdministratorToast(getActivity())); view -> ManagedPreferencesUtils.showManagedByAdministratorToast(getActivity()));
} else { } else {
if (importSyncType == ImportSyncType.SWITCHING_SYNC_ACCOUNTS) { mConfirmImportOption.setChecked(true);
mKeepSeparateOption.setChecked(true);
} else {
mConfirmImportOption.setChecked(true);
}
}
if (importSyncType == ImportSyncType.SWITCHING_SYNC_ACCOUNTS) {
// Re-order the buttons so that Import Data is last and Don't Import (the default) is
// at the top.
LinearLayout layout = v.findViewById(R.id.sync_import_data_content);
layout.removeView(mConfirmImportOption);
layout.addView(mConfirmImportOption);
} }
return new AlertDialog.Builder(getActivity(), R.style.Theme_Chromium_AlertDialog) return new AlertDialog.Builder(getActivity(), R.style.Theme_Chromium_AlertDialog)
......
...@@ -67,26 +67,6 @@ public class ConfirmManagedSyncDataDialog extends DialogFragment ...@@ -67,26 +67,6 @@ public class ConfirmManagedSyncDataDialog extends DialogFragment
showNewInstance(title, desc, positive, negative, fragmentManager, callback); showNewInstance(title, desc, positive, negative, fragmentManager, callback);
} }
/**
* Create the dialog to show when switching from a managed account.
* @param callback Callback for result.
* @param fragmentManager FragmentManaged to display the dialog.
* @param resources Resources to load the strings.
* @param domain The domain of the managed account.
* @param oldAccount The old account email address.
* @param newAccount The new account email address.
*/
public static void showSwitchFromManagedAccountDialog(Listener callback,
FragmentManager fragmentManager, Resources resources, String domain, String oldAccount,
String newAccount) {
String title = resources.getString(R.string.sign_out_managed_account);
String positive = resources.getString(R.string.accept_and_switch_accounts);
String negative = resources.getString(R.string.cancel);
String desc = resources.getString(R.string.switch_from_managed_account_description,
oldAccount, newAccount, domain);
showNewInstance(title, desc, positive, negative, fragmentManager, callback);
}
private static void showNewInstance(String title, String description, String positiveButton, private static void showNewInstance(String title, String description, String positiveButton,
String negativeButton, FragmentManager fragmentManager, Listener callback) { String negativeButton, FragmentManager fragmentManager, Listener callback) {
ConfirmManagedSyncDataDialog confirmSync = ConfirmManagedSyncDataDialog confirmSync =
......
...@@ -14,7 +14,6 @@ import androidx.annotation.IntDef; ...@@ -14,7 +14,6 @@ import androidx.annotation.IntDef;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
import org.chromium.chrome.browser.signin.ConfirmImportSyncDataDialog.ImportSyncType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -68,10 +67,8 @@ public class ConfirmSyncDataStateMachine ...@@ -68,10 +67,8 @@ public class ConfirmSyncDataStateMachine
private final ConfirmImportSyncDataDialog.Listener mCallback; private final ConfirmImportSyncDataDialog.Listener mCallback;
private final @Nullable String mOldAccountName; private final @Nullable String mOldAccountName;
private final String mNewAccountName; private final String mNewAccountName;
private final boolean mCurrentlyManaged;
private final FragmentManager mFragmentManager; private final FragmentManager mFragmentManager;
private final Context mContext; private final Context mContext;
private final @ImportSyncType int mImportSyncType;
private final ConfirmSyncDataStateMachineDelegate mDelegate; private final ConfirmSyncDataStateMachineDelegate mDelegate;
private final Handler mHandler = new Handler(); private final Handler mHandler = new Handler();
...@@ -81,31 +78,23 @@ public class ConfirmSyncDataStateMachine ...@@ -81,31 +78,23 @@ public class ConfirmSyncDataStateMachine
/** /**
* Create and run state machine, displaying the appropriate dialogs. * Create and run state machine, displaying the appropriate dialogs.
* @param importSyncType SWITCHING_SYNC_ACCOUNTS if there's already a signed in account, * @param oldAccountName the name of the last signed in account or null
* PREVIOUS_DATA_FOUND otherwise
* @param oldAccountName if importSyncType is SWITCHING_SYNC_ACCOUNTS: the name of the signed in
* account; if importSyncType is PREVIOUS_DATA_FOUND: the name of the last signed in
* account or null
* @param newAccountName the name of the account user is signing in with * @param newAccountName the name of the account user is signing in with
* @param callback the listener to receive the result of this state machine * @param callback the listener to receive the result of this state machine
*/ */
public ConfirmSyncDataStateMachine(Context context, FragmentManager fragmentManager, public ConfirmSyncDataStateMachine(Context context, FragmentManager fragmentManager,
@ImportSyncType int importSyncType, @Nullable String oldAccountName, @Nullable String oldAccountName, String newAccountName,
String newAccountName, ConfirmImportSyncDataDialog.Listener callback) { ConfirmImportSyncDataDialog.Listener callback) {
ThreadUtils.assertOnUiThread(); ThreadUtils.assertOnUiThread();
// Includes implicit not-null assertion. // Includes implicit not-null assertion.
assert !newAccountName.equals("") : "New account name must be provided."; assert !newAccountName.equals("") : "New account name must be provided.";
mOldAccountName = oldAccountName; mOldAccountName = oldAccountName;
mNewAccountName = newAccountName; mNewAccountName = newAccountName;
mImportSyncType = importSyncType;
mFragmentManager = fragmentManager; mFragmentManager = fragmentManager;
mContext = context; mContext = context;
mCallback = callback; mCallback = callback;
mCurrentlyManaged =
IdentityServicesProvider.getSigninManager().getManagementDomain() != null;
mDelegate = new ConfirmSyncDataStateMachineDelegate(mFragmentManager); mDelegate = new ConfirmSyncDataStateMachineDelegate(mFragmentManager);
// New account management status isn't needed right now, but fetching it // New account management status isn't needed right now, but fetching it
...@@ -155,22 +144,10 @@ public class ConfirmSyncDataStateMachine ...@@ -155,22 +144,10 @@ public class ConfirmSyncDataStateMachine
// If there is no old account or the user is just logging back into whatever // If there is no old account or the user is just logging back into whatever
// they were previously logged in as, progress past the old account checks. // they were previously logged in as, progress past the old account checks.
progress(); progress();
} else if (mCurrentlyManaged
&& mImportSyncType == ImportSyncType.SWITCHING_SYNC_ACCOUNTS) {
// We only care about the user's previous account being managed if they are
// switching accounts.
mWipeData = true;
// This will call back into onConfirm() on success.
ConfirmManagedSyncDataDialog.showSwitchFromManagedAccountDialog(this,
mFragmentManager, mContext.getResources(),
SigninManager.extractDomainName(mOldAccountName), mOldAccountName,
mNewAccountName);
} else { } else {
// This will call back into onConfirm(boolean wipeData) on success. // This will call back into onConfirm(boolean wipeData) on success.
ConfirmImportSyncDataDialog.showNewInstance(mOldAccountName, mNewAccountName, ConfirmImportSyncDataDialog.showNewInstance(
mImportSyncType, mFragmentManager, this); mOldAccountName, mNewAccountName, mFragmentManager, this);
} }
break; break;
......
...@@ -436,7 +436,6 @@ public abstract class SigninFragmentBase ...@@ -436,7 +436,6 @@ public abstract class SigninFragmentBase
private void runStateMachineAndSignin(boolean settingsClicked) { private void runStateMachineAndSignin(boolean settingsClicked) {
mConfirmSyncDataStateMachine = new ConfirmSyncDataStateMachine(getContext(), mConfirmSyncDataStateMachine = new ConfirmSyncDataStateMachine(getContext(),
getChildFragmentManager(), getChildFragmentManager(),
ConfirmImportSyncDataDialog.ImportSyncType.PREVIOUS_DATA_FOUND,
PrefServiceBridge.getInstance().getSyncLastAccountName(), mSelectedAccountName, PrefServiceBridge.getInstance().getSyncLastAccountName(), mSelectedAccountName,
new ConfirmImportSyncDataDialog.Listener() { new ConfirmImportSyncDataDialog.Listener() {
@Override @Override
......
...@@ -1624,21 +1624,12 @@ Your Google account may have other forms of browsing history like searches and a ...@@ -1624,21 +1624,12 @@ Your Google account may have other forms of browsing history like searches and a
</message> </message>
<!-- Sync strings --> <!-- Sync strings -->
<message name="IDS_SIGN_OUT_MANAGED_ACCOUNT" desc="Title for prompts to sign out of managed accounts">
Sign out of managed account
</message>
<message name="IDS_SIGN_IN_MANAGED_ACCOUNT" desc="Title for prompts to sign in to managed accounts"> <message name="IDS_SIGN_IN_MANAGED_ACCOUNT" desc="Title for prompts to sign in to managed accounts">
Sign in to managed account Sign in to managed account
</message> </message>
<message name="IDS_SIGN_IN_MANAGED_ACCOUNT_DESCRIPTION" desc="Description for signing in to managed accounts"> <message name="IDS_SIGN_IN_MANAGED_ACCOUNT_DESCRIPTION" desc="Description for signing in to managed accounts">
You are signing in with an account managed by <ph name="MANAGED_DOMAIN">%1$s<ex>Google</ex></ph> and giving its administrator control over your Chrome data. Your data will become permanently tied to this account. Signing out of Chrome will delete your data from this device, but it will remain stored in your Google Account. You are signing in with an account managed by <ph name="MANAGED_DOMAIN">%1$s<ex>Google</ex></ph> and giving its administrator control over your Chrome data. Your data will become permanently tied to this account. Signing out of Chrome will delete your data from this device, but it will remain stored in your Google Account.
</message> </message>
<message name="IDS_SWITCH_FROM_MANAGED_ACCOUNT_DESCRIPTION" desc="Description for switching from a managed account">
You are switching sync accounts from <ph name="ACCOUNT_EMAIL_OLD">%1$s<ex>user@example.com</ex></ph> to <ph name="ACCOUNT_EMAIL_NEW">%2$s<ex>user@example.com</ex></ph>. Your existing Chrome data is managed by <ph name="MANAGED_DOMAIN">%3$s<ex>Google</ex></ph>. This will delete your data from this device, but your data will remain in <ph name="ACCOUNT_EMAIL_OLD">%1$s<ex>user@example.com</ex></ph>.
</message>
<message name="IDS_ACCEPT_AND_SWITCH_ACCOUNTS" desc="Button displayed for user to confirm and switch from a managed account">
Accept and switch accounts
</message>
<message name="IDS_SYNC_YOUR_BOOKMARKS" desc="Title for the prompt to signin and enable sync to sync their bookmarks"> <message name="IDS_SYNC_YOUR_BOOKMARKS" desc="Title for the prompt to signin and enable sync to sync their bookmarks">
Sync your bookmarks Sync your bookmarks
</message> </message>
...@@ -1759,9 +1750,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p ...@@ -1759,9 +1750,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
<message name="IDS_SYNC_KEEP_EXISTING_DATA_SEPARATE_SUBTEXT_EXISTING_DATA" desc="Subtext describing what happens if the user elects to keep the existing data separate signing into a new account after have previously being signed into a different account then signed out."> <message name="IDS_SYNC_KEEP_EXISTING_DATA_SEPARATE_SUBTEXT_EXISTING_DATA" desc="Subtext describing what happens if the user elects to keep the existing data separate signing into a new account after have previously being signed into a different account then signed out.">
Delete existing data. Delete existing data.
</message> </message>
<message name="IDS_SYNC_KEEP_EXISTING_DATA_SEPARATE_SUBTEXT_SWITCHING_ACCOUNTS" desc="Subtext describing what happens if the user elects to keep the existing data separate when switching sync accounts.">
Delete existing data. You can retrieve it by switching back to <ph name="FROM_ACCOUNT">%1$s<ex>johndoe@old.com</ex></ph>.
</message>
<!-- Bluetooth Picker UI strings --> <!-- Bluetooth Picker UI strings -->
<message name="IDS_BLUETOOTH_DIALOG_TITLE" desc="The header message shown on top of the dialog that lets the user pick a Bluetooth device for the site to pair with. Shown above a list of Bluetooth devices discovered. "> <message name="IDS_BLUETOOTH_DIALOG_TITLE" desc="The header message shown on top of the dialog that lets the user pick a Bluetooth device for the site to pair with. Shown above a list of Bluetooth devices discovered. ">
......
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