| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.signin; | 5 package org.chromium.chrome.browser.signin; |
| 6 | 6 |
| 7 import android.accounts.Account; | 7 import android.accounts.Account; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.DialogFragment; | 9 import android.app.DialogFragment; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 * Will be set during the sign in process, and nulled out when there is not a
pending sign in. | 70 * Will be set during the sign in process, and nulled out when there is not a
pending sign in. |
| 71 * Needs to be null checked after ever async entry point because it can be nu
lled out at any time | 71 * Needs to be null checked after ever async entry point because it can be nu
lled out at any time |
| 72 * by system accounts changing. | 72 * by system accounts changing. |
| 73 */ | 73 */ |
| 74 private SignInState mSignInState; | 74 private SignInState mSignInState; |
| 75 | 75 |
| 76 private Runnable mSignOutCallback; | 76 private Runnable mSignOutCallback; |
| 77 | 77 |
| 78 private boolean mSigninAllowedByPolicy; | 78 private boolean mSigninAllowedByPolicy; |
| 79 | 79 |
| 80 private boolean mSignOutInProgress; |
| 81 |
| 80 /** | 82 /** |
| 81 * A SignInStateObserver is notified when the user signs in to or out of Chr
ome. | 83 * A SignInStateObserver is notified when the user signs in to or out of Chr
ome. |
| 82 */ | 84 */ |
| 83 public interface SignInStateObserver { | 85 public interface SignInStateObserver { |
| 84 /** | 86 /** |
| 85 * Invoked when the user has signed in to Chrome. | 87 * Invoked when the user has signed in to Chrome. |
| 86 */ | 88 */ |
| 87 void onSignedIn(); | 89 void onSignedIn(); |
| 88 | 90 |
| 89 /** | 91 /** |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 /** | 511 /** |
| 510 * Signs out of Chrome. | 512 * Signs out of Chrome. |
| 511 * <p/> | 513 * <p/> |
| 512 * This method clears the signed-in username, stops sync and sends out a | 514 * This method clears the signed-in username, stops sync and sends out a |
| 513 * sign-out notification on the native side. | 515 * sign-out notification on the native side. |
| 514 * | 516 * |
| 515 * @param callback Will be invoked after signout completes, if not null. | 517 * @param callback Will be invoked after signout completes, if not null. |
| 516 * @param wipeDataHooks Hooks to call during data wiping in case the account
is managed. | 518 * @param wipeDataHooks Hooks to call during data wiping in case the account
is managed. |
| 517 */ | 519 */ |
| 518 public void signOut(Runnable callback, WipeDataHooks wipeDataHooks) { | 520 public void signOut(Runnable callback, WipeDataHooks wipeDataHooks) { |
| 521 mSignOutInProgress = true; |
| 519 mSignOutCallback = callback; | 522 mSignOutCallback = callback; |
| 520 | 523 |
| 521 boolean wipeData = getManagementDomain() != null; | 524 boolean wipeData = getManagementDomain() != null; |
| 522 Log.d(TAG, "Signing out, wipe data? " + wipeData); | 525 Log.d(TAG, "Signing out, wipe data? " + wipeData); |
| 523 | 526 |
| 524 // Native signout must happen before resetting the account so data is de
leted correctly. | 527 // Native signout must happen before resetting the account so data is de
leted correctly. |
| 525 // http://crbug.com/589028 | 528 // http://crbug.com/589028 |
| 526 nativeSignOut(mNativeSigninManagerAndroid); | 529 nativeSignOut(mNativeSigninManagerAndroid); |
| 527 ChromeSigninController.get(mContext).setSignedInAccountName(null); | 530 ChromeSigninController.get(mContext).setSignedInAccountName(null); |
| 528 | 531 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 // This will call back to onProfileDataWiped(). | 583 // This will call back to onProfileDataWiped(). |
| 581 nativeWipeProfileData(mNativeSigninManagerAndroid, hooks); | 584 nativeWipeProfileData(mNativeSigninManagerAndroid, hooks); |
| 582 } | 585 } |
| 583 | 586 |
| 584 @CalledByNative | 587 @CalledByNative |
| 585 private void onProfileDataWiped(WipeDataHooks hooks) { | 588 private void onProfileDataWiped(WipeDataHooks hooks) { |
| 586 if (hooks != null) hooks.postWipeData(); | 589 if (hooks != null) hooks.postWipeData(); |
| 587 onSignOutDone(); | 590 onSignOutDone(); |
| 588 } | 591 } |
| 589 | 592 |
| 593 @CalledByNative |
| 594 private void onNativeSignOut() { |
| 595 if (!mSignOutInProgress) { |
| 596 signOut(); |
| 597 } |
| 598 } |
| 599 |
| 590 private void onSignOutDone() { | 600 private void onSignOutDone() { |
| 601 mSignOutInProgress = false; |
| 591 if (mSignOutCallback != null) { | 602 if (mSignOutCallback != null) { |
| 592 new Handler().post(mSignOutCallback); | 603 new Handler().post(mSignOutCallback); |
| 593 mSignOutCallback = null; | 604 mSignOutCallback = null; |
| 594 } | 605 } |
| 595 | 606 |
| 596 for (SignInStateObserver observer : mSignInStateObservers) { | 607 for (SignInStateObserver observer : mSignInStateObservers) { |
| 597 observer.onSignedOut(); | 608 observer.onSignedOut(); |
| 598 } | 609 } |
| 599 } | 610 } |
| 600 | 611 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 private native void nativeFetchPolicyBeforeSignIn(long nativeSigninManagerAn
droid); | 646 private native void nativeFetchPolicyBeforeSignIn(long nativeSigninManagerAn
droid); |
| 636 private native void nativeAbortSignIn(long nativeSigninManagerAndroid); | 647 private native void nativeAbortSignIn(long nativeSigninManagerAndroid); |
| 637 private native void nativeOnSignInCompleted(long nativeSigninManagerAndroid,
String username); | 648 private native void nativeOnSignInCompleted(long nativeSigninManagerAndroid,
String username); |
| 638 private native void nativeSignOut(long nativeSigninManagerAndroid); | 649 private native void nativeSignOut(long nativeSigninManagerAndroid); |
| 639 private native String nativeGetManagementDomain(long nativeSigninManagerAndr
oid); | 650 private native String nativeGetManagementDomain(long nativeSigninManagerAndr
oid); |
| 640 private native void nativeWipeProfileData(long nativeSigninManagerAndroid, W
ipeDataHooks hooks); | 651 private native void nativeWipeProfileData(long nativeSigninManagerAndroid, W
ipeDataHooks hooks); |
| 641 private native void nativeClearLastSignedInUser(long nativeSigninManagerAndr
oid); | 652 private native void nativeClearLastSignedInUser(long nativeSigninManagerAndr
oid); |
| 642 private native void nativeLogInSignedInUser(long nativeSigninManagerAndroid)
; | 653 private native void nativeLogInSignedInUser(long nativeSigninManagerAndroid)
; |
| 643 private native boolean nativeIsSignedInOnNative(long nativeSigninManagerAndr
oid); | 654 private native boolean nativeIsSignedInOnNative(long nativeSigninManagerAndr
oid); |
| 644 } | 655 } |
| OLD | NEW |