Add UI support in the browser for HTML5 databases
diff --git a/res/layout/permission_dialog.xml b/res/layout/permission_dialog.xml
new file mode 100644
index 0000000..ff24eaf
--- /dev/null
+++ b/res/layout/permission_dialog.xml
@@ -0,0 +1,158 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 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.
+ */
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+  android:drawingCacheQuality="auto"
+  android:layout_width="fill_parent"
+  android:layout_height="wrap_content"
+  android:orientation="vertical"
+  android:padding="0dip">
+
+  <LinearLayout
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="horizontal"
+    android:padding="10dip">
+
+    <ImageView
+      android:id="@+id/icon"
+      android:paddingRight="10dip"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_centerHorizontal="true"/>
+
+    <TextView
+      android:id="@+id/dialog_title"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_centerVertical="true"
+      android:gravity="center_vertical"
+      android:visibility="gone"
+      android:textSize="16dip"
+      android:textStyle="bold"
+      android:textColor="@color/white"/>
+
+  </LinearLayout>
+
+  <LinearLayout
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:orientation="vertical">
+
+    <ImageView android:id="@+id/titleDivider"
+        android:layout_width="fill_parent"
+        android:layout_height="1dip"
+        android:scaleType="fitXY"
+        android:gravity="fill_horizontal"
+        android:src="@drawable/dialog_divider_horizontal_light"
+        android:layout_marginLeft="10dip"
+        android:layout_marginRight="10dip"/>
+
+  </LinearLayout>
+
+  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:paddingBottom="10dip"
+    android:layout_weight="1">
+
+    <LinearLayout
+      android:orientation="vertical"
+      android:layout_width="fill_parent"
+      android:paddingTop="10dip"
+      android:paddingLeft="10dip"
+      android:paddingRight="10dip"
+      android:layout_height="wrap_content">
+
+      <TextView
+        android:id="@+id/origin"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:visibility="gone"
+        android:textStyle="bold"
+        android:gravity="left"
+        android:textSize="16dip"
+        android:textColor="@color/white"/>
+
+      <TextView
+        android:id="@+id/dialog_message"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:paddingLeft="4dip"
+        android:paddingTop="10dip"
+        android:gravity="left"
+        android:textSize="16dip"
+        android:textColor="@color/white"/>
+
+    </LinearLayout>
+
+  </ScrollView>
+
+  <LinearLayout
+    android:layout_width="fill_parent"
+    android:background="@color/gray"
+    android:layout_height="wrap_content"
+    android:paddingTop="4dip"
+    android:paddingLeft="0dip"
+    android:paddingRight="0dip">
+
+    <LinearLayout android:id="@+id/leftSpacer"
+       android:layout_weight="0.25"
+       android:layout_width="0dip"
+       android:layout_height="wrap_content"
+       android:orientation="horizontal"
+       android:visibility="gone"/>
+
+    <Button
+      android:id="@+id/button_allow"
+      android:layout_width="96dip"
+      android:layout_height="48dip"
+      android:layout_gravity="left"
+      android:layout_weight="1"
+      android:maxLines="2"
+      android:textSize="13dip"/>
+
+    <Button
+      android:id="@+id/button_alwaysdeny"
+      android:layout_width="96dip"
+      android:layout_height="48dip"
+      android:layout_gravity="left"
+      android:layout_weight="1"
+      android:maxLines="2"
+      android:textSize="13dip"/>
+
+    <Button
+      android:id="@+id/button_deny"
+      android:layout_width="96dip"
+      android:layout_height="48dip"
+      android:layout_gravity="right"
+      android:layout_weight="1"
+      android:maxLines="2"
+      android:textSize="13dip"/>
+
+    <LinearLayout android:id="@+id/rightSpacer"
+      android:layout_width="0dip"
+      android:layout_weight="0.25"
+      android:layout_height="wrap_content"
+      android:orientation="horizontal"
+      android:visibility="gone" />
+
+  </LinearLayout>
+
+</LinearLayout>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
new file mode 100644
index 0000000..219cc6b
--- /dev/null
+++ b/res/values/arrays.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+  -->
+<resources>
+   <string-array name="webstorage_quota_entries">
+      <item>No quota allowed</item>
+      <item>5 MB</item>
+      <item>10 MB</item>
+      <item>30 MB</item>
+      <item>100 MB</item>
+   </string-array>
+   <string-array name="webstorage_quota_entries_values">
+      <item>0</item>
+      <item>5</item>
+      <item>10</item>
+      <item>30</item>
+      <item>100</item>
+   </string-array>
+</resources>
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 77464d7..22ff0df 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -365,6 +365,31 @@
     <!-- Settings summary -->
     <string name="pref_extras_gears_enable_summary">Applications that extend browser functionality</string>
     <!-- Settings label -->
