Chromium Code Reviews| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 /** | 211 /** |
| 212 * Log the access point when the user see the view of choosing account to sig n in. | 212 * Log the access point when the user see the view of choosing account to sig n in. |
| 213 * @param accessPoint the enum value of AccessPoint defined in signin_metrics .h. | 213 * @param accessPoint the enum value of AccessPoint defined in signin_metrics .h. |
| 214 */ | 214 */ |
| 215 public static void logSigninStartAccessPoint(int accessPoint) { | 215 public static void logSigninStartAccessPoint(int accessPoint) { |
| 216 RecordHistogram.recordEnumeratedHistogram( | 216 RecordHistogram.recordEnumeratedHistogram( |
| 217 "Signin.SigninStartedAccessPoint", accessPoint, SigninAccessPoin t.MAX); | 217 "Signin.SigninStartedAccessPoint", accessPoint, SigninAccessPoin t.MAX); |
| 218 sSignInAccessPoint = accessPoint; | 218 sSignInAccessPoint = accessPoint; |
| 219 } | 219 } |
| 220 | 220 |
| 221 /** | |
| 222 * Checks whether a different account was previously signed in and so the co nfirm data sync | |
| 223 * dialog should be shown. | |
| 224 * @param newAccountName The name of the proposed account. | |
| 225 * @return Whether the previous account was different to the proposed accoun t. | |
| 226 */ | |
| 227 public static boolean shouldShowDataSyncDialog(String newAccountName) { | |
|
newt (away)
2016/02/25 18:01:32
Now that this the SigninInvestigator logic has bee
PEConn
2016/02/25 20:45:12
Done.
| |
| 228 return SigninInvestigator.investigate(newAccountName) | |
| 229 == InvestigatedScenario.DIFFERENT_ACCOUNT; | |
| 230 } | |
| 231 | |
| 221 private void logSigninCompleteAccessPoint() { | 232 private void logSigninCompleteAccessPoint() { |
| 222 RecordHistogram.recordEnumeratedHistogram( | 233 RecordHistogram.recordEnumeratedHistogram( |
| 223 "Signin.SigninCompletedAccessPoint", sSignInAccessPoint, SigninA ccessPoint.MAX); | 234 "Signin.SigninCompletedAccessPoint", sSignInAccessPoint, SigninA ccessPoint.MAX); |
| 224 sSignInAccessPoint = SigninAccessPoint.UNKNOWN; | 235 sSignInAccessPoint = SigninAccessPoint.UNKNOWN; |
| 225 } | 236 } |
| 226 | 237 |
| 227 /** | 238 /** |
| 228 * Notifies the SigninManager that the First Run check has completed. | 239 * Notifies the SigninManager that the First Run check has completed. |
| 229 * | 240 * |
| 230 * The user will be allowed to sign-in once this is signaled. | 241 * The user will be allowed to sign-in once this is signaled. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 285 }); | 296 }); |
| 286 } | 297 } |
| 287 | 298 |
| 288 /** | 299 /** |
| 289 * Continue pending sign in after system accounts have been seeded into Accou ntTrackerService. | 300 * Continue pending sign in after system accounts have been seeded into Accou ntTrackerService. |
| 290 */ | 301 */ |
| 291 @Override | 302 @Override |
| 292 public void onSystemAccountsSeedingComplete() { | 303 public void onSystemAccountsSeedingComplete() { |
| 293 if (mSignInState != null && mSignInState.blockedOnAccountSeeding) { | 304 if (mSignInState != null && mSignInState.blockedOnAccountSeeding) { |
| 294 mSignInState.blockedOnAccountSeeding = false; | 305 mSignInState.blockedOnAccountSeeding = false; |
| 295 progressSignInFlowInvestigateScenario(); | 306 progressSignInFlowCheckPolicy(); |
| 296 } | 307 } |
| 297 } | 308 } |
| 298 | 309 |
| 299 /** | 310 /** |
| 300 * Clear pending sign in when system accounts in AccountTrackerService were r efreshed. | 311 * Clear pending sign in when system accounts in AccountTrackerService were r efreshed. |
| 301 */ | 312 */ |
| 302 @Override | 313 @Override |
| 303 public void onSystemAccountsChanged() { | 314 public void onSystemAccountsChanged() { |
| 304 if (mSignInState != null) { | 315 if (mSignInState != null) { |
| 305 abortSignIn(); | 316 abortSignIn(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 AccountManagerHelper.get(mContext).getAccountFromName(accountName, new C allback<Account>() { | 370 AccountManagerHelper.get(mContext).getAccountFromName(accountName, new C allback<Account>() { |
| 360 @Override | 371 @Override |
| 361 public void onResult(Account account) { | 372 public void onResult(Account account) { |
| 362 signIn(account, activity, callback); | 373 signIn(account, activity, callback); |
| 363 } | 374 } |
| 364 }); | 375 }); |
| 365 } | 376 } |
| 366 | 377 |
| 367 private void progressSignInFlowSeedSystemAccounts() { | 378 private void progressSignInFlowSeedSystemAccounts() { |
| 368 if (AccountTrackerService.get(mContext).checkAndSeedSystemAccounts()) { | 379 if (AccountTrackerService.get(mContext).checkAndSeedSystemAccounts()) { |
| 369 progressSignInFlowInvestigateScenario(); | 380 progressSignInFlowCheckPolicy(); |
| 370 } else if (AccountIdProvider.getInstance().canBeUsed(mContext)) { | 381 } else if (AccountIdProvider.getInstance().canBeUsed(mContext)) { |
| 371 mSignInState.blockedOnAccountSeeding = true; | 382 mSignInState.blockedOnAccountSeeding = true; |
| 372 } else { | 383 } else { |
| 373 Activity activity = mSignInState.activity; | 384 Activity activity = mSignInState.activity; |
| 374 UserRecoverableErrorHandler errorHandler = activity != null | 385 UserRecoverableErrorHandler errorHandler = activity != null |
| 375 ? new UserRecoverableErrorHandler.ModalDialog(activity) | 386 ? new UserRecoverableErrorHandler.ModalDialog(activity) |
| 376 : new UserRecoverableErrorHandler.SystemNotification(); | 387 : new UserRecoverableErrorHandler.SystemNotification(); |
| 377 ExternalAuthUtils.getInstance().canUseGooglePlayServices(mContext, e rrorHandler); | 388 ExternalAuthUtils.getInstance().canUseGooglePlayServices(mContext, e rrorHandler); |
| 378 Log.w(TAG, "Cancelling the sign-in process as Google Play services i s unavailable"); | 389 Log.w(TAG, "Cancelling the sign-in process as Google Play services i s unavailable"); |
| 379 abortSignIn(); | 390 abortSignIn(); |
| 380 } | 391 } |
| 381 } | 392 } |
| 382 | 393 |
| 383 /** | 394 /** |
| 384 * If sign-in is interactive and the user is changing accounts, display a co nfirmation dialog. | 395 * Continues the signin flow by checking if there is a policy that the accou nt is subject to. |
| 385 */ | 396 */ |
| 386 private void progressSignInFlowInvestigateScenario() { | 397 private void progressSignInFlowCheckPolicy() { |
| 387 if (!mSignInState.isInteractive()) { | 398 if (mSignInState == null) { |
| 388 progressSignInFlowCheckPolicy(); | 399 Log.w(TAG, "Ignoring sign in progress request as no pending sign in. "); |
| 389 return; | 400 return; |
| 390 } | 401 } |
| 391 | 402 |
| 392 if (mSignInState.isActivityDestroyed()) { | 403 if (mSignInState.isActivityDestroyed()) { |
| 393 abortSignIn(); | 404 abortSignIn(); |
| 394 return; | 405 return; |
| 395 } | 406 } |
| 396 | 407 |
| 397 // TODO(skym): Warn for high risk upgrade scenario, crbug.com/572754. | |
| 398 if (SigninInvestigator.investigate(mSignInState.account.name) | |
| 399 == InvestigatedScenario.DIFFERENT_ACCOUNT) { | |
| 400 mSignInState.displayedDialog = | |
| 401 ConfirmAccountChangeFragment.newInstance(mSignInState.accoun t.name); | |
| 402 mSignInState.displayedDialog.show( | |
| 403 mSignInState.activity.getFragmentManager(), CONFIRM_ACCOUNT_ CHANGED_DIALOG_TAG); | |
| 404 } else { | |
| 405 // Do not display dialog, just sign-in. | |
| 406 progressSignInFlowCheckPolicy(); | |
| 407 } | |
| 408 } | |
| 409 | |
| 410 /** | |
| 411 * Called from ConfirmAccountChangeFragment if the new account name was conf irmed. | |
| 412 */ | |
| 413 void progressInteractiveSignInFlowAccountConfirmed() { | |
| 414 if (mSignInState == null || mSignInState.displayedDialog == null) { | |
| 415 // Stop if sign-in was cancelled or this is a duplicate click event. | |
| 416 return; | |
| 417 } | |
| 418 mSignInState.displayedDialog = null; | |
| 419 | |
| 420 progressSignInFlowCheckPolicy(); | |
| 421 } | |
| 422 | |
| 423 /** | |
| 424 * Continues the signin flow by checking if there is a policy that the accou nt is subject to. | |
| 425 */ | |
| 426 private void progressSignInFlowCheckPolicy() { | |
| 427 if (mSignInState == null) { | |
| 428 Log.w(TAG, "Ignoring sign in progress request as no pending sign in. "); | |
| 429 return; | |
| 430 } | |
| 431 | |
| 432 if (!nativeShouldLoadPolicyForUser(mSignInState.account.name)) { | 408 if (!nativeShouldLoadPolicyForUser(mSignInState.account.name)) { |
| 433 // Proceed with the sign-in flow without checking for policy if it c an be determined | 409 // Proceed with the sign-in flow without checking for policy if it c an be determined |
| 434 // that this account can't have management enabled based on the user name. | 410 // that this account can't have management enabled based on the user name. |
| 435 finishSignIn(); | 411 finishSignIn(); |
| 436 return; | 412 return; |
| 437 } | 413 } |
| 438 | 414 |
| 439 Log.d(TAG, "Checking if account has policy management enabled"); | 415 Log.d(TAG, "Checking if account has policy management enabled"); |
| 440 // This will call back to onPolicyCheckedBeforeSignIn. | 416 // This will call back to onPolicyCheckedBeforeSignIn. |
| 441 nativeCheckPolicyBeforeSignIn(mNativeSigninManagerAndroid, mSignInState. account.name); | 417 nativeCheckPolicyBeforeSignIn(mNativeSigninManagerAndroid, mSignInState. account.name); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 458 return; | 434 return; |
| 459 } | 435 } |
| 460 | 436 |
| 461 if (!mSignInState.isInteractive()) { | 437 if (!mSignInState.isInteractive()) { |
| 462 // If this is a forced sign-in then don't show the confirmation dial og. | 438 // If this is a forced sign-in then don't show the confirmation dial og. |
| 463 // This will call back to onPolicyFetchedBeforeSignIn. | 439 // This will call back to onPolicyFetchedBeforeSignIn. |
| 464 nativeFetchPolicyBeforeSignIn(mNativeSigninManagerAndroid); | 440 nativeFetchPolicyBeforeSignIn(mNativeSigninManagerAndroid); |
| 465 return; | 441 return; |
| 466 } | 442 } |
| 467 | 443 |
| 444 // TODO(peconn): Move this and other UI interactions into AccountSigninV iew. | |
| 468 Log.d(TAG, "Account has policy management"); | 445 Log.d(TAG, "Account has policy management"); |
| 469 mSignInState.displayedDialog = ConfirmManagedSigninFragment.newInstance( managementDomain); | 446 mSignInState.displayedDialog = ConfirmManagedSigninFragment.newInstance( managementDomain); |
| 470 mSignInState.displayedDialog.show( | 447 mSignInState.displayedDialog.show( |
| 471 mSignInState.activity.getFragmentManager(), CONFIRM_MANAGED_SIGN IN_DIALOG_TAG); | 448 mSignInState.activity.getFragmentManager(), CONFIRM_MANAGED_SIGN IN_DIALOG_TAG); |
| 472 } | 449 } |
| 473 | 450 |
| 474 /** | 451 /** |
| 475 * Called from ConfirmManagedSigninFragment if the managed account was confi rmed. | 452 * Called from ConfirmManagedSigninFragment if the managed account was confi rmed. |
| 476 */ | 453 */ |
| 477 void progressInteractiveSignInFlowManagedConfirmed() { | 454 void progressInteractiveSignInFlowManagedConfirmed() { |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 long nativeSigninManagerAndroid, String username); | 650 long nativeSigninManagerAndroid, String username); |
| 674 private native void nativeFetchPolicyBeforeSignIn(long nativeSigninManagerAn droid); | 651 private native void nativeFetchPolicyBeforeSignIn(long nativeSigninManagerAn droid); |
| 675 private native void nativeOnSignInCompleted(long nativeSigninManagerAndroid, String username); | 652 private native void nativeOnSignInCompleted(long nativeSigninManagerAndroid, String username); |
| 676 private native void nativeSignOut(long nativeSigninManagerAndroid); | 653 private native void nativeSignOut(long nativeSigninManagerAndroid); |
| 677 private native String nativeGetManagementDomain(long nativeSigninManagerAndr oid); | 654 private native String nativeGetManagementDomain(long nativeSigninManagerAndr oid); |
| 678 private native void nativeWipeProfileData(long nativeSigninManagerAndroid, W ipeDataHooks hooks); | 655 private native void nativeWipeProfileData(long nativeSigninManagerAndroid, W ipeDataHooks hooks); |
| 679 private native void nativeClearLastSignedInUser(long nativeSigninManagerAndr oid); | 656 private native void nativeClearLastSignedInUser(long nativeSigninManagerAndr oid); |
| 680 private native void nativeLogInSignedInUser(long nativeSigninManagerAndroid) ; | 657 private native void nativeLogInSignedInUser(long nativeSigninManagerAndroid) ; |
| 681 private native boolean nativeIsSignedInOnNative(long nativeSigninManagerAndr oid); | 658 private native boolean nativeIsSignedInOnNative(long nativeSigninManagerAndr oid); |
| 682 } | 659 } |
| OLD | NEW |