Add an options menu to the web site settings activity with just one option to clear all websites' storage/geolocation permissions.
Change-Id: Idbcf24f5340491e8d75353838c482bc2d5039da8
diff --git a/res/menu/websitesettings.xml b/res/menu/websitesettings.xml
new file mode 100644
index 0000000..5acc8a5
--- /dev/null
+++ b/res/menu/websitesettings.xml
@@ -0,0 +1,21 @@
+<!-- Copyright (C) 2009 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:id="@+id/website_settings_menu_clear_all"
+ android:title="@string/website_settings_clear_all"
+ android:icon="@android:drawable/ic_menu_close_clear_cancel" />
+</menu>
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3654c74..3555e86 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -736,6 +736,13 @@
<string name="geolocation_settings_page_dialog_message">Location access for this website will be cleared</string>
<string name="geolocation_settings_page_dialog_ok_button">Clear access</string>
<string name="geolocation_settings_page_dialog_cancel_button">Cancel</string>
+ <!-- Label for the menu item in the website settings activity used to clear data stored by all websites -->
+ <string name="website_settings_clear_all">Clear All</string>
+ <string name="website_settings_clear_all_dialog_title">Clear All Website Settings?</string>
+ <string name="website_settings_clear_all_dialog_message">All website data and Geolocation permissions will be deleted.</string>
+ <string name="website_settings_clear_all_dialog_ok_button">Delete All Data</string>
+ <string name="website_settings_clear_all_dialog_cancel_button">Cancel</string>
+
<!-- Zoom-related strings --><skip />
<!-- Caption for a button that is shown when the zoom widget is showing. The button's action will switch to the zoom overview mode. -->
diff --git a/src/com/android/browser/WebsiteSettingsActivity.java b/src/com/android/browser/WebsiteSettingsActivity.java
index 577fc1c..fc72b62 100644
--- a/src/com/android/browser/WebsiteSettingsActivity.java
+++ b/src/com/android/browser/WebsiteSettingsActivity.java
@@ -29,6 +29,9 @@
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.GeolocationPermissions;
@@ -433,4 +436,41 @@
setListAdapter(mAdapter);
getListView().setOnItemClickListener(mAdapter);
}
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.websitesettings, menu);
+ return true;
+ }
+
+ @Override
+ public boolean onPrepareOptionsMenu(Menu menu) {
+ // If we aren't listing any sites hide the clear all button (and hence the menu).
+ return mAdapter.getCount() > 0;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.website_settings_menu_clear_all:
+ // Show the prompt to clear all origins of their data and geolocation permissions.
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.website_settings_clear_all_dialog_title)
+ .setMessage(R.string.website_settings_clear_all_dialog_message)
+ .setPositiveButton(R.string.website_settings_clear_all_dialog_ok_button,
+ new AlertDialog.OnClickListener() {
+ public void onClick(DialogInterface dlg, int which) {
+ WebStorage.getInstance().deleteAllData();
+ GeolocationPermissions.getInstance().clearAll();
+ mAdapter.populateOrigins();
+ mAdapter.notifyDataSetChanged();
+ }})
+ .setNegativeButton(R.string.website_settings_clear_all_dialog_cancel_button, null)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .show();
+ return true;
+ }
+ return false;
+ }
}