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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/RepostFormWarningDialog.java

Issue 27461003: Implement form resubmission warning for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address findbugs's comments. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/TabBase.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/RepostFormWarningDialog.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/RepostFormWarningDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/RepostFormWarningDialog.java
new file mode 100644
index 0000000000000000000000000000000000000000..31f2b55f548e90901406e65e50aa4bee245c151f
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/RepostFormWarningDialog.java
@@ -0,0 +1,76 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser;
+
+import java.lang.Runnable;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
+import org.chromium.chrome.R;
+
+/**
+ * Form resubmission warning dialog. Presents the cancel/continue choice and fires one of two
+ * callbacks accordingly.
+ */
+class RepostFormWarningDialog extends DialogFragment {
+ // Warning dialog currently being shown, stored for testing.
+ private static Dialog sCurrentDialog;
+
+ private final Runnable mCancelCallback;
+ private final Runnable mContinueCallback;
+
+ public RepostFormWarningDialog(Runnable cancelCallback, Runnable continueCallback) {
+ mCancelCallback = cancelCallback;
+ mContinueCallback = continueCallback;
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity())
+ .setMessage(R.string.http_post_warning)
+ .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ mCancelCallback.run();
+ }
+ })
+ .setPositiveButton(R.string.http_post_warning_resend,
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ mContinueCallback.run();
+ }
+ });
+
+ assert getCurrentDialog() == null;
+ Dialog dialog = builder.create();
+ setCurrentDialog(dialog);
+
+ return dialog;
+ }
+
+ @Override
+ public void onDismiss(DialogInterface dialog) {
+ super.onDismiss(dialog);
+ setCurrentDialog(null);
+ }
+
+ /**
+ * Sets the currently displayed dialog in sCurrentDialog. This is required by findbugs, which
+ * allows static fields only to be set from static methods.
+ */
+ private static void setCurrentDialog(Dialog dialog) {
+ sCurrentDialog = dialog;
+ }
+
+ /**
+ * @return dialog currently being displayed.
+ */
+ public static Dialog getCurrentDialog() {
+ return sCurrentDialog;
+ }
+}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/TabBase.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698