Chromium Code Reviews| 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..454fa693baf5e52989a729f1426f77d19c674c35 |
| --- /dev/null |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/signin/AccountSigninActivity.java |
| @@ -0,0 +1,110 @@ |
| +// 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.base.metrics.RecordUserAction; |
| +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.ImportSyncType; |
| +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) { |
|
newt (away)
2016/02/25 06:25:53
We need to make sure the native library is loaded
PEConn
2016/02/25 14:19:51
Done.
|
| + 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() { |
| + RecordUserAction.record("Signin_Signin_FromSettings"); |
| + SigninManager.get(this).signIn(mAccountName, null, this); |
|
newt (away)
2016/02/25 06:25:53
We're using "non-interactive" sign-in here, which
PEConn
2016/02/25 14:19:51
I changed all of these back.
|
| + } |
| + |
| + @Override |
| + public void onSettingsClicked() { |
| + RecordUserAction.record("Signin_Signin_FromSettings"); |
| + 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, |
| + ImportSyncType.PREVIOUS_DATA_FOUND, getFragmentManager(), callback); |
| + } |
| +} |