| Index: chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
|
| index 80ebc63b65b530d71261e8a977b688a36258ec4f..0ecf63c354b1d882bb9b612ad407d175f433e30e 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationDelegateImpl.java
|
| @@ -364,17 +364,37 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
|
| }
|
| }
|
|
|
| + /**
|
| + * Shows an alert dialog prompting the user to leave incognito mode.
|
| + *
|
| + * @param activity The {@link Activity} to launch the dialog from.
|
| + * @param onAccept Will be called when the user chooses to leave incognito.
|
| + * @param onCancel Will be called when the user declines to leave incognito.
|
| + */
|
| + public static void showLeaveIncognitoWarningDialog(Activity activity,
|
| + final OnClickListener onAccept, final OnCancelListener onCancel) {
|
| + new AlertDialog.Builder(activity, R.style.AlertDialogTheme)
|
| + .setTitle(R.string.external_app_leave_incognito_warning_title)
|
| + .setMessage(R.string.external_app_leave_incognito_warning)
|
| + .setPositiveButton(R.string.ok, onAccept)
|
| + .setNegativeButton(R.string.cancel, new OnClickListener() {
|
| + @Override
|
| + public void onClick(DialogInterface dialog, int which) {
|
| + onCancel.onCancel(dialog);
|
| + }
|
| + })
|
| + .setOnCancelListener(onCancel)
|
| + .show();
|
| + }
|
| +
|
| @Override
|
| public void startIncognitoIntent(final Intent intent, final String referrerUrl,
|
| final String fallbackUrl, final Tab tab, final boolean needsToCloseTab) {
|
| Context context = tab.getWindowAndroid().getContext().get();
|
| if (!(context instanceof Activity)) return;
|
|
|
| - Activity activity = (Activity) context;
|
| - new AlertDialog.Builder(activity, R.style.AlertDialogTheme)
|
| - .setTitle(R.string.external_app_leave_incognito_warning_title)
|
| - .setMessage(R.string.external_app_leave_incognito_warning)
|
| - .setPositiveButton(R.string.ok, new OnClickListener() {
|
| + showLeaveIncognitoWarningDialog((Activity) context,
|
| + new OnClickListener() {
|
| @Override
|
| public void onClick(DialogInterface dialog, int which) {
|
| startActivity(intent);
|
| @@ -383,20 +403,13 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
|
| closeTab(tab);
|
| }
|
| }
|
| - })
|
| - .setNegativeButton(R.string.cancel, new OnClickListener() {
|
| - @Override
|
| - public void onClick(DialogInterface dialog, int which) {
|
| - loadIntent(intent, referrerUrl, fallbackUrl, tab, needsToCloseTab, true);
|
| - }
|
| - })
|
| - .setOnCancelListener(new OnCancelListener() {
|
| + },
|
| + new OnCancelListener() {
|
| @Override
|
| public void onCancel(DialogInterface dialog) {
|
| loadIntent(intent, referrerUrl, fallbackUrl, tab, needsToCloseTab, true);
|
| }
|
| - })
|
| - .show();
|
| + });
|
| }
|
|
|
| @Override
|
|
|