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.app.Dialog; | 7 import android.app.Dialog; |
8 import android.app.DialogFragment; | 8 import android.app.DialogFragment; |
9 import android.content.DialogInterface; | 9 import android.content.DialogInterface; |
10 import android.os.Bundle; | 10 import android.os.Bundle; |
11 import android.support.v7.app.AlertDialog; | 11 import android.support.v7.app.AlertDialog; |
12 | 12 |
13 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
14 import org.chromium.chrome.browser.profiles.ProfileAccountManagementMetrics; | |
14 | 15 |
15 /** | 16 /** |
16 * Shows the dialog that explains the user the consequences of signing out of Ch rome. | 17 * Shows the dialog that explains the user the consequences of signing out of Ch rome. |
17 * Calls the listener callback if the user signs out. | 18 * Calls the listener callback if the user signs out. |
18 */ | 19 */ |
19 public class SignOutDialogFragment extends DialogFragment implements | 20 public class SignOutDialogFragment extends DialogFragment implements |
20 DialogInterface.OnClickListener { | 21 DialogInterface.OnClickListener { |
21 /** | 22 /** |
23 * The extra key used to specify the GAIA service that triggered this dialog . | |
24 */ | |
25 public static final String SHOW_GAIA_SERVICE_TYPE_EXTRA = "ShowGAIAServiceTy pe"; | |
26 | |
27 /** | |
22 * Receives updates when the user clicks "Sign out" or dismisses the dialog. | 28 * Receives updates when the user clicks "Sign out" or dismisses the dialog. |
23 */ | 29 */ |
24 public interface SignOutDialogListener { | 30 public interface SignOutDialogListener { |
25 /** | 31 /** |
26 * Called when the user clicks "Sign out". | 32 * Called when the user clicks "Sign out". |
27 */ | 33 */ |
28 public void onSignOutClicked(); | 34 public void onSignOutClicked(); |
29 | 35 |
30 /** | 36 /** |
31 * Called when the dialog is dismissed. | 37 * Called when the dialog is dismissed. |
32 * | 38 * |
33 * @param signOutClicked Whether the user clicked the "sign out" button before the dialog | 39 * @param signOutClicked Whether the user clicked the "sign out" button before the dialog |
34 * was dismissed. | 40 * was dismissed. |
35 */ | 41 */ |
36 public void onSignOutDialogDismissed(boolean signOutClicked); | 42 public void onSignOutDialogDismissed(boolean signOutClicked); |
37 } | 43 } |
38 | 44 |
39 private boolean mSignOutClicked; | 45 private boolean mSignOutClicked; |
46 /** | |
newt (away)
2016/02/16 23:05:01
newline before this
May
2016/02/17 13:24:31
Done.
| |
47 * The GAIA service that's prompted this dialog. Values can be any constant in | |
48 * signin::GAIAServiceType | |
49 */ | |
50 private int mGaiaServiceType; | |
40 | 51 |
41 @Override | 52 @Override |
42 public Dialog onCreateDialog(Bundle savedInstanceState) { | 53 public Dialog onCreateDialog(Bundle savedInstanceState) { |
54 mGaiaServiceType = AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE; | |
55 if (getArguments() != null) { | |
56 mGaiaServiceType = getArguments().getInt( | |
57 SHOW_GAIA_SERVICE_TYPE_EXTRA, mGaiaServiceType); | |
58 } | |
59 | |
43 String managementDomain = SigninManager.get(getActivity()).getManagement Domain(); | 60 String managementDomain = SigninManager.get(getActivity()).getManagement Domain(); |
44 String message; | 61 String message; |
45 if (managementDomain == null) { | 62 if (managementDomain == null) { |
46 message = getActivity().getResources().getString(R.string.signout_me ssage); | 63 message = getActivity().getResources().getString(R.string.signout_me ssage); |
47 } else { | 64 } else { |
48 message = getActivity().getResources().getString( | 65 message = getActivity().getResources().getString( |
49 R.string.signout_managed_account_message, managementDomain); | 66 R.string.signout_managed_account_message, managementDomain); |
50 } | 67 } |
51 | 68 |
52 return new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme) | 69 return new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme) |
53 .setTitle(R.string.signout_title) | 70 .setTitle(R.string.signout_title) |
54 .setPositiveButton(R.string.ok, this) | 71 .setPositiveButton(R.string.signout_dialog_positive_button, this ) |
55 .setNegativeButton(R.string.cancel, this) | 72 .setNegativeButton(R.string.cancel, this) |
56 .setMessage(message) | 73 .setMessage(message) |
57 .create(); | 74 .create(); |
58 } | 75 } |
59 | 76 |
60 @Override | 77 @Override |
61 public void onClick(DialogInterface dialog, int which) { | 78 public void onClick(DialogInterface dialog, int which) { |
62 if (which == AlertDialog.BUTTON_POSITIVE) { | 79 if (which == AlertDialog.BUTTON_POSITIVE) { |
80 AccountManagementScreenHelper.logEvent( | |
81 ProfileAccountManagementMetrics.SIGNOUT_SIGNOUT, mGaiaServic eType); | |
82 | |
63 mSignOutClicked = true; | 83 mSignOutClicked = true; |
64 SignOutDialogListener targetFragment = (SignOutDialogListener) getTa rgetFragment(); | 84 SignOutDialogListener targetFragment = (SignOutDialogListener) getTa rgetFragment(); |
65 targetFragment.onSignOutClicked(); | 85 targetFragment.onSignOutClicked(); |
66 } | 86 } |
67 } | 87 } |
68 | 88 |
69 @Override | 89 @Override |
70 public void onDismiss(DialogInterface dialog) { | 90 public void onDismiss(DialogInterface dialog) { |
71 super.onDismiss(dialog); | 91 super.onDismiss(dialog); |
92 AccountManagementScreenHelper.logEvent( | |
93 ProfileAccountManagementMetrics.SIGNOUT_CANCEL, mGaiaServiceType ); | |
94 | |
72 SignOutDialogListener targetFragment = (SignOutDialogListener) getTarget Fragment(); | 95 SignOutDialogListener targetFragment = (SignOutDialogListener) getTarget Fragment(); |
73 targetFragment.onSignOutDialogDismissed(mSignOutClicked); | 96 targetFragment.onSignOutDialogDismissed(mSignOutClicked); |
74 } | 97 } |
75 } | 98 } |
OLD | NEW |