| Index: chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2b286cc13624f88cdfb1dacf0c2161f3bb568124
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java
|
| @@ -0,0 +1,106 @@
|
| +// Copyright 2016 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.chrome.browser.signin;
|
| +
|
| +import android.content.Intent;
|
| +import android.os.Bundle;
|
| +import android.support.v7.app.AppCompatActivity;
|
| +import android.view.LayoutInflater;
|
| +
|
| +import org.chromium.chrome.R;
|
| +import org.chromium.chrome.browser.firstrun.ProfileDataCache;
|
| +import org.chromium.chrome.browser.preferences.Preferences;
|
| +import org.chromium.chrome.browser.preferences.PreferencesLauncher;
|
| +import org.chromium.chrome.browser.profiles.Profile;
|
| +import org.chromium.chrome.browser.sync.ui.ConfirmImportSyncDataFragment;
|
| +import org.chromium.chrome.browser.sync.ui.ConfirmImportSyncDataFragment.Listener;
|
| +import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment;
|
| +
|
| +/**
|
| + * An Activity displayed from the MainPreferences to allow the user to pick an account to
|
| + * sign in to.
|
| + */
|
| +public class AccountSigninActivity extends AppCompatActivity
|
| + implements AccountSigninView.Listener, SigninManager.SignInCallback{
|
| + private static final String TAG = "AccountSigninFragment";
|
| +
|
| + private static final String CONFIRM_IMPORT_SYNC_DATA_DIALOG_TAG =
|
| + "signin_import_data_tag";
|
| +
|
| + private AccountSigninView mView;
|
| + private String mAccountName;
|
| + private boolean mShowSyncSettings = false;
|
| +
|
| + @Override
|
| + protected void onCreate(Bundle savedInstanceState) {
|
| + super.onCreate(savedInstanceState);
|
| +
|
| + mView = (AccountSigninView) LayoutInflater.from(this).inflate(
|
| + R.layout.account_signin_view, null);
|
| + mView.init(new ProfileDataCache(this, Profile.getLastUsedProfile()));
|
| + mView.setListener(this);
|
| +
|
| + setContentView(mView);
|
| + }
|
| +
|
| + @Override
|
| + public void onAccountSelectionCanceled() {
|
| + finish();
|
| + }
|
| +
|
| + @Override
|
| + public void onNewAccount() {
|
| + AccountAdder.getInstance().addAccount(this, AccountAdder.ADD_ACCOUNT_RESULT);
|
| + }
|
| +
|
| + @Override
|
| + public void onAccountSelected(String accountName) {
|
| + mAccountName = accountName;
|
| +
|
| + }
|
| +
|
| + @Override
|
| + public void onDoneClicked() {
|
| + SigninManager.get(this).signIn(mAccountName, null, this);
|
| + }
|
| +
|
| + @Override
|
| + public void onSettingsClicked() {
|
| + mShowSyncSettings = true;
|
| + SigninManager.get(this).signIn(mAccountName, null, this);
|
| + }
|
| +
|
| + @Override
|
| + public void onFailedToSetForcedAccount(String forcedAccountName) {
|
| + assert false : "No forced accounts in account switching preferences.";
|
| +
|
| + }
|
| +
|
| + @Override
|
| + public void onSignInComplete() {
|
| + if (mShowSyncSettings) {
|
| + Intent intent = PreferencesLauncher.createIntentForSettingsPage(this,
|
| + SyncCustomizationFragment.class.getName());
|
| + Bundle args = new Bundle();
|
| + args.putString(SyncCustomizationFragment.ARGUMENT_ACCOUNT, mAccountName);
|
| + intent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
|
| + startActivity(intent);
|
| + }
|
| +
|
| + finish();
|
| + }
|
| +
|
| + @Override
|
| + public void onSignInAborted() {
|
| + assert false : "Signin cannot be aborted when forced.";
|
| + }
|
| +
|
| + @Override
|
| + public void onPreviousAccountFound(
|
| + String oldAccountName, String newAccountName, Listener callback) {
|
| + ConfirmImportSyncDataFragment.showNewInstance(
|
| + oldAccountName, newAccountName, getFragmentManager(), callback);
|
| + }
|
| +}
|
|
|