Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ClearAllStorageAction.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ClearAllStorageAction.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ClearAllStorageAction.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..328199bd3d4cc326267427e914570266ce5312b4 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ClearAllStorageAction.java |
@@ -0,0 +1,65 @@ |
+// Copyright 2015 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.preferences.website; |
+ |
+import android.app.Activity; |
+import android.app.AlertDialog; |
+import android.content.DialogInterface; |
+import android.content.res.Resources; |
+import android.text.format.Formatter; |
+ |
+import org.chromium.chrome.R; |
+ |
+/** |
+ * This class handles showing clear storage dialogs to the user. |
+ */ |
+public class ClearAllStorageAction { |
+ /** |
+ * Class that we delegate our clear calls to. |
+ */ |
+ public static interface CanClearStorage { void clearStorage(); } |
+ |
+ private CanClearStorage mStorageClearer; |
+ |
+ /** |
+ * @param storageClearer is used to either clear all website storage or clear unimportant |
+ * storage. |
+ */ |
+ public ClearAllStorageAction(CanClearStorage storageClearer) { |
+ mStorageClearer = storageClearer; |
+ } |
+ |
+ public void showClearAllDialog(final Activity activity, long totalWebsiteUsage) { |
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity); |
+ builder.setPositiveButton(R.string.storage_clear_dialog_clear_storage_option, |
+ new DialogInterface.OnClickListener() { |
+ @Override |
+ public void onClick(DialogInterface dialog, int id) { |
+ mStorageClearer.clearStorage(); |
+ } |
+ }); |
+ builder.setNegativeButton(R.string.cancel, null); |
+ builder.setTitle(R.string.storage_clear_dialog_title); |
+ Resources res = activity.getResources(); |
+ String dialogFormattedText = res.getString(R.string.storage_clear_dialog_text, |
+ Formatter.formatShortFileSize(activity, totalWebsiteUsage)); |
+ builder.setMessage(dialogFormattedText); |
+ builder.create().show(); |
+ } |
+ |
+ public void showClearUnimportantDialog(final Activity activity) { |
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity); |
+ builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { |
+ @Override |
+ public void onClick(DialogInterface dialog, int id) { |
+ mStorageClearer.clearStorage(); |
+ } |
+ }); |
+ builder.setNegativeButton(R.string.cancel, null); |
+ builder.setTitle(R.string.storage_management_clear_unimportant_dialog_title); |
+ builder.setMessage(R.string.storage_management_clear_unimportant_dialog_text); |
+ builder.create().show(); |
+ } |
+} |