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..ca56998303c4285990b8dcc98839fbf63548ecc0 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ClearAllStorageAction.java |
@@ -0,0 +1,65 @@ |
+// Copyright 2016 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.content.DialogInterface; |
+import android.content.res.Resources; |
+import android.support.v7.app.AlertDialog; |
+import android.text.format.Formatter; |
+ |
+import org.chromium.chrome.R; |
+ |
+/** |
+ * This class handles showing clear storage dialogs to the user. |
Theresa
2016/04/27 21:10:59
I'm having trouble working out where certain class
dmurph
2016/04/29 23:53:48
I removed this.
|
+ */ |
+public class ClearAllStorageAction { |
+ /** |
+ * Class that we delegate our clear calls to. |
+ */ |
+ public static interface CanClearStorage { void clearStorage(); } |
Theresa
2016/04/27 21:10:59
This is an odd interface name. Maybe ClearStorageD
dmurph
2016/04/29 23:53:48
Removed.
|
+ |
+ private CanClearStorage mStorageClearer; |
+ |
+ /** |
+ * @param storageClearer is used to either clear all website storage or clear unimportant |
Theresa
2016/04/27 21:10:59
Nit: capitalize "Is"
dmurph
2016/04/29 23:53:48
REmoved.
|
+ * storage. |
+ */ |
+ public ClearAllStorageAction(CanClearStorage storageClearer) { |
+ mStorageClearer = storageClearer; |
+ } |
+ |
+ public void showClearAllDialog(final Activity activity, long totalWebsiteUsage) { |
Theresa
2016/04/27 21:10:59
javadocs for this method and the one below
dmurph
2016/04/29 23:53:48
Removed.
|
+ 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(); |
+ } |
+} |