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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ClearAllStorageAction.java

Issue 1465363002: [Storage] Android - ManageSpace UI, Important Origins, and CBD Dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments, splitting off dialog logic, etc Created 5 years, 1 month 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
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..8a5e94bb36ed681c7194af8d6f0891790f4d45a9
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/ClearAllStorageAction.java
@@ -0,0 +1,87 @@
+// 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 2 dialogs to the user regarding clearing all site storage or all app
+ * data.
+ */
+public class ClearAllStorageAction {
+ /**
+ * Class that we delegate our clear calls to.
+ */
+ public static interface CanClearStorage {
+ void clearAllWebsiteStorage();
+ void clearAllAppData();
+ }
+
+ private CanClearStorage mStorageClearer;
+
+ /**
+ * @param storageClearer is used to either clear all website storage or clear all app data.
+ */
+ public ClearAllStorageAction(CanClearStorage storageClearer) {
+ mStorageClearer = storageClearer;
+ }
+
+ /**
+ * This creates two dialogs:
+ * * We prompt user if they want to clear the site data, or all app data.
+ * * When the user selects to clear all app data, we preset a confirmation dialog.
+ * Clearing app data and site storage data actions are sent to the CanClearStorage object.
+ * @param activity is the activity used to create the dialogs.
+ * @param totalWebsiteUsage is used to tell the user how much storage they can clear by clearing
+ * all website storage.
+ */
+ public void showClearDialog(final Activity activity, long totalWebsiteUsage) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ // Add the buttons
Finnur 2015/11/26 15:54:41 nit: Missing period.
dmurph 2015/11/30 22:16:53 Done.
+ builder.setPositiveButton(R.string.storage_clear_dialog_clear_storage_option,
+ new DialogInterface.OnClickListener() {
+ // We've clicked the 'clear all site storage' button.
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ mStorageClearer.clearAllWebsiteStorage();
+ }
+ });
+ builder.setNeutralButton(R.string.storage_clear_dialog_reset_app_option,
+ new DialogInterface.OnClickListener() {
+ // We've clicked the 'reset all app data' button.
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(activity);
+ builder.setPositiveButton(
+ R.string.ok, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ mStorageClearer.clearAllAppData();
+ }
+ });
+ builder.setNegativeButton(
+ R.string.cancel, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {}
+ });
+ builder.setTitle(R.string.storage_reset_app_dialog_title);
+ builder.setMessage(R.string.storage_reset_app_dialog_text);
+ builder.create().show();
+ }
+ });
+ 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();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698