OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.content.Context; | 9 import android.content.Context; |
10 import android.content.Intent; | 10 import android.content.Intent; |
(...skipping 28 matching lines...) Expand all Loading... |
39 import org.chromium.chrome.browser.preferences.PreferencesLauncher; | 39 import org.chromium.chrome.browser.preferences.PreferencesLauncher; |
40 import org.chromium.chrome.browser.profiles.Profile; | 40 import org.chromium.chrome.browser.profiles.Profile; |
41 import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics; | 41 import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics; |
42 import org.chromium.chrome.browser.profiles.ProfileDownloader; | 42 import org.chromium.chrome.browser.profiles.ProfileDownloader; |
43 import org.chromium.chrome.browser.signin.AccountManagementScreenHelper.AccountM
anagementFragmentDelegate; | 43 import org.chromium.chrome.browser.signin.AccountManagementScreenHelper.AccountM
anagementFragmentDelegate; |
44 import org.chromium.chrome.browser.signin.SignOutDialogFragment.SignOutDialogLis
tener; | 44 import org.chromium.chrome.browser.signin.SignOutDialogFragment.SignOutDialogLis
tener; |
45 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; | 45 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; |
46 import org.chromium.chrome.browser.sync.GoogleServiceAuthError; | 46 import org.chromium.chrome.browser.sync.GoogleServiceAuthError; |
47 import org.chromium.chrome.browser.sync.ProfileSyncService; | 47 import org.chromium.chrome.browser.sync.ProfileSyncService; |
48 import org.chromium.chrome.browser.sync.ProfileSyncService.SyncStateChangedListe
ner; | 48 import org.chromium.chrome.browser.sync.ProfileSyncService.SyncStateChangedListe
ner; |
49 import org.chromium.sync.notifier.SyncStatusHelper; | 49 import org.chromium.sync.AndroidSyncSettings; |
50 import org.chromium.sync.signin.AccountManagerHelper; | 50 import org.chromium.sync.signin.AccountManagerHelper; |
51 import org.chromium.sync.signin.ChromeSigninController; | 51 import org.chromium.sync.signin.ChromeSigninController; |
52 | 52 |
53 import java.util.ArrayList; | 53 import java.util.ArrayList; |
54 import java.util.HashMap; | 54 import java.util.HashMap; |
55 | 55 |
56 /** | 56 /** |
57 * The settings screen with information and settings related to the user's accou
nts. | 57 * The settings screen with information and settings related to the user's accou
nts. |
58 * | 58 * |
59 * This shows which accounts the user is signed in with, allows the user to sign
out of Chrome, | 59 * This shows which accounts the user is signed in with, allows the user to sign
out of Chrome, |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 | 381 |
382 if (isPrimaryAccount) { | 382 if (isPrimaryAccount) { |
383 mPrimaryAccountPreference = pref; | 383 mPrimaryAccountPreference = pref; |
384 pref.setOnPreferenceClickListener(new OnPreferenceClickListener(
) { | 384 pref.setOnPreferenceClickListener(new OnPreferenceClickListener(
) { |
385 @Override | 385 @Override |
386 public boolean onPreferenceClick(Preference preference) { | 386 public boolean onPreferenceClick(Preference preference) { |
387 AccountManagementScreenHelper.logEvent( | 387 AccountManagementScreenHelper.logEvent( |
388 ProfileAccountManagementMetrics.CLICK_PRIMARY_AC
COUNT, | 388 ProfileAccountManagementMetrics.CLICK_PRIMARY_AC
COUNT, |
389 mGaiaServiceType); | 389 mGaiaServiceType); |
390 | 390 |
391 if (SyncStatusHelper.get(activity).isMasterSyncAutomatic
allyEnabled()) { | 391 if (AndroidSyncSettings.get(activity).isMasterSyncEnable
d()) { |
392 getDelegate().openSyncCustomizationFragment(activity
, account); | 392 getDelegate().openSyncCustomizationFragment(activity
, account); |
393 } else { | 393 } else { |
394 Intent intent = new Intent(Settings.ACTION_SYNC_SETT
INGS); | 394 Intent intent = new Intent(Settings.ACTION_SYNC_SETT
INGS); |
395 intent.putExtra("account_types", new String[]{"com.g
oogle"}); | 395 intent.putExtra("account_types", new String[]{"com.g
oogle"}); |
396 activity.startActivity(intent); | 396 activity.startActivity(intent); |
397 } | 397 } |
398 | 398 |
399 return true; | 399 return true; |
400 } | 400 } |
401 }); | 401 }); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 | 463 |
464 @Override | 464 @Override |
465 public void onSignedOut() { | 465 public void onSignedOut() { |
466 update(); | 466 update(); |
467 } | 467 } |
468 | 468 |
469 private static String getSyncStatusSummary(Activity activity) { | 469 private static String getSyncStatusSummary(Activity activity) { |
470 ChromeSigninController signinController = ChromeSigninController.get(act
ivity); | 470 ChromeSigninController signinController = ChromeSigninController.get(act
ivity); |
471 if (!signinController.isSignedIn()) return ""; | 471 if (!signinController.isSignedIn()) return ""; |
472 | 472 |
473 SyncStatusHelper syncStatusHelper = SyncStatusHelper.get(activity); | 473 AndroidSyncSettings androidSyncSettings = AndroidSyncSettings.get(activi
ty); |
474 ProfileSyncService profileSyncService = ProfileSyncService.get(activity)
; | 474 ProfileSyncService profileSyncService = ProfileSyncService.get(activity)
; |
475 Resources res = activity.getResources(); | 475 Resources res = activity.getResources(); |
476 | 476 |
477 if (ChildAccountService.getInstance(activity).hasChildAccount()) { | 477 if (ChildAccountService.getInstance(activity).hasChildAccount()) { |
478 return res.getString(R.string.kids_account); | 478 return res.getString(R.string.kids_account); |
479 } | 479 } |
480 | 480 |
481 if (!syncStatusHelper.isMasterSyncAutomaticallyEnabled()) { | 481 if (!androidSyncSettings.isMasterSyncEnabled()) { |
482 return res.getString(R.string.sync_android_master_sync_disabled); | 482 return res.getString(R.string.sync_android_master_sync_disabled); |
483 } | 483 } |
484 | 484 |
485 if (profileSyncService.getAuthError() != GoogleServiceAuthError.State.NO
NE) { | 485 if (profileSyncService.getAuthError() != GoogleServiceAuthError.State.NO
NE) { |
486 return res.getString(profileSyncService.getAuthError().getMessage())
; | 486 return res.getString(profileSyncService.getAuthError().getMessage())
; |
487 } | 487 } |
488 | 488 |
489 if (syncStatusHelper.isSyncEnabled()) { | 489 if (androidSyncSettings.isSyncEnabled()) { |
490 if (!profileSyncService.isSyncInitialized()) { | 490 if (!profileSyncService.isSyncInitialized()) { |
491 return res.getString(R.string.sync_setup_progress); | 491 return res.getString(R.string.sync_setup_progress); |
492 } | 492 } |
493 | 493 |
494 if (profileSyncService.isPassphraseRequiredForDecryption()) { | 494 if (profileSyncService.isPassphraseRequiredForDecryption()) { |
495 switch (profileSyncService.getPassphraseType()) { | 495 switch (profileSyncService.getPassphraseType()) { |
496 case IMPLICIT_PASSPHRASE: | 496 case IMPLICIT_PASSPHRASE: |
497 return res.getString(R.string.sync_need_password); | 497 return res.getString(R.string.sync_need_password); |
498 case FROZEN_IMPLICIT_PASSPHRASE: // Falling through intentio
nally. | 498 case FROZEN_IMPLICIT_PASSPHRASE: // Falling through intentio
nally. |
499 case CUSTOM_PASSPHRASE: | 499 case CUSTOM_PASSPHRASE: |
500 return res.getString(R.string.sync_need_passphrase); | 500 return res.getString(R.string.sync_need_passphrase); |
501 default: | 501 default: |
502 break; | 502 break; |
503 } | 503 } |
504 } | 504 } |
505 } | 505 } |
506 | 506 |
507 return syncStatusHelper.isSyncEnabled(signinController.getSignedInUser()
) | 507 return androidSyncSettings.isSyncEnabled(signinController.getSignedInUse
r()) |
508 ? res.getString(R.string.sync_is_enabled) | 508 ? res.getString(R.string.sync_is_enabled) |
509 : res.getString(R.string.sync_is_disabled); | 509 : res.getString(R.string.sync_is_disabled); |
510 } | 510 } |
511 | 511 |
512 /** | 512 /** |
513 * Open the account management UI. | 513 * Open the account management UI. |
514 * @param applicationContext An application context. | 514 * @param applicationContext An application context. |
515 * @param profile A user profile. | 515 * @param profile A user profile. |
516 * @param serviceType A signin::GAIAServiceType that triggered the dialog. | 516 * @param serviceType A signin::GAIAServiceType that triggered the dialog. |
517 */ | 517 */ |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 * @param context A context | 703 * @param context A context |
704 * @param isAllowed True if the sign out is not disabled due to a child/EDU
account | 704 * @param isAllowed True if the sign out is not disabled due to a child/EDU
account |
705 */ | 705 */ |
706 public static void setSignOutAllowedPreferenceValue(Context context, boolean
isAllowed) { | 706 public static void setSignOutAllowedPreferenceValue(Context context, boolean
isAllowed) { |
707 PreferenceManager.getDefaultSharedPreferences(context) | 707 PreferenceManager.getDefaultSharedPreferences(context) |
708 .edit() | 708 .edit() |
709 .putBoolean(SIGN_OUT_ALLOWED, isAllowed) | 709 .putBoolean(SIGN_OUT_ALLOWED, isAllowed) |
710 .apply(); | 710 .apply(); |
711 } | 711 } |
712 } | 712 } |
OLD | NEW |