| 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | package org.chromium.chrome.testshell.sync; |
| 6 | |
| 7 | import android.app.AlertDialog; |
| 8 | import android.app.Dialog; |
| 9 | import android.app.DialogFragment; |
| 10 | import android.content.DialogInterface; |
| 11 | import android.os.Bundle; |
| 12 | |
| 13 | import org.chromium.chrome.browser.signin.SigninManager; |
| 14 | import org.chromium.chrome.testshell.R; |
| 15 | |
| 16 | /** |
| 17 | * The fragment to show when the user is given the option to sign out of Chromium. |
| 18 | */ |
| 19 | public class SignoutFragment extends DialogFragment implements DialogInterface.OnClickListener { |
| 20 | @Override |
| 21 | public Dialog onCreateDialog(Bundle savedInstanceState) { |
| 22 | return new AlertDialog.Builder(getActivity(), AlertDialog.THEME_HOLO_LIGHT) |
| 23 | .setTitle(R.string.signout_title) |
| 24 | .setPositiveButton(R.string.signout_sign_out, this) |
| 25 | .setNegativeButton(R.string.signout_cancel, this) |
| 26 | .create(); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public void onClick(DialogInterface dialog, int which) { |
| 31 | switch (which) { |
| 32 | case DialogInterface.BUTTON_POSITIVE: { |
| 33 | SigninManager.get(getActivity()).signOut(getActivity(), null); |
| 34 | break; |
| 35 | } |
| 36 | case DialogInterface.BUTTON_NEGATIVE: { |
| 37 | dismiss(); |
| 38 | break; |
| 39 | } |
| 40 | default: |
| 41 | break; |
| 42 | } |
| 43 | } |
| 44 | } |