+    <string name="pref_extras_webstorage_settings">Local Storage</string>
+    <!-- Settings summary -->
+    <string name="pref_extras_webstorage_settings_summary">Allow websites to store information on your phone</string>
+    <!-- Settings label -->
+    <string name="pref_extras_webstorage_enable">Enable Database Storage</string>
+    <!-- Settings summary -->
+    <string name="pref_extras_webstorage_enable_summary">Allow websites to store informatin in a local database</string>
+    <!-- Settings label -->
+    <string name="pref_extras_webstorage_set_location">Set Databases Location</string>
+    <!-- Settings summary -->
+    <string name="pref_extras_webstorage_set_location_summary">Define where the databases are stored</string>
+    <!-- Settings label -->
+    <string name="pref_extras_webstorage_set_quota">Set Default Quota</string>
+    <!-- Settings summary -->
+    <string name="pref_extras_webstorage_set_quota_summary">The amount of storage new websites can use without your permission</string>
+    <!-- Settings label -->
+    <string name="pref_extras_webstorage_manage_databases">Manage Databases</string>
+    <!-- Settings summary -->
+    <string name="pref_extras_webstorage_manage_databases_summary">Configure existing databases</string>
+    <!-- Settings label -->
+    <string name="pref_extras_webstorage_clear_databases">Clear All Existing Databases</string>
+    <!-- Settings summary -->
+    <string name="pref_extras_webstorage_clear_databases_summary">Clear all data stored in local databases</string>
+    <string name="pref_extras_webstorage_clear_databases_dlg">All existing databases will be cleared</string>
+    <!-- Settings label -->
     <string name="pref_extras_gears_settings">Gears settings</string>
     <!-- Settings summary -->
     <string name="pref_plugin_installed">Plugins list</string>
@@ -655,6 +680,9 @@
     <!-- Gears Dialogs -->
     <string name="query_data_prompt">Allow storage</string>
     <string name="query_data_message">This web site would like to store information on your phone.</string>
+    <string name="query_storage_quota_prompt">Increase storage quota</string>
+    <string name="query_storage_quota_message">This web site is over its current
+      storage limit. Would you like to increase its quota limit ?</string>
     <string name="location_prompt">Access your location</string>
     <string name="location_message">This web site would like to have access to your location.</string>
     <string name="shortcut_prompt">Create a shortcut</string>
@@ -711,6 +739,22 @@
     <string name="unrecognized_dialog_message">Unrecognized dialog type</string>
     <string name="default_button">OK</string>
 
+    <!-- HTML5 dialogs -->
+    <!-- Used as a toast notification after the user close the html5 webstorage permission dialog -->
+    <string name="webstorage_notification">The quota for this site can be changed in the Local Storage section of the Browser settings</string>
+    <!-- Used in the Browser Settings -->
+    <string name="webstorage_manage_quota_title">Manage Quota</string>
+    <string name="webstorage_manage_quota_summary">Set a new size quota</string>
+    <string name="webstorage_clear_data_title">Clear All Data</string>
+    <string name="webstorage_clear_data_summary">Remove all databases associated with this website</string>
+    <!-- Confirmation dialog when the user ask to clear all data for an origin -->
+    <string name="webstorage_clear_data_dialog_title">Clear All Data</string>
+    <string name="webstorage_clear_data_dialog_message">All stored data by this origin will be deleted</string>
+    <!-- Strings used in the summary of origins -->
+    <string name="webstorage_origin_summary_mb_used">MB used</string>
+    <string name="webstorage_origin_summary_no_quota_left">no allowed quota left</string>
+    <string name="webstorage_origin_summary_mb_left">MB left in the quota</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. -->
     <string name="zoom_overview_button_text">Overview</string>
diff --git a/res/xml/browser_preferences.xml b/res/xml/browser_preferences.xml
index 79dfb92..c5b6b24 100644
--- a/res/xml/browser_preferences.xml
+++ b/res/xml/browser_preferences.xml
@@ -171,6 +171,42 @@
                     android:title="@string/pref_extras_gears_settings"
                     android:summary="@string/pref_extras_gears_settings_summary" />
 
+            <PreferenceScreen
+                    android:key="webstorage_settings"
+                    android:title="@string/pref_extras_webstorage_settings"
+                    android:summary="@string/pref_extras_webstorage_settings_summary">
+
+                  <CheckBoxPreference
+                        android:key="enable_database"
+                        android:defaultValue="true"
+                        android:title="@string/pref_extras_webstorage_enable"
+                        android:summary="@string/pref_extras_webstorage_enable_summary" />
+
+                  <ListPreference
+                        android:key="webstorage_default_quota"
+                        android:dependency="enable_database"
+                        android:title="@string/pref_extras_webstorage_set_quota"
+                        android:summary="@string/pref_extras_webstorage_set_quota_summary"
+                        android:entries="@array/webstorage_quota_entries"
+                        android:entryValues="@array/webstorage_quota_entries_values" />
+
+                  <PreferenceScreen
+                        android:key="webstorage_manage_databases"
+                        android:dependency="enable_database"
+                        android:title="@string/pref_extras_webstorage_manage_databases"
+                        android:summary="@string/pref_extras_webstorage_manage_databases_summary" />
+
+                  <com.android.browser.BrowserYesNoPreference
+                        android:key="webstorage_clear_databases"
+                        android:dependency="enable_database"
+                        android:title="@string/pref_extras_webstorage_clear_databases"
+                        android:summary="@string/pref_extras_webstorage_clear_databases_summary"
+                        android:dialogMessage="@string/pref_extras_webstorage_clear_databases_dlg"
+                        android:dialogTitle="@string/clear"
+                        android:dialogIcon="@android:drawable/ic_dialog_alert" />
+
+            </PreferenceScreen>
+
             <com.android.browser.BrowserYesNoPreference
                     android:key="reset_default_preferences"
                     android:title="@string/pref_extras_reset_default"