Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(967)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/signin/AccountManagementFragment.java

Issue 2014833002: Show dialogs for syncing to managed accounts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.app.Activity; 9 import android.app.Activity;
10 import android.app.Dialog; 10 import android.app.Dialog;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 import org.chromium.chrome.browser.preferences.Preferences; 44 import org.chromium.chrome.browser.preferences.Preferences;
45 import org.chromium.chrome.browser.preferences.PreferencesLauncher; 45 import org.chromium.chrome.browser.preferences.PreferencesLauncher;
46 import org.chromium.chrome.browser.preferences.SyncPreference; 46 import org.chromium.chrome.browser.preferences.SyncPreference;
47 import org.chromium.chrome.browser.profiles.Profile; 47 import org.chromium.chrome.browser.profiles.Profile;
48 import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics; 48 import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics;
49 import org.chromium.chrome.browser.profiles.ProfileDownloader; 49 import org.chromium.chrome.browser.profiles.ProfileDownloader;
50 import org.chromium.chrome.browser.signin.SignOutDialogFragment.SignOutDialogLis tener; 50 import org.chromium.chrome.browser.signin.SignOutDialogFragment.SignOutDialogLis tener;
51 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver; 51 import org.chromium.chrome.browser.signin.SigninManager.SignInStateObserver;
52 import org.chromium.chrome.browser.sync.ProfileSyncService; 52 import org.chromium.chrome.browser.sync.ProfileSyncService;
53 import org.chromium.chrome.browser.sync.ProfileSyncService.SyncStateChangedListe ner; 53 import org.chromium.chrome.browser.sync.ProfileSyncService.SyncStateChangedListe ner;
54 import org.chromium.chrome.browser.sync.ui.ConfirmManagedSyncDataDialog;
54 import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment; 55 import org.chromium.chrome.browser.sync.ui.SyncCustomizationFragment;
55 import org.chromium.sync.AndroidSyncSettings; 56 import org.chromium.sync.AndroidSyncSettings;
56 import org.chromium.sync.signin.AccountManagerHelper; 57 import org.chromium.sync.signin.AccountManagerHelper;
57 import org.chromium.sync.signin.ChromeSigninController; 58 import org.chromium.sync.signin.ChromeSigninController;
58 59
59 import java.util.ArrayList; 60 import java.util.ArrayList;
60 import java.util.HashMap; 61 import java.util.HashMap;
61 62
62 /** 63 /**
63 * The settings screen with information and settings related to the user's accou nts. 64 * The settings screen with information and settings related to the user's accou nts.
64 * 65 *
65 * This shows which accounts the user is signed in with, allows the user to sign out of Chrome, 66 * This shows which accounts the user is signed in with, allows the user to sign out of Chrome,
66 * links to sync settings, has links to add accounts and go incognito, and shows parental settings 67 * links to sync settings, has links to add accounts and go incognito, and shows parental settings
67 * if a child account is in use. 68 * if a child account is in use.
68 * 69 *
69 * Note: This can be triggered from a web page, e.g. a GAIA sign-in page. 70 * Note: This can be triggered from a web page, e.g. a GAIA sign-in page.
70 */ 71 */
71 public class AccountManagementFragment extends PreferenceFragment 72 public class AccountManagementFragment extends PreferenceFragment
72 implements SignOutDialogListener, ProfileDownloader.Observer, 73 implements SignOutDialogListener, ProfileDownloader.Observer,
73 SyncStateChangedListener, SignInStateObserver { 74 SyncStateChangedListener, SignInStateObserver,
75 ConfirmManagedSyncDataDialog.Listener {
74 public static final String SIGN_OUT_DIALOG_TAG = "sign_out_dialog_tag"; 76 public static final String SIGN_OUT_DIALOG_TAG = "sign_out_dialog_tag";
75 private static final String CLEAR_DATA_PROGRESS_DIALOG_TAG = "clear_data_pro gress"; 77 private static final String CLEAR_DATA_PROGRESS_DIALOG_TAG = "clear_data_pro gress";
76 78
77 /** 79 /**
78 * The key for an integer value in 80 * The key for an integer value in
79 * {@link Preferences#EXTRA_SHOW_FRAGMENT_ARGUMENTS} bundle to 81 * {@link Preferences#EXTRA_SHOW_FRAGMENT_ARGUMENTS} bundle to
80 * specify the correct GAIA service that has triggered the dialog. 82 * specify the correct GAIA service that has triggered the dialog.
81 * If the argument is not set, GAIA_SERVICE_TYPE_NONE is used as the origin of the dialog. 83 * If the argument is not set, GAIA_SERVICE_TYPE_NONE is used as the origin of the dialog.
82 */ 84 */
83 public static final String SHOW_GAIA_SERVICE_TYPE_EXTRA = "ShowGAIAServiceTy pe"; 85 public static final String SHOW_GAIA_SERVICE_TYPE_EXTRA = "ShowGAIAServiceTy pe";
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 @Override 245 @Override
244 public boolean onPreferenceClick(Preference preference) { 246 public boolean onPreferenceClick(Preference preference) {
245 if (!isVisible() || !isResumed()) return false; 247 if (!isVisible() || !isResumed()) return false;
246 248
247 if (ChromeSigninController.get(getActivity()).isSignedIn() 249 if (ChromeSigninController.get(getActivity()).isSignedIn()
248 && getSignOutAllowedPreferenceValue(getActivity())) { 250 && getSignOutAllowedPreferenceValue(getActivity())) {
249 AccountManagementScreenHelper.logEvent( 251 AccountManagementScreenHelper.logEvent(
250 ProfileAccountManagementMetrics.TOGGLE_SIGNOUT, 252 ProfileAccountManagementMetrics.TOGGLE_SIGNOUT,
251 mGaiaServiceType); 253 mGaiaServiceType);
252 254
253 SignOutDialogFragment signOutFragment = new SignOutDialo gFragment(); 255 String managementDomain =
254 Bundle args = new Bundle(); 256 SigninManager.get(getContext()).getManagementDom ain();
255 args.putInt(SHOW_GAIA_SERVICE_TYPE_EXTRA, mGaiaServiceTy pe); 257 if (managementDomain != null) {
256 signOutFragment.setArguments(args); 258 // Show the 'You are signing out of a managed accoun t' dialog.
259 ConfirmManagedSyncDataDialog.showSignOutFromManagedA ccountDialog(
260 AccountManagementFragment.this, getFragmentM anager(),
261 getResources(), managementDomain);
262 } else {
263 // Show the 'You are signing out' dialog.
264 SignOutDialogFragment signOutFragment = new SignOutD ialogFragment();
265 Bundle args = new Bundle();
266 args.putInt(SHOW_GAIA_SERVICE_TYPE_EXTRA, mGaiaServi ceType);
267 signOutFragment.setArguments(args);
257 268
258 signOutFragment.setTargetFragment(AccountManagementFragm ent.this, 0); 269 signOutFragment.setTargetFragment(AccountManagementF ragment.this, 0);
259 signOutFragment.show(getFragmentManager(), SIGN_OUT_DIAL OG_TAG); 270 signOutFragment.show(getFragmentManager(), SIGN_OUT_ DIALOG_TAG);
271 }
272
260 return true; 273 return true;
261 } 274 }
262 275
263 return false; 276 return false;
264 } 277 }
265 278
266 }); 279 });
267 } 280 }
268 } 281 }
269 282
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 508
496 @Override 509 @Override
497 public void onSignOutDialogDismissed(boolean signOutClicked) { 510 public void onSignOutDialogDismissed(boolean signOutClicked) {
498 if (!signOutClicked) { 511 if (!signOutClicked) {
499 AccountManagementScreenHelper.logEvent( 512 AccountManagementScreenHelper.logEvent(
500 ProfileAccountManagementMetrics.SIGNOUT_CANCEL, 513 ProfileAccountManagementMetrics.SIGNOUT_CANCEL,
501 mGaiaServiceType); 514 mGaiaServiceType);
502 } 515 }
503 } 516 }
504 517
518 // ConfirmManagedSyncDataDialog.Listener implementation
519 @Override
520 public void onConfirm() {
521 onSignOutClicked();
522 }
523
524 @Override
525 public void onCancel() {
526 onSignOutDialogDismissed(false);
527 }
528
505 // ProfileSyncServiceListener implementation: 529 // ProfileSyncServiceListener implementation:
506 530
507 @Override 531 @Override
508 public void syncStateChanged() { 532 public void syncStateChanged() {
509 SyncPreference pref = (SyncPreference) findPreference(PREF_SYNC_SETTINGS ); 533 SyncPreference pref = (SyncPreference) findPreference(PREF_SYNC_SETTINGS );
510 if (pref != null) { 534 if (pref != null) {
511 pref.updateSyncSummaryAndIcon(); 535 pref.updateSyncSummaryAndIcon();
512 } 536 }
513 537
514 // TODO(crbug/557784): Show notification for sync error 538 // TODO(crbug/557784): Show notification for sync error
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 * @param context A context 741 * @param context A context
718 * @param isAllowed True if the sign out is not disabled due to a child/EDU account 742 * @param isAllowed True if the sign out is not disabled due to a child/EDU account
719 */ 743 */
720 public static void setSignOutAllowedPreferenceValue(Context context, boolean isAllowed) { 744 public static void setSignOutAllowedPreferenceValue(Context context, boolean isAllowed) {
721 ContextUtils.getAppSharedPreferences() 745 ContextUtils.getAppSharedPreferences()
722 .edit() 746 .edit()
723 .putBoolean(SIGN_OUT_ALLOWED, isAllowed) 747 .putBoolean(SIGN_OUT_ALLOWED, isAllowed)
724 .apply(); 748 .apply();
725 } 749 }
726 } 750 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698