Commit 7ce8a07c authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Unity][Android] Pin account for consent bump screen

The consent bump screen is shown for the primary signed in account and
the account picker in the consent bump screen should not react to
clicks. This CL adds a fragment argument to pass the account name and
disables the account picker.

Bug: 869426
Change-Id: I1f84705d36b78d7f66eb28a546ab4bf825727e30
Reviewed-on: https://chromium-review.googlesource.com/1165235Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581232}
parent 96e8014a
...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.signin; ...@@ -7,6 +7,7 @@ package org.chromium.chrome.browser.signin;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.IdRes; import android.support.annotation.IdRes;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -18,8 +19,13 @@ import org.chromium.chrome.R; ...@@ -18,8 +19,13 @@ import org.chromium.chrome.R;
* users who are already signed in and have Sync enabled, so there's no need to sign in users. * users who are already signed in and have Sync enabled, so there's no need to sign in users.
*/ */
public class ConsentBumpFragment extends SigninFragmentBase { public class ConsentBumpFragment extends SigninFragmentBase {
public static Bundle createArguments() { /**
return createArgumentsForConsentBumpFlow(); * Creates arguments for instantiating this fragment.
* @param accountName The name of the account to show in the consent bump
* @return The bundle to pass to {@link Fragment#setArguments} or {@link Fragment#instantiate}
*/
public static Bundle createArguments(String accountName) {
return createArgumentsForConsentBumpFlow(accountName);
} }
// Every fragment must have a public default constructor. // Every fragment must have a public default constructor.
......
...@@ -68,10 +68,11 @@ public class SigninActivity extends SynchronousInitializationActivity { ...@@ -68,10 +68,11 @@ public class SigninActivity extends SynchronousInitializationActivity {
/** /**
* Creates an {@link Intent} which can be used to start consent bump flow. * Creates an {@link Intent} which can be used to start consent bump flow.
* @param accountName The name of the signed in account.
*/ */
public static Intent createIntentForConsentBump(Context context) { public static Intent createIntentForConsentBump(Context context, String accountName) {
return createIntentInternal( return createIntentInternal(context, ConsentBumpFragment.class,
context, ConsentBumpFragment.class, ConsentBumpFragment.createArguments()); ConsentBumpFragment.createArguments(accountName));
} }
private static Intent createIntentInternal( private static Intent createIntentInternal(
......
...@@ -157,10 +157,14 @@ public abstract class SigninFragmentBase ...@@ -157,10 +157,14 @@ public abstract class SigninFragmentBase
return result; return result;
} }
/** Creates an argument bundle for the consent bump screen. */ /**
protected static Bundle createArgumentsForConsentBumpFlow() { * Creates an argument bundle for the consent bump screen.
* @param accountName The name of the signed in account.
*/
protected static Bundle createArgumentsForConsentBumpFlow(String accountName) {
Bundle result = new Bundle(); Bundle result = new Bundle();
result.putInt(ARGUMENT_SIGNIN_FLOW_TYPE, SigninFlowType.CONSENT_BUMP); result.putInt(ARGUMENT_SIGNIN_FLOW_TYPE, SigninFlowType.CONSENT_BUMP);
result.putString(ARGUMENT_ACCOUNT_NAME, accountName);
return result; return result;
} }
...@@ -200,6 +204,11 @@ public abstract class SigninFragmentBase ...@@ -200,6 +204,11 @@ public abstract class SigninFragmentBase
return mSigninFlowType == SigninFlowType.FORCED; return mSigninFlowType == SigninFlowType.FORCED;
} }
/** Returns whether this fragment is in Consent bump mode. */
protected boolean isConsentBump() {
return mSigninFlowType == SigninFlowType.CONSENT_BUMP;
}
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
...@@ -363,7 +372,7 @@ public abstract class SigninFragmentBase ...@@ -363,7 +372,7 @@ public abstract class SigninFragmentBase
} }
private void onAccountPickerClicked() { private void onAccountPickerClicked() {
if (isForcedSignin() || !areControlsEnabled()) return; if (isForcedSignin() || isConsentBump() || !areControlsEnabled()) return;
showAccountPicker(); showAccountPicker();
} }
......
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