auto import from //branches/cupcake/...@131421
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index e58231a..110bda4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -28,6 +28,9 @@
     <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT"/>
     <uses-permission android:name="android.permission.INTERNET" />
     <uses-permission android:name="android.permission.WAKE_LOCK"/>
+    <!-- Needed by the ZoomRingController to set the bit saying we've already shown the
+         tutorial toast. -->
+    <uses-permission android:name="android.permission.WRITE_SETTINGS"/>
     <uses-permission android:name="com.android.browser.permission.READ_HISTORY_BOOKMARKS"/>
     <uses-permission android:name="com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"/>
 
diff --git a/res/drawable/dialog_divider_horizontal_light.9.png b/res/drawable/dialog_divider_horizontal_light.9.png
new file mode 100755
index 0000000..b69619b
--- /dev/null
+++ b/res/drawable/dialog_divider_horizontal_light.9.png
Binary files differ
diff --git a/res/drawable/ic_dialog_menu_generic.png b/res/drawable/ic_dialog_menu_generic.png
new file mode 100755
index 0000000..de07bda
--- /dev/null
+++ b/res/drawable/ic_dialog_menu_generic.png
Binary files differ
diff --git a/res/layout-land/gears_dialog.xml b/res/layout-land/gears_dialog.xml
deleted file mode 100644
index 5536fed..0000000
--- a/res/layout-land/gears_dialog.xml
+++ /dev/null
@@ -1,161 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
- * Copyright 2008, 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="10dip"
-  android:background="@color/white">
-
-  <LinearLayout
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical"
-    android:paddingBottom="10dip">
-
-    <LinearLayout
-      android:layout_width="fill_parent"
-      android:layout_height="wrap_content"
-      android:orientation="vertical">
-
-      <LinearLayout
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:orientation="horizontal">
-
-        <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:paddingRight="10dip"
-          android:gravity="center_vertical"
-          android:visibility="gone"
-          android:textSize="16dip"
-          android:textStyle="bold"
-          android:textColor="@color/black"/>
-
-        <TextView
-          android:id="@+id/dialog_subtitle"
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:paddingTop="10dip"
-          android:paddingRight="10dip"
-          android:gravity="center_vertical"
-          android:visibility="gone"
-          android:textSize="13dip"
-          android:textColor="@color/black"/>
-
-        <TextView
-          android:id="@+id/dialog_message"
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:visibility="gone"
-          android:gravity="center_vertical"
-          android:textSize="13dip"
-          android:textColor="@color/black"/>
-
-      </LinearLayout>
-
-    </LinearLayout>
-
-  </LinearLayout>
-
-  <LinearLayout
-    android:id="@+id/panel_content"
-    android:layout_width="fill_parent"
-    android:layout_height="0dip"
-    android:layout_weight="1"/>
-
-  <RelativeLayout
-    android:background="@color/white"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:paddingTop="2dip">
-
-    <LinearLayout 
-      android:orientation="vertical"
-      android:layout_width="fill_parent"
-      android:layout_height="wrap_content">
-
-       <TextView
-         android:id="@+id/selection"
-         android:layout_width="fill_parent"
-         android:layout_height="wrap_content"
-         android:textSize="13dip"
-         android:gravity="right"
-         android:textColor="@color/black"/>
-
-       <RelativeLayout
-         android:background="@color/white"
-         android:layout_width="fill_parent"
-         android:layout_height="wrap_content"
-         android:paddingTop="2dip">
-
-         <LinearLayout
-           android:orientation="horizontal"
-           android:layout_width="wrap_content"
-           android:layout_height="wrap_content"
-           android:background="@color/white">
-
-           <Button
-             android:id="@+id/button_alwaysdeny"
-             android:layout_width="wrap_content"
-             android:layout_height="48px"
-             android:layout_alignParentLeft="true"
-             style="@style/gears_button"
-             android:textSize="13dip"/>
-
-         </LinearLayout>
-
-         <LinearLayout
-           android:layout_width="wrap_content"
-           android:layout_alignParentRight="true"
-           android:layout_height="wrap_content">
-
-           <Button
-             android:id="@+id/button_allow"
-             android:layout_width="wrap_content"
-             android:layout_height="48px"
-             android:textSize="13dip"/>
-
-           <Button
-             android:id="@+id/button_deny"
-             android:layout_width="wrap_content"
-             android:layout_height="48px"
-             android:textSize="13dip"/>
-
-         </LinearLayout>
-
-       </RelativeLayout>
-
-    </LinearLayout>
-
-  </RelativeLayout>
-
-</LinearLayout>
diff --git a/res/layout/gears_dialog.xml b/res/layout/gears_dialog.xml
index 0d834f3..57d4f0b 100644
--- a/res/layout/gears_dialog.xml
+++ b/res/layout/gears_dialog.xml
@@ -22,14 +22,13 @@
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical"
-  android:padding="10dip"
-  android:background="@color/white">
+  android:padding="0dip">
 
   <LinearLayout
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:orientation="vertical"
-    android:paddingBottom="10dip">
+    android:padding="10dip">
 
     <LinearLayout
       android:layout_width="fill_parent"
@@ -46,7 +45,7 @@
           android:paddingRight="10dip"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
-          android:layout_centerHorizontal="true" />
+          android:layout_centerHorizontal="true"/>
 
         <TextView
           android:id="@+id/dialog_title"
@@ -57,7 +56,7 @@
           android:visibility="gone"
           android:textSize="16dip"
           android:textStyle="bold"
-          android:textColor="@color/black"/>
+          android:textColor="@color/white"/>
 
         <TextView
           android:id="@+id/dialog_message"
@@ -65,95 +64,112 @@
           android:layout_height="wrap_content"
           android:visibility="gone"
           android:gravity="center_vertical"
-          android:textSize="13dip"
-          android:textColor="@color/black"/>
+          android:textSize="20dip"
+          android:textColor="@color/white"/>
 
       </LinearLayout>
 
-      <TextView
-        android:id="@+id/dialog_subtitle"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:paddingTop="10dip"
-        android:gravity="center_vertical"
-        android:visibility="gone"
-        android:textSize="13dip"
-        android:textColor="@color/black"/>
-
     </LinearLayout>
 
   </LinearLayout>
 
   <LinearLayout
-    android:id="@+id/panel_content"
-    android:layout_width="fill_parent"
-    android:layout_height="0dip"
-    android:layout_weight="1"/>
-
-  <RelativeLayout
-    android:background="@color/white"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
-    android:paddingTop="2dip">
+    android:orientation="vertical">
 
-    <LinearLayout 
+    <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>
+
+  <LinearLayout
+    android:id="@+id/panel_content"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:padding="0dip"
+    android:layout_weight="1" />
+
+  <RelativeLayout
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:paddingLeft="10dip"
+    android:paddingRight="10dip"
+    android:paddingTop="0dip">
+
+    <LinearLayout
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content">
 
-       <TextView
-         android:id="@+id/selection"
-         android:layout_width="fill_parent"
-         android:layout_height="wrap_content"
-         android:textSize="13dip"
-         android:gravity="right"
-         android:textColor="@color/black"/>
-
-       <RelativeLayout
-         android:background="@color/white"
-         android:layout_width="fill_parent"
-         android:layout_height="wrap_content"
-         android:paddingTop="2dip">
-
-         <LinearLayout
-           android:orientation="horizontal"
-           android:layout_width="wrap_content"
-           android:layout_height="wrap_content"
-           android:background="@color/white">
- 
-           <Button
-             android:id="@+id/button_alwaysdeny"
-             android:layout_width="wrap_content"
-             android:layout_height="48px"
-             android:layout_alignParentLeft="true"
-             style="@style/gears_button"
-             android:textSize="13dip"/>
-
-         </LinearLayout>
-
-         <LinearLayout
-           android:layout_width="wrap_content"
-           android:layout_alignParentRight="true"
-           android:layout_height="wrap_content">
-
-           <Button
-             android:id="@+id/button_allow"
-             android:layout_width="wrap_content"
-             android:layout_height="48px"
-             android:textSize="13dip"/>
-
-           <Button
-             android:id="@+id/button_deny"
-             android:layout_width="wrap_content"
-             android:layout_height="48px"
-             android:textSize="13dip"/>
-
-         </LinearLayout>
-
-       </RelativeLayout>
+      <TextView
+        android:id="@+id/selection"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:textSize="13dip"
+        android:gravity="right"
+        android:visibility="gone"
+        android:textColor="@color/white"/>
 
     </LinearLayout>
 
   </RelativeLayout>
 
+  <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="96px"
+      android:layout_height="48px"
+      android:layout_gravity="left"
+      android:layout_weight="1"
+      android:maxLines="2"
+      android:textSize="13dip"/>
+
+    <Button
+      android:id="@+id/button_alwaysdeny"
+      android:layout_width="96px"
+      android:layout_height="48px"
+      android:layout_gravity="left"
+      android:layout_weight="1"
+      android:maxLines="2"
+      android:textSize="13dip"/>
+
+    <Button
+      android:id="@+id/button_deny"
+      android:layout_width="96px"
+      android:layout_height="48px"
+      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/layout/gears_dialog_filepicker.xml b/res/layout/gears_dialog_filepicker.xml
index b1c1646..68268f1 100644
--- a/res/layout/gears_dialog_filepicker.xml
+++ b/res/layout/gears_dialog_filepicker.xml
@@ -23,22 +23,9 @@
   android:layout_height="wrap_content">
 
   <LinearLayout
-    android:orientation="vertical"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:background="@color/white" >
-
-    <GridView android:id="@+id/paths_list"
-      android:padding="4dip"
-      android:layout_width="fill_parent"
-      android:layout_height="wrap_content" />
-  </LinearLayout>
-
-  <LinearLayout
     android:orientation="horizontal"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:background="@color/white">
+    android:layout_height="wrap_content">
 
     <TextView
       android:id="@+id/path_name"
@@ -46,67 +33,28 @@
       android:layout_height="wrap_content"
       android:textSize="13dip"
       android:textColor="@color/dark_gray"/>
- 
+
     <TextView
       android:id="@+id/current_path"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:textSize="13dip"
-      android:textColor="@color/black"/>
+      android:textColor="@color/white"/>
 
   </LinearLayout>
 
   <LinearLayout
     android:orientation="vertical"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:background="@color/gray"
-    android:padding="1px">
+    android:layout_height="wrap_content">
 
-    <LinearLayout
-      android:orientation="vertical"
+    <GridView android:id="@+id/files_list"
+      android:padding="4px"
       android:layout_width="fill_parent"
-      android:layout_height="wrap_content"
-      android:background="@color/white">
-
-      <LinearLayout
-        android:orientation="horizontal"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:gravity="center"
-        android:background="@color/white">
-
-        <ImageView
-          android:id="@+id/image"
-          android:padding="10dip"
-          android:layout_centerHorizontal="true"
-          android:layout_width="wrap_content"
-          android:layout_height="wrap_content"
-          android:adjustViewBounds="true"
-          android:visibility="gone"
-          android:gravity="center"
-          android:src="@drawable/gears"/>
-
-        <LinearLayout
-          android:orientation="vertical"
-          android:layout_width="fill_parent"
-          android:layout_height="wrap_content"
-          android:background="@color/white">
- 
-          <GridView android:id="@+id/files_list"
-            android:padding="4px"
-            android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
-            android:horizontalSpacing="2px"
-            android:verticalSpacing="2px"
-            android:numColumns="3"
-            style="@android:style/Widget.ListView.White" />
-
-        </LinearLayout>
-
-      </LinearLayout>
-
-    </LinearLayout>
+      android:layout_height="fill_parent"
+      android:horizontalSpacing="2px"
+      android:verticalSpacing="2px"
+      android:numColumns="3" />
 
   </LinearLayout>
 
diff --git a/res/layout/gears_dialog_filepicker_cell.xml b/res/layout/gears_dialog_filepicker_cell.xml
index 0440e1f..369fc6a 100644
--- a/res/layout/gears_dialog_filepicker_cell.xml
+++ b/res/layout/gears_dialog_filepicker_cell.xml
@@ -32,9 +32,9 @@
 
   <TextView
     android:id="@+id/name"
-    android:textColor="@color/black"
+    android:textColor="@color/white"
     android:textSize="13dip"
-    android:shadowColor="@color/white"
+    android:shadowColor="@color/black"
     android:shadowRadius="2.0"
     android:singleLine="true"
     android:ellipsize="middle"
diff --git a/res/layout/gears_dialog_permission.xml b/res/layout/gears_dialog_permission.xml
index 3852f83..01914e2 100644
--- a/res/layout/gears_dialog_permission.xml
+++ b/res/layout/gears_dialog_permission.xml
@@ -17,22 +17,23 @@
  */
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-  android:orientation="vertical"
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
-  android:layout_height="wrap_content">
+  android:layout_height="wrap_content"
+  android:paddingBottom="10dip">
 
   <LinearLayout
+    android:orientation="vertical"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:id="@+id/content_border"
-    android:padding="1px">
+    android:paddingTop="10dip"
+    android:paddingLeft="10dip"
+    android:paddingRight="10dip"
+    android:layout_height="wrap_content">
 
     <LinearLayout
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
-      android:id="@+id/content_background"
-      android:padding="4dip">
+      android:orientation="horizontal">
 
       <ImageView
         android:id="@+id/origin_icon"
@@ -57,8 +58,8 @@
           android:visibility="gone"
           android:textStyle="bold"
           android:gravity="left"
-          android:textSize="13dip"
-          android:textColor="@color/black"/>
+          android:textSize="16dip"
+          android:textColor="@color/white"/>
 
         <TextView
           android:id="@+id/origin_subtitle"
@@ -67,7 +68,7 @@
           android:visibility="gone"
           android:gravity="left"
           android:textSize="13dip"
-          android:textColor="@color/black"/>
+          android:textColor="@color/white"/>
 
         <TextView
           android:id="@+id/origin_message"
@@ -77,24 +78,34 @@
           android:paddingTop="10dip"
           android:gravity="left"
           android:textSize="13dip"
-          android:textColor="@color/black"/>
+          android:textColor="@color/white"/>
 
       </LinearLayout>
 
     </LinearLayout>
 
+    <TextView
+      android:id="@+id/privacy_policy_label"
+      android:layout_width="fill_parent"
+      android:layout_height="wrap_content"
+      android:paddingTop="10dip"
+      android:gravity="center_horizontal"
+      android:textSize="13dip"
+      android:textStyle="italic"
+      android:textColor="@color/white"
+      android:visibility="gone"
+      android:text="@string/privacy_policy" />
+
+    <TextView
+      android:id="@+id/permission_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>
 
-  <TextView
-    android:id="@+id/privacy_policy_label"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:paddingTop="10dip"
-    android:gravity="center_horizontal"
-    android:textSize="13dip"
-    android:textStyle="italic"
-    android:textColor="@color/black"
-    android:visibility="gone"
-    android:text="@string/privacy_policy" />
-
-</LinearLayout>
+</ScrollView>
diff --git a/res/layout/gears_dialog_settings.xml b/res/layout/gears_dialog_settings.xml
index 07b08ab..a9026db 100644
--- a/res/layout/gears_dialog_settings.xml
+++ b/res/layout/gears_dialog_settings.xml
@@ -36,7 +36,7 @@
       android:background="@color/white">
 
       <ListView android:id="@+id/sites_list"
-        android:padding="2dip"
+        android:padding="4dip"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         style="@android:style/Widget.ListView.White" />
diff --git a/res/layout/gears_dialog_shortcut.xml b/res/layout/gears_dialog_shortcut.xml
new file mode 100644
index 0000000..28f93d0
--- /dev/null
+++ b/res/layout/gears_dialog_shortcut.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 2008, 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.
+ */
+-->
+
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+  android:layout_width="fill_parent"
+  android:layout_height="wrap_content"
+  android:paddingBottom="10dip">
+
+  <LinearLayout
+    android:orientation="vertical"
+    android:paddingLeft="10dip"
+    android:paddingRight="10dip"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content">
+
+    <LinearLayout
+      android:layout_width="fill_parent"
+      android:layout_height="wrap_content"
+      android:padding="4dip"
+      android:orientation="vertical">
+
+      <TextView
+        android:id="@+id/origin_subtitle"
+        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"/>
+
+    </LinearLayout>
+
+    <TextView
+      android:id="@+id/privacy_policy_label"
+      android:layout_width="fill_parent"
+      android:layout_height="wrap_content"
+      android:paddingTop="10dip"
+      android:gravity="center_horizontal"
+      android:textSize="13dip"
+      android:textStyle="italic"
+      android:textColor="@color/white"
+      android:visibility="gone"
+      android:text="@string/privacy_policy" />
+
+    <TextView
+      android:id="@+id/permission_dialog_message"
+      android:layout_width="fill_parent"
+      android:layout_height="wrap_content"
+      android:paddingTop="10dip"
+      android:gravity="left"
+      android:textSize="16dip"
+      android:textColor="@color/white"/>
+
+    <LinearLayout
+      android:id="@+id/shortcut_panel"
+      android:layout_width="fill_parent"
+      android:layout_height="wrap_content"
+      android:visibility="gone"
+      android:gravity="center"
+      android:orientation="vertical">
+
+      <ImageView
+        android:id="@+id/origin_icon"
+        android:paddingTop="10dip"
+        android:layout_centerHorizontal="true"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:gravity="center"
+        android:adjustViewBounds="true"
+        android:src="@drawable/gears"/>
+
+      <TextView
+        android:id="@+id/shortcut_name"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:paddingTop="10dip"
+        android:gravity="center"
+        android:textSize="13dip"
+        android:textColor="@color/white"/>
+
+    </LinearLayout>
+
+  </LinearLayout>
+
+</ScrollView>
+
diff --git a/res/layout/gears_settings.xml b/res/layout/gears_settings.xml
new file mode 100644
index 0000000..e3a4cbe
--- /dev/null
+++ b/res/layout/gears_settings.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 2008, 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">
+
+  <ListView android:id="@+id/sites_list"
+    android:padding="4dip"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content" />
+
+  <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>
+
+</LinearLayout>
diff --git a/res/layout/gears_settings_row.xml b/res/layout/gears_settings_row.xml
new file mode 100644
index 0000000..6a1e851
--- /dev/null
+++ b/res/layout/gears_settings_row.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+ * Copyright 2008, 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.
+ */
+-->
+
+<com.android.internal.view.menu.ListMenuItemView
+  xmlns:android="http://schemas.android.com/apk/res/android"
+  android:layout_width="fill_parent"
+  android:layout_height="?android:attr/listPreferredItemHeight">
+
+  <RelativeLayout
+    android:layout_width="0dip"
+    android:layout_weight="1"
+    android:layout_height="wrap_content"
+    android:layout_gravity="center_vertical"
+    android:layout_marginLeft="6dip"
+    android:layout_marginRight="6dip"
+    android:duplicateParentState="true">
+
+    <TextView
+      android:id="@+id/title"
+      android:layout_width="fill_parent"
+      android:layout_height="wrap_content"
+      android:layout_alignParentTop="true"
+      android:layout_alignParentLeft="true"
+      android:textAppearance="?android:attr/textAppearanceMedium"
+      android:singleLine="true"
+      android:duplicateParentState="true"
+      android:ellipsize="start"
+      android:fadingEdge="none"/>
+
+    <TextView
+      android:id="@+id/subtitle"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_below="@id/title"
+      android:layout_alignParentLeft="true"
+      android:textAppearance="?android:attr/textAppearanceSmall"
+      android:singleLine="false"
+      android:duplicateParentState="true"/>
+
+    <TextView
+      android:id="@+id/info"
+      android:visibility="gone"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_below="@id/subtitle"
+      android:textAppearance="?android:attr/textAppearanceMedium"
+      android:singleLine="true"
+      android:layout_centerHorizontal="true"
+      android:duplicateParentState="true"
+      android:ellipsize="marquee"
+      android:fadingEdge="horizontal"/>
+
+  </RelativeLayout>
+
+  <LinearLayout
+    android:layout_width="wrap_content"
+    android:layout_height="fill_parent"
+    android:paddingLeft="10dip"
+    android:gravity="center_vertical"
+    android:orientation="horizontal">
+
+    <ImageView
+      android:id="@+id/icon"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:visibility="gone"
+      android:src="@drawable/ic_dialog_menu_generic" />
+
+    <CheckBox
+      android:id="@+id/checkbox"
+      android:layout_width="wrap_content"
+      android:layout_height="wrap_content"
+      android:layout_alignParentLeft="true"
+      android:drawablePadding="10dip"
+      android:focusable="false"
+      android:clickable="false"
+      android:duplicateParentState="true"
+      android:visibility="gone"
+      android:textSize="16dip"/>
+
+  </LinearLayout>
+
+</com.android.internal.view.menu.ListMenuItemView>
diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml
index 7ac84e6..20fe7df 100644
--- a/res/values-nb/strings.xml
+++ b/res/values-nb/strings.xml
@@ -16,17 +16,12 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="application_name">"Nettleser"</string>
-    <!-- no translation found for tab_bookmarks (2305793036003473653) -->
-    <skip />
-    <!-- no translation found for tab_most_visited (1077402532455000703) -->
-    <skip />
-    <!-- no translation found for tab_history (1979267558744613746) -->
-    <skip />
-    <!-- no translation found for added_to_bookmarks (1020224130695956728) -->
-    <skip />
-    <!-- no translation found for removed_from_bookmarks (6063705902028438800) -->
-    <skip />
-    <string name="sign_in_to">"Logg inn på <xliff:g id="HOSTNAME">%s1</xliff:g> \\\"<xliff:g id="REALM">%s2</xliff:g>\\\""</string>
+    <string name="tab_bookmarks">"Bokmerker"</string>
+    <string name="tab_most_visited">"Mest besøkt"</string>
+    <string name="tab_history">"Historie"</string>
+    <string name="added_to_bookmarks">"Lagt til bokmerker"</string>
+    <string name="removed_from_bookmarks">"Fjernet fra bokmerker"</string>
+    <string name="sign_in_to">"Logg inn på <xliff:g id="HOSTNAME">%s1</xliff:g> \\\\\\\"<xliff:g id="REALM">%s2</xliff:g>\\\\\\\""</string>
     <string name="username">"Brukernavn"</string>
     <string name="password">"Passord"</string>
     <string name="action">"Logg inn"</string>
@@ -81,13 +76,12 @@
     <string name="delete_bookmark">"Slett"</string>
     <string name="bookmark_page">"Legg til bokmerke for sist sette side"</string>
     <string name="current_page">"Gjeldende side:"</string>
-    <string name="delete_bookmark_warning">"Bokmerket \\\"<xliff:g id="BOOKMARK">%s</xliff:g>\\\" vil bli slettet."</string>
+    <string name="delete_bookmark_warning">"Bokmerket \\\\\\\"<xliff:g id="BOOKMARK">%s</xliff:g>\\\\\\\" vil bli slettet."</string>
     <string name="open_in_new_window">"Åpne i nytt vindu"</string>
     <string name="new_window">"Nytt vindu"</string>
     <string name="goto_dot">"Gå til URL"</string>
     <string name="find_dot">"Finn på siden"</string>
-    <!-- no translation found for select_dot (6299170761900561967) -->
-    <skip />
+    <string name="select_dot">"Velg tekst"</string>
     <string name="view_tabs">"Vindusoversikt"</string>
     <string name="view_tabs_condensed">"Vinduer"</string>
     <string name="tab_picker_title">"Gjeldende vinduer"</string>
@@ -206,7 +200,7 @@
     <string name="browserFrameNetworkErrorLabel">"Tilkoblingsproblem"</string>
     <string name="browserFrameFileErrorLabel">"Problem med fil"</string>
     <string name="browserFrameFormResubmitLabel">"Bekreft"</string>
-    <string name="browserFrameFormResubmitMessage">"Siden du prøver å se, inneholder data som allerede er blitt sendt inn (\\\"POSTDATA\\\"). Hvis du sender dataene på nytt, kan det skjemaet på siden gjorde bli gjort på nytt."</string>
+    <string name="browserFrameFormResubmitMessage">"Siden du prøver å se, inneholder data som allerede er blitt sendt inn (\\\\\\\"POSTDATA\\\\\\\"). Hvis du sender dataene på nytt, kan det skjemaet på siden gjorde bli gjort på nytt."</string>
     <string name="loadSuspendedTitle">"Ingen nettverkstilkobling"</string>
     <string name="loadSuspended">"Siden vil fortsette å laste etter at tilkoblingen er blitt gjenopprettet."</string>
     <string name="clear_history">"Slett logg"</string>
@@ -241,7 +235,7 @@
     <string name="download_no_sdcard_dlg_title">"Mangler minnekort"</string>
     <string name="download_no_sdcard_dlg_msg">"Du trenger et minnekort for å laste ned <xliff:g id="FILENAME">%s</xliff:g>."</string>
     <string name="download_sdcard_busy_dlg_title">"Minnekort utilgjengelig"</string>
-    <string name="download_sdcard_busy_dlg_msg">"Minnekortet er opptatt. For å tillatte nedlastinger, gå til Hjem &gt; Innstillinger &gt; Minnekort og telefonlagring, og fjern haken ved \\\"Bruk for USB-lagring\\\"-boksen."</string>
+    <string name="download_sdcard_busy_dlg_msg">"Minnekortet er opptatt. For å tillatte nedlastinger, gå til Hjem &gt; Innstillinger &gt; Minnekort og telefonlagring, og fjern haken ved \\\\\\\"Bruk for USB-lagring\\\\\\\"-boksen."</string>
     <string name="download_no_application">"Fant ingen applikasjon som kunne åpne denne filen."</string>
     <string name="retry">"Prøv igjen"</string>
     <string name="no_downloads">"Nedlastingsloggen er tom."</string>
@@ -257,12 +251,11 @@
     <string name="download_length_required">"Kan ikke laste ned. Klarte ikke bestemme størrelsen på filen."</string>
     <string name="download_precondition_failed">"Nedlastingen ble avbrutt. Den kan ikke fortsettes."</string>
     <string name="activity_instrumentation_test_runner">"Browser Test Runner"</string>
-    <!-- no translation found for search_google (1231765426260855357) -->
-    <skip />
-    <string name="permlab_readHistoryBookmarks">"read Browser\\\'s history and bookmarks"</string>
-    <string name="permdesc_readHistoryBookmarks">"Allows the application to read all the URLs that the Browser has visited, and all of the Browser\\\'s bookmarks."</string>
-    <string name="permlab_writeHistoryBookmarks">"write Browser\\\'s history and bookmarks"</string>
-    <string name="permdesc_writeHistoryBookmarks">"Allows an application to modify the Browser\\\'s history or bookmarks stored on your phone. Malicious applications can use this to erase or modify your Browser\\\'s data."</string>
+    <string name="search_google">"Søk på Google"</string>
+    <string name="permlab_readHistoryBookmarks">"read Browser\\\\\\\'s history and bookmarks"</string>
+    <string name="permdesc_readHistoryBookmarks">"Allows the application to read all the URLs that the Browser has visited, and all of the Browser\\\\\\\'s bookmarks."</string>
+    <string name="permlab_writeHistoryBookmarks">"write Browser\\\\\\\'s history and bookmarks"</string>
+    <string name="permdesc_writeHistoryBookmarks">"Allows an application to modify the Browser\\\\\\\'s history or bookmarks stored on your phone. Malicious applications can use this to erase or modify your Browser\\\\\\\'s data."</string>
     <string name="query_data_message">"Nettsiden under ønsker å lagre informasjon på datamaskinen ved hjelp av Gears."</string>
     <string name="location_message">"Nettsiden under ønsker å finne ut hvor du er ved hjelp av Gears."</string>
     <string name="shortcut_message">"Denne nettsiden ønsker å lage en snarvei på datamaskinen. Ønsker du å tillate dette?"</string>
@@ -290,6 +283,5 @@
     <string name="denied">"Nektet"</string>
     <string name="unrecognized_dialog_message">"Ukjent meldingstype"</string>
     <string name="default_button">"OK"</string>
-    <!-- no translation found for zoom_overview_button_text (4146579940085488881) -->
-    <skip />
+    <string name="zoom_overview_button_text">"Oversikt"</string>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6a24b08..912ed44 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -641,20 +641,43 @@
         can use this to erase or modify your Browser\'s data.</string>
 
     <!-- Gears Dialogs -->
-    <string name="query_data_message">The Web site below wants to store information on your computer using Gears.</string>
-    <string name="location_message">The Web site below wants to access information about your location using Gears.</string>
-    <string name="shortcut_message">This Web site wants to create a shortcut on your computer. Do you want to allow this?</string>
+    <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="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>
+    <string name="shortcut_message">This web site would like to create a shortcut to this page on your home screen.</string>
     <string name="settings_message">The table below shows the permissions you have granted to each site that has attempted to use Gears.</string>
-    <string name="filepicker_message">Gears File Picker</string>
+    <string name="filepicker_message">File Picker</string>
+    <string name="image_message">Choosen Image</string>
 
     <string name="settings_title">Gears settings</string>
     <string name="privacy_policy">Read the site\'s privacy policy to see how your location will be used.</string>
+    <string name="settings_storage_title">Allow Local Storage</string>
+    <string name="settings_storage_subtitle_on">This site can save information to your phone</string>
+    <string name="settings_storage_subtitle_off">This site cannot save information to your phone</string>
 
-    <string name="permission_button_alwaysdeny">Never allow this site</string>
-    <string name="permission_button_allow">Allow</string>
-    <string name="permission_button_deny">Deny</string>
+    <string name="settings_location_title">Allow Location Detection</string>
+    <string name="settings_location_subtitle_on">This site can read your current location</string>
+    <string name="settings_location_subtitle_off">This site cannot read your current location</string>
 
-    <string name="shortcut_button_alwaysdeny">Never allow this shortcut</string>
+    <string name="settings_remove_site">Remove this site from Gears</string>
+    <string name="settings_empty">No permissions set</string>
+
+    <string name="settings_confirmation_remove_title">Remove this site</string>
+    <string name="settings_confirmation_remove">All permissions will be canceled, and any data stored on your phone by the site will be deleted</string>
+
+    <string name="storage_notification">This site will store information on this phone.\n Change this setting in:\n Settings->Gears Settings</string>
+    <string name="storage_notification_alwaysdeny">This site will never store information on this phone.\n Change this setting in:\n Settings->Gears Settings</string>
+    <string name="location_notification">This site will now access your location.\n Change this setting in:\n Settings->Gears Settings</string>
+    <string name="location_notification_alwaysdeny">This site will never access your location.\n Change this setting in:\n Settings->Gears Settings</string>
+    <string name="shortcut_notification">Shortcut created</string>
+
+    <string name="permission_button_alwaysdeny">Never Allow</string>
+    <string name="permission_button_allow">OK</string>
+    <string name="permission_button_deny">Cancel</string>
+
+    <string name="shortcut_button_alwaysdeny">Never Allow</string>
     <string name="shortcut_button_allow">OK</string>
     <string name="shortcut_button_deny">Cancel</string>
 
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 1a5ee1f..f20220f 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -32,7 +32,7 @@
         <item name="android:textAppearance">?android:attr/textAppearanceLargeInverse</item>
         <item name="android:completionThreshold">2</item>
         <item name="android:dropDownSelector">@android:drawable/list_selector_background</item>
-        <item name="android:popupBackground">@android:drawable/editbox_dropdown_dark_frame</item>
+        <item name="android:popupBackground">@android:drawable/spinner_dropdown_background</item>
     </style>
 
     <style name="gears_button">
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index b6942d2..d8fd3fa 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -120,6 +120,7 @@
 import android.widget.LinearLayout;
 import android.widget.TextView;
 import android.widget.Toast;
+import android.widget.ZoomRingController;
 
 import com.google.android.googleapps.IGoogleLoginService;
 import com.google.android.googlelogin.GoogleLoginServiceConstants;
@@ -131,6 +132,7 @@
 import java.io.InputStream;
 import java.io.IOException;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.net.URLEncoder;
 import java.text.ParseException;
@@ -743,6 +745,9 @@
                     }
                 }
             };
+            
+        // Show a tutorial for the new zoom interaction (the method ensure we only show it once)
+        ZoomRingController.showZoomTutorialOnce(this);
     }
 
     @Override
@@ -3389,10 +3394,44 @@
             return;
         }
 
+        // java.net.URI is a lot stricter than KURL so we have to undo
+        // KURL's percent-encoding and redo the encoding using java.net.URI.
+        URI uri = null;
+        try {
+            // Undo the percent-encoding that KURL may have done.
+            String newUrl = new String(URLUtil.decode(url.getBytes()));
+            // Parse the url into pieces
+            WebAddress w = new WebAddress(newUrl);
+            String frag = null;
+            String query = null;
+            String path = w.mPath;
+            // Break the path into path, query, and fragment
+            if (path.length() > 0) {
+                // Strip the fragment
+                int idx = path.lastIndexOf('#');
+                if (idx != -1) {
+                    frag = path.substring(idx + 1);
+                    path = path.substring(0, idx);
+                }
+                idx = path.lastIndexOf('?');
+                if (idx != -1) {
+                    query = path.substring(idx + 1);
+                    path = path.substring(0, idx);
+                }
+            }
+            uri = new URI(w.mScheme, w.mAuthInfo, w.mHost, w.mPort, path,
+                    query, frag);
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Could not parse url for download: " + url, e);
+            return;
+        }
+
+        // XXX: Have to use the old url since the cookies were stored using the
+        // old percent-encoded url.
         String cookies = CookieManager.getInstance().getCookie(url);
 
         ContentValues values = new ContentValues();
-        values.put(Downloads.URI, url);
+        values.put(Downloads.URI, uri.toString());
         values.put(Downloads.COOKIE_DATA, cookies);
         values.put(Downloads.USER_AGENT, userAgent);
         values.put(Downloads.NOTIFICATION_PACKAGE,
@@ -3402,7 +3441,7 @@
         values.put(Downloads.VISIBILITY, Downloads.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
         values.put(Downloads.MIMETYPE, mimetype);
         values.put(Downloads.FILENAME_HINT, filename);
-        values.put(Downloads.DESCRIPTION, Uri.parse(url).getHost());
+        values.put(Downloads.DESCRIPTION, uri.getHost());
         if (contentLength > 0) {
             values.put(Downloads.TOTAL_BYTES, contentLength);
         }
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 5038a4e..06ccf01 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -334,6 +334,8 @@
     
     public void toggleDebugSettings() {
         showDebugSettings = !showDebugSettings;
+        navDump = showDebugSettings;
+        update();
     }
 
     /**
diff --git a/src/com/android/browser/FakeWebView.java b/src/com/android/browser/FakeWebView.java
index 7997672..633b799 100644
--- a/src/com/android/browser/FakeWebView.java
+++ b/src/com/android/browser/FakeWebView.java
@@ -34,10 +34,12 @@
  */
 public class FakeWebView extends ImageView {
     private TabControl.Tab mTab;
+    private Picture        mPicture;
     private boolean        mUsesResource;
 
     private class Listener implements WebView.PictureListener {
         public void onNewPicture(WebView view, Picture p) {
+            FakeWebView.this.mPicture = p;
             FakeWebView.this.invalidate();
         }
     };
@@ -69,13 +71,12 @@
             if (mTab != null) {
                 final WebView w = mTab.getTopWindow();
                 if (w != null) {
-                    Picture p = w.capturePicture();
-                    if (p != null) {
+                    if (mPicture != null) {
                         canvas.save();
                         float scale = getWidth() * w.getScale() / w.getWidth();
                         canvas.scale(scale, scale);
                         canvas.translate(-w.getScrollX(), -w.getScrollY());
-                        canvas.drawPicture(p);
+                        canvas.drawPicture(mPicture);
                         canvas.restore();
                     }
                 }
@@ -99,10 +100,12 @@
         mTab = t;
         if (t != null && t.getWebView() != null) {
             Listener l = new Listener();
-            t.getWebView().setPictureListener(l);
             if (t.getSubWebView() != null) {
                 t.getSubWebView().setPictureListener(l);
+            } else {
+                t.getWebView().setPictureListener(l);
             }
+            mPicture = mTab.getTopWindow().capturePicture();
         }
     }
 }
diff --git a/src/com/android/browser/GearsBaseDialog.java b/src/com/android/browser/GearsBaseDialog.java
index afd0dd2..3379537 100644
--- a/src/com/android/browser/GearsBaseDialog.java
+++ b/src/com/android/browser/GearsBaseDialog.java
@@ -17,6 +17,7 @@
 package com.android.browser;
 
 import android.app.Activity;
+import android.app.Dialog;
 import android.content.Context;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
@@ -191,14 +192,14 @@
                   public void onClick(View v) {
                     mHandler.sendEmptyMessage(ALWAYS_DENY);
                   }
-                }, true, false);
+                });
 
     setupButton(R.id.button_allow, allowRsc,
                 new Button.OnClickListener() {
                   public void onClick(View v) {
                     mHandler.sendEmptyMessage(ALLOW);
                   }
-                }, false, true);
+                });
 
     setupButton(R.id.button_deny, denyRsc,
                 new Button.OnClickListener() {
@@ -249,6 +250,67 @@
   }
 
   /**
+   * Utility method to hide a view.
+   */
+  void hideView(View v, int rsc) {
+    if (rsc == 0) {
+      return;
+    }
+    View view = v.findViewById(rsc);
+    if (view != null) {
+      view.setVisibility(View.GONE);
+    }
+  }
+
+  /**
+   * Utility method to show a view.
+   */
+  void showView(View v, int rsc) {
+    if (rsc == 0) {
+      return;
+    }
+    View view = v.findViewById(rsc);
+    if (view != null) {
+      view.setVisibility(View.VISIBLE);
+    }
+  }
+
+  /**
+   * Utility method to set a text.
+   */
+  void setText(View v, int rsc, CharSequence text) {
+    if (rsc == 0) {
+      return;
+    }
+    View view = v.findViewById(rsc);
+    if (view != null) {
+      TextView textView = (TextView) view;
+      textView.setText(text);
+      textView.setVisibility(View.VISIBLE);
+    }
+  }
+
+  /**
+   * Utility method to set a text.
+   */
+  void setText(View v, int rsc, int txtRsc) {
+    if (rsc == 0) {
+      return;
+    }
+    View view = v.findViewById(rsc);
+    if (view != null) {
+      TextView textView = (TextView) view;
+      if (txtRsc == 0) {
+        textView.setVisibility(View.GONE);
+      } else {
+        CharSequence text = getString(txtRsc);
+        textView.setText(text);
+        textView.setVisibility(View.VISIBLE);
+      }
+    }
+  }
+
+  /**
    * Utility class to download an icon in the background.
    * Once done ask the UI thread to update the icon.
    */
@@ -360,7 +422,7 @@
    */
   public void setupDialog(TextView message, ImageView icon) {
     message.setText(R.string.unrecognized_dialog_message);
-    icon.setImageResource(R.drawable.gears_icon_48x48);
+    icon.setImageResource(R.drawable.ic_dialog_menu_generic);
     message.setVisibility(View.VISIBLE);
   }
 
@@ -373,4 +435,29 @@
     setupDialog();
   }
 
+  /**
+   * Method called when the back button is pressed,
+   * allowing the dialog to intercept the default behaviour.
+   */
+  public boolean handleBackButton() {
+    return false;
+  }
+
+  /**
+   * Returns the resource string of the notification displayed
+   * after the dialog. By default, does not return one.
+   */
+  public int notification() {
+    return 0;
+  }
+
+  /**
+   * If a secondary dialog (e.g. a confirmation dialog) is created,
+   * GearsNativeDialog will call this method.
+   */
+  public Dialog onCreateDialog(int id) {
+    // This should be redefined by subclasses as needed.
+    return null;
+  }
+
 }
diff --git a/src/com/android/browser/GearsFilePickerDialog.java b/src/com/android/browser/GearsFilePickerDialog.java
index d84a970..0bb28d4 100644
--- a/src/com/android/browser/GearsFilePickerDialog.java
+++ b/src/com/android/browser/GearsFilePickerDialog.java
@@ -155,7 +155,7 @@
   public void setupDialog(TextView message, ImageView icon) {
     message.setText(R.string.filepicker_message);
     message.setTextSize(24);
-    icon.setImageResource(R.drawable.gears_icon_32x32);
+    icon.setImageResource(R.drawable.ic_dialog_menu_generic);
   }
 
   public boolean onTouch(View v, MotionEvent event) {
@@ -684,7 +684,7 @@
             int color = getResources().getColor(R.color.icon_selection);
             v.setBackgroundColor(color);
           } else {
-            v.setBackgroundColor(Color.WHITE);
+            v.setBackgroundColor(android.R.color.background_dark);
           }
           return false;
         }
@@ -696,7 +696,7 @@
         int color = getResources().getColor(R.color.icon_selection);
         cell.setBackgroundColor(color);
       } else {
-        cell.setBackgroundColor(Color.WHITE);
+        cell.setBackgroundColor(android.R.color.background_dark);
       }
       Bitmap bmp = elem.getIcon(position);
       if (bmp != null) {
diff --git a/src/com/android/browser/GearsNativeDialog.java b/src/com/android/browser/GearsNativeDialog.java
index c8ae741..c72ad8e 100644
--- a/src/com/android/browser/GearsNativeDialog.java
+++ b/src/com/android/browser/GearsNativeDialog.java
@@ -17,6 +17,7 @@
 package com.android.browser;
 
 import android.app.Activity;
+import android.app.Dialog;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
@@ -24,9 +25,11 @@
 import android.os.Message;
 import android.util.Config;
 import android.util.Log;
+import android.view.Gravity;
 import android.view.KeyEvent;
 import android.view.Window;
 import android.widget.BaseAdapter;
+import android.widget.Toast;
 
 import android.webkit.gears.NativeDialog;
 
@@ -90,10 +93,15 @@
 
   @Override
   public void onCreate(Bundle icicle) {
-    super.onCreate(icicle);
-    requestWindowFeature(Window.FEATURE_NO_TITLE);
-    setContentView(R.layout.gears_dialog);
     getArguments();
+    if (mDialogType == SETTINGS_DIALOG) {
+      setTheme(android.R.style.Theme);
+    }
+    super.onCreate(icicle);
+    if (mDialogType != SETTINGS_DIALOG) {
+      requestWindowFeature(Window.FEATURE_NO_TITLE);
+      setContentView(R.layout.gears_dialog);
+    }
 
     switch (mDialogType) {
       case SETTINGS_DIALOG:
@@ -185,6 +193,9 @@
         + "customMessage: \"Press the button to enable my "
         + "application to run offline!\" };";
 
+    String argumentsPermissions2 = "{ locale: \"en-US\", "
+        + "origin: \"http://www.google.com\", dialogType: \"localData\" };";
+
     String argumentsLocation = "{ locale: \"en-US\", "
         + "origin: \"http://www.google.com\", dialogType: \"locationData\","
         + "customIcon: \"http://google-gears.googlecode.com/"
@@ -195,8 +206,8 @@
 
     String argumentsSettings = "{ locale: \"en-US\", permissions: [ { "
         + "name: \"http://www.google.com\", "
-        + "localStorage: { permissionState: 1 }, "
-        + "locationData: { permissionState: 0 } }, "
+        + "localStorage: { permissionState: 0 }, "
+        + "locationData: { permissionState: 1 } }, "
         + "{ name: \"http://www.aaronboodman.com\", "
         + "localStorage: { permissionState: 1 }, "
         + "locationData: { permissionState: 2 } }, "
@@ -204,6 +215,12 @@
         + "localStorage: { permissionState: 2 }, "
         + "locationData: { permissionState: 2 } } ] }";
 
+    String argumentsFilePicker = "{ \"cameraMode\" : \"OFF\", \"filters\""
+        + ": [ \"text/html\", \".txt\" ], \"mode\" : \"MULTIPLE_FILES\" }\"";
+
+    String argumentsFilePicker2 = "{ \"cameraMode\" : \"OFF\", \"filters\""
+        + ": [ \"text/html\", \".txt\" ], \"mode\" : \"SINGLE_FILE\" }\"";
+
     switch (mDialogType) {
       case SHORTCUT_DIALOG:
         mDialogArguments = argumentsShortcuts;
@@ -216,6 +233,9 @@
         break;
       case SETTINGS_DIALOG:
         mDialogArguments = argumentsSettings;
+        break;
+      case FILEPICKER_DIALOG:
+        mDialogArguments = argumentsFilePicker2;
     }
   }
 
@@ -232,6 +252,14 @@
     NativeDialog.closeDialog(ret);
     notifyEndOfDialog();
     finish();
+
+    // If the dialog sets a notification, we display it.
+    int notification = dialog.notification();
+    if (notification != 0) {
+      Toast toast = Toast.makeText(this, notification, Toast.LENGTH_LONG);
+      toast.setGravity(Gravity.BOTTOM, 0, 0);
+      toast.show();
+    }
   }
 
   @Override
@@ -265,10 +293,26 @@
    * NativeDialog that we are done.
    */
   public boolean dispatchKeyEvent(KeyEvent event) {
-    if (event.getKeyCode() ==  KeyEvent.KEYCODE_BACK && event.isDown()) {
-      closeDialog(GearsBaseDialog.CANCEL);
+    if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK)
+      && (event.getAction() == KeyEvent.ACTION_DOWN)) {
+      if (!dialog.handleBackButton()) {
+        // if the dialog doesn't do anything with the back button
+        closeDialog(GearsBaseDialog.CANCEL);
+      }
+      return true; // event consumed
     }
     return super.dispatchKeyEvent(event);
   }
 
+  /**
+   * If the dialog call showDialog() on ourself, we let
+   * it handle the creation of this secondary dialog.
+   * It is used in GearsSettingsDialog, to create the confirmation
+   * dialog when the user click on "Remove this site from Gears"
+   */
+  @Override
+  protected Dialog onCreateDialog(int id) {
+    return dialog.onCreateDialog(id);
+  }
+
 }
diff --git a/src/com/android/browser/GearsPermissions.java b/src/com/android/browser/GearsPermissions.java
index cd46324..e48e045 100644
--- a/src/com/android/browser/GearsPermissions.java
+++ b/src/com/android/browser/GearsPermissions.java
@@ -49,37 +49,37 @@
     public static final int PERMISSION_DENIED = 2;
 
     String mName;
-    int mRowRsc;
-    int mAllowedButtonRsc;
-    int mDeniedButtonRsc;
+    int mTitleRsc;
+    int mSubtitleOnRsc;
+    int mSubtitleOffRsc;
 
     PermissionType(String name) {
       mName = name;
     }
 
-    public void setResources(int rowRsc, int allowedButtonRsc,
-        int deniedButtonRsc) {
-      mRowRsc = rowRsc;
-      mAllowedButtonRsc = allowedButtonRsc;
-      mDeniedButtonRsc = deniedButtonRsc;
-    }
-
-    public int getRowRsc() {
-      return mRowRsc;
-    }
-
-    public int getAllowedButtonRsc() {
-      return mAllowedButtonRsc;
-    }
-
-    public int getDeniedButtonRsc() {
-      return mDeniedButtonRsc;
+    public void setResources(int titleRsc,
+        int subtitleOnRsc, int subtitleOffRsc) {
+      mTitleRsc = titleRsc;
+      mSubtitleOnRsc = subtitleOnRsc;
+      mSubtitleOffRsc = subtitleOffRsc;
     }
 
     public String getName() {
       return mName;
     }
 
+    public int getTitleRsc() {
+      return mTitleRsc;
+    }
+
+    public int getSubtitleOnRsc() {
+      return mSubtitleOnRsc;
+    }
+
+    public int getSubtitleOffRsc() {
+      return mSubtitleOffRsc;
+    }
+
   }
 
   /**
diff --git a/src/com/android/browser/GearsPermissionsDialog.java b/src/com/android/browser/GearsPermissionsDialog.java
index b57ab0b..dbec363 100644
--- a/src/com/android/browser/GearsPermissionsDialog.java
+++ b/src/com/android/browser/GearsPermissionsDialog.java
@@ -35,6 +35,7 @@
   private static final String TAG = "GearsPermissionsDialog";
 
   private String mDialogType;
+  private int mNotification = 0;
 
   public GearsPermissionsDialog(Activity activity,
                                 Handler handler,
@@ -48,15 +49,6 @@
                  R.string.permission_button_allow,
                  R.string.permission_button_deny);
 
-    View contentBorder = findViewById(R.id.content_border);
-    if (contentBorder != null) {
-      contentBorder.setBackgroundResource(R.color.permission_border);
-    }
-    View contentBackground = findViewById(R.id.content_background);
-    if (contentBackground != null) {
-      contentBackground.setBackgroundResource(R.color.permission_background);
-    }
-
     try {
       JSONObject json = new JSONObject(mDialogArguments);
 
@@ -84,6 +76,16 @@
         downloadIcon(iconUrl);
       }
 
+      View msg = findViewById(R.id.permission_dialog_message);
+      if (msg != null) {
+        TextView dialogMessage = (TextView) msg;
+        if (mDialogType.equalsIgnoreCase(LOCAL_DATA_STRING)) {
+          dialogMessage.setText(R.string.query_data_message);
+        } else if (mDialogType.equalsIgnoreCase(LOCATION_DATA_STRING)) {
+          dialogMessage.setText(R.string.location_message);
+        }
+      }
+
     } catch (JSONException e) {
       Log.e(TAG, "JSON exception ", e);
     }
@@ -91,15 +93,11 @@
 
   public void setupDialog(TextView message, ImageView icon) {
     if (mDialogType.equalsIgnoreCase(LOCAL_DATA_STRING)) {
-      message.setText(R.string.query_data_message);
-      icon.setImageResource(R.drawable.gears_local_data);
+      message.setText(R.string.query_data_prompt);
+      icon.setImageResource(android.R.drawable.ic_popup_disk_full);
     } else if (mDialogType.equalsIgnoreCase(LOCATION_DATA_STRING)) {
-      message.setText(R.string.location_message);
-      icon.setImageResource(R.drawable.gears_location_data);
-      View privacyPolicyLabel = findViewById(R.id.privacy_policy_label);
-      if (privacyPolicyLabel != null) {
-        privacyPolicyLabel.setVisibility(View.VISIBLE);
-      }
+      message.setText(R.string.location_prompt);
+      icon.setImageResource(R.drawable.ic_dialog_menu_generic);
     }
   }
 
@@ -108,9 +106,19 @@
     switch (closingType) {
       case ALWAYS_DENY:
         ret = "{\"allow\": false, \"permanently\": true }";
+        if (mDialogType.equalsIgnoreCase(LOCAL_DATA_STRING)) {
+          mNotification = R.string.storage_notification_alwaysdeny;
+        } else if (mDialogType.equalsIgnoreCase(LOCATION_DATA_STRING)) {
+          mNotification = R.string.location_notification_alwaysdeny;
+        }
         break;
       case ALLOW:
         ret = "{\"allow\": true, \"permanently\": true }";
+        if (mDialogType.equalsIgnoreCase(LOCAL_DATA_STRING)) {
+          mNotification = R.string.storage_notification;
+        } else if (mDialogType.equalsIgnoreCase(LOCATION_DATA_STRING)) {
+          mNotification = R.string.location_notification;
+        }
         break;
       case DENY:
         ret = "{\"allow\": false, \"permanently\": false }";
@@ -119,4 +127,7 @@
     return ret;
   }
 
+  public int notification() {
+    return mNotification;
+  }
 }
diff --git a/src/com/android/browser/GearsSettingsDialog.java b/src/com/android/browser/GearsSettingsDialog.java
index 56a1d8d..5ea2342 100644
--- a/src/com/android/browser/GearsSettingsDialog.java
+++ b/src/com/android/browser/GearsSettingsDialog.java
@@ -17,14 +17,21 @@
 package com.android.browser;
 
 import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.os.Handler;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.BaseAdapter;
 import android.widget.Button;
+import android.widget.CheckBox;
 import android.widget.CompoundButton;
 import android.widget.ImageView;
 import android.widget.ListAdapter;
@@ -33,6 +40,7 @@
 import android.widget.TextView;
 
 import com.android.browser.GearsPermissions.OriginPermissions;
+import com.android.browser.GearsPermissions.Permission;
 import com.android.browser.GearsPermissions.PermissionsChangesListener;
 import com.android.browser.GearsPermissions.PermissionType;
 
@@ -55,6 +63,7 @@
   private Vector<OriginPermissions> mCurrentPermissions = null;
 
   private Vector<PermissionType> mPermissions;
+  private static final int CONFIRMATION_REMOVE_DIALOG = 1;
 
   // We declare the permissions globally to simplify the code
   private final PermissionType LOCAL_STORAGE =
@@ -64,23 +73,23 @@
 
   private boolean mChanges = false;
 
+  SettingsAdapter mListAdapter;
 
   public GearsSettingsDialog(Activity activity,
                              Handler handler,
                              String arguments) {
     super (activity, handler, arguments);
+    activity.setContentView(R.layout.gears_settings);
   }
 
   public void setup() {
     // First let's add the permissions' resources
-    LOCAL_STORAGE.setResources(R.id.local_storage_choice,
-       R.id.local_storage_allowed,
-       R.id.local_storage_denied);
-
-    LOCATION_DATA.setResources(R.id.location_data_choice,
-       R.id.location_data_allowed,
-       R.id.location_data_denied);
-
+    LOCAL_STORAGE.setResources(R.string.settings_storage_title,
+                               R.string.settings_storage_subtitle_on,
+                               R.string.settings_storage_subtitle_off);
+    LOCATION_DATA.setResources(R.string.settings_location_title,
+                               R.string.settings_location_subtitle_on,
+                               R.string.settings_location_subtitle_off);
     // add the permissions to the list of permissions.
     mPermissions = new Vector<PermissionType>();
     mPermissions.add(LOCAL_STORAGE);
@@ -88,25 +97,7 @@
     OriginPermissions.setListener(this);
 
 
-    inflate(R.layout.gears_dialog_settings, R.id.panel_content);
     setupDialog();
-    setupButtons(0,
-                 R.string.settings_button_allow,
-                 R.string.settings_button_deny);
-
-    // by default disable the allow button (it will get enabled if
-    // something is changed by the user)
-    View buttonView = findViewById(R.id.button_allow);
-    if (buttonView != null) {
-      Button button = (Button) buttonView;
-      button.setEnabled(false);
-    }
-
-    View gearsVersionView = findViewById(R.id.gears_version);
-    if (gearsVersionView != null) {
-      TextView gearsVersion = (TextView) gearsVersionView;
-      gearsVersion.setText(mGearsVersion);
-    }
 
     // We manage the permissions using three vectors, mSitesPermissions,
     // mOriginalPermissions and mCurrentPermissions.
@@ -165,32 +156,23 @@
     View listView = findViewById(R.id.sites_list);
     if (listView != null) {
       ListView list = (ListView) listView;
-      list.setAdapter(new SettingsAdapter(mActivity, mSitesPermissions));
+      mListAdapter = new SettingsAdapter(mActivity, mSitesPermissions);
+      list.setAdapter(mListAdapter);
       list.setScrollBarStyle(android.view.View.SCROLLBARS_OUTSIDE_INSET);
+      list.setOnItemClickListener(mListAdapter);
     }
     if (mDebug) {
       printPermissions();
     }
   }
 
+  private void setMainTitle() {
+    String windowTitle = mActivity.getString(R.string.pref_extras_gears_settings);
+    mActivity.setTitle(windowTitle);
+  }
+
   public void setupDialog() {
-    View dialogTitleView = findViewById(R.id.dialog_title);
-    if (dialogTitleView != null) {
-      TextView dialogTitle = (TextView) dialogTitleView;
-      dialogTitle.setText(R.string.settings_title);
-      dialogTitle.setVisibility(View.VISIBLE);
-    }
-    View dialogSubtitleView = findViewById(R.id.dialog_subtitle);
-    if (dialogSubtitleView != null) {
-      TextView dialogSubtitle = (TextView) dialogSubtitleView;
-      dialogSubtitle.setText(R.string.settings_message);
-      dialogSubtitle.setVisibility(View.VISIBLE);
-    }
-    View iconView = findViewById(R.id.icon);
-    if (iconView != null) {
-      ImageView icon = (ImageView) iconView;
-      icon.setImageResource(R.drawable.gears_icon_32x32);
-    }
+    setMainTitle();
   }
 
   /**
@@ -198,164 +180,95 @@
    */
   public boolean setPermission(PermissionType type, int perm) {
     if (mChanges == false) {
-      signalChanges();
+      mChanges = true;
     }
     return mChanges;
   }
 
-  /**
-   * Controller class for binding the model (OriginPermissions) with
-   * the UI.
-   */
-  class PermissionController {
-    final static int ALLOWED_BUTTON = 1;
-    final static int DENIED_BUTTON = 2;
-    private int mButtonType;
-    private PermissionType mPermissionType;
-    private OriginPermissions mPermissions;
-
-    PermissionController(PermissionType permissionType, int buttonType,
-        OriginPermissions permissions) {
-      mPermissionType = permissionType;
-      mButtonType = buttonType;
-      mPermissions = permissions;
-    }
-
-    public boolean isChecked() {
-      boolean checked = false;
-
-      switch (mButtonType) {
-        case ALLOWED_BUTTON:
-          if (mPermissions.getPermission(mPermissionType) ==
-              PermissionType.PERMISSION_ALLOWED) {
-            checked = true;
-          } break;
-        case DENIED_BUTTON:
-          if (mPermissions.getPermission(mPermissionType) ==
-              PermissionType.PERMISSION_DENIED) {
-            checked = true;
-          }
-      }
-      return checked;
-    }
-
-    public String print() {
-        return printType() + " for " + mPermissions.getOrigin();
-    }
-
-    private String printType() {
-      switch (mButtonType) {
-        case ALLOWED_BUTTON:
-          return "ALLOWED_BUTTON";
-        case DENIED_BUTTON:
-          return "DENIED_BUTTON";
-      }
-      return "UNKNOWN BUTTON";
-    }
-
-    public void changed(boolean isChecked) {
-      if (isChecked == isChecked()) {
-        return; // already set
-      }
-
-      switch (mButtonType) {
-        case ALLOWED_BUTTON:
-          mPermissions.setPermission(mPermissionType,
-              PermissionType.PERMISSION_ALLOWED);
-          break;
-        case DENIED_BUTTON:
-          mPermissions.setPermission(mPermissionType,
-              PermissionType.PERMISSION_DENIED);
-          break;
-      }
-    }
+  public boolean handleBackButton() {
+    return mListAdapter.backButtonPressed();
   }
 
-
+  /**
+   * We use this to create a confirmation dialog when the user
+   * clicks on "remove this site from gears"
+   */
+  public Dialog onCreateDialog(int id) {
+    return new AlertDialog.Builder(mActivity)
+        .setTitle(R.string.settings_confirmation_remove_title)
+        .setMessage(R.string.settings_confirmation_remove)
+        .setPositiveButton(android.R.string.ok,
+                           new AlertDialog.OnClickListener() {
+          public void onClick(DialogInterface dlg, int which) {
+            mListAdapter.removeCurrentSite();
+          }
+        })
+        .setNegativeButton(android.R.string.cancel, null)
+        .setIcon(android.R.drawable.ic_dialog_alert)
+        .create();
+  }
 
   /**
    * Adapter class for the list view in the settings dialog
    *
-   * Every row in the settings dialog display the permissions
-   * for a given origin. For every type of permission
-   * (location, local data...) there is two radio buttons to
-   * authorize or deny the permission.
-   * A remove button is also present to let the user remove
-   * all the authorization of an origin in one step.
+   * We first display a list of all the origins (sites), or
+   * a message saying that no permission is set if the list is empty.
+   * When the user click on one of the origin, we then display
+   * the list of the permissions existing for that origin.
+   * Each permission can be either allowed or denied by clicking
+   * on the checkbox.
+   * The last row is a special case, allowing to remove the entire origin.
    */
-  class SettingsAdapter extends ArrayAdapter {
+  class SettingsAdapter extends BaseAdapter
+      implements AdapterView.OnItemClickListener {
     private Activity mContext;
     private List mItems;
+    private OriginPermissions mCurrentSite;
+    private Vector mCurrentPermissions;
+    private int MAX_ROW_HEIGHT = 64;
 
     SettingsAdapter(Activity context, List items) {
-      super(context, R.layout.gears_dialog_settings_row, items);
       mContext = context;
       mItems = items;
+      mCurrentSite = null;
     }
 
-    /*
-     * setup the necessary listeners for the radiobuttons
-     * When the buttons are clicked the permissions change.
-     */
-    private void createAndSetButtonListener(View buttonView,
-        OriginPermissions perms, PermissionType permissionType,
-        int buttonType) {
-      if (buttonView == null) {
-        return;
-      }
-      RadioButton button = (RadioButton) buttonView;
-
-      button.setOnCheckedChangeListener(null);
-      PermissionController p = new PermissionController(permissionType,
-          buttonType, perms);
-      button.setTag(p);
-
-      CompoundButton.OnCheckedChangeListener listener =
-          new CompoundButton.OnCheckedChangeListener() {
-        public void onCheckedChanged(CompoundButton buttonView,
-            boolean isChecked) {
-          PermissionController perm = (PermissionController)buttonView.getTag();
-          perm.changed(isChecked);
+    public int getCount() {
+      if (mCurrentSite == null) {
+        int size = mItems.size();
+        if (size == 0) {
+          return 1;
+        } else {
+          return size;
         }
-      };
-
-      button.setOnCheckedChangeListener(listener);
-
-      if (p.isChecked() != button.isChecked()) {
-        button.setChecked(p.isChecked());
       }
+      return mCurrentPermissions.size() + 1;
     }
 
-    /*
-     * setup the remove button for an origin: each row has a global
-     * remove button in addition to the radio buttons controlling the
-     * permissions.
-     */
-    private void setRemoveButton(Button button, OriginPermissions perms) {
-      Button.OnClickListener listener = new Button.OnClickListener() {
-        public void onClick(View buttonView) {
-          if (mChanges == false) {
-            signalChanges();
-          }
-          OriginPermissions perm = (OriginPermissions) buttonView.getTag();
-          perm.setPermission(LOCAL_STORAGE, PermissionType.PERMISSION_NOT_SET);
-          perm.setPermission(LOCATION_DATA, PermissionType.PERMISSION_NOT_SET);
-          mSitesPermissions.remove(perm);
+    public long getItemId(int position) {
+      return position;
+    }
 
-          View view = findViewById(R.id.sites_list);
-          if (view != null) {
-            ListView listView = (ListView) view;
-            ListAdapter listAdapter = listView.getAdapter();
-            if (listAdapter != null) {
-              SettingsAdapter settingsAdapter = (SettingsAdapter) listAdapter;
-              settingsAdapter.notifyDataSetChanged();
-            }
-          }
+    private String shortName(String url) {
+        // We remove the http and https prefix
+        if (url.startsWith("http://")) {
+          return url.substring(7);
         }
-      };
-      button.setTag(perms);
-      button.setOnClickListener(listener);
-      displayAsLink(button);
+        if (url.startsWith("https://")) {
+          return url.substring(8);
+        }
+        return url;
+    }
+
+    public Object getItem(int position) {
+      if (mCurrentSite == null) {
+        if (mItems.size() == 0) {
+          return null;
+        } else {
+          return mItems.get(position);
+        }
+      }
+      return mCurrentPermissions.get(position);
     }
 
     public View getView(int position, View convertView, ViewGroup parent) {
@@ -363,46 +276,117 @@
       if (row == null) { // no cached view, we create one
         LayoutInflater inflater = (LayoutInflater) getSystemService(
             Context.LAYOUT_INFLATER_SERVICE);
-        row = inflater.inflate(R.layout.gears_dialog_settings_row, null);
+        row = inflater.inflate(R.layout.gears_settings_row, null);
       }
+      row.setMinimumHeight(MAX_ROW_HEIGHT);
 
-      OriginPermissions perms = (OriginPermissions) mItems.get(position);
+      if (mCurrentSite == null) {
+        if (mItems.size() == 0) {
+          hideView(row, R.id.title);
+          hideView(row, R.id.subtitle);
+          hideView(row, R.id.checkbox);
+          hideView(row, R.id.icon);
+          setText(row, R.id.info, R.string.settings_empty);
+        } else {
+          hideView(row, R.id.subtitle);
+          hideView(row, R.id.info);
+          hideView(row, R.id.checkbox);
+          OriginPermissions perms = (OriginPermissions) mItems.get(position);
+          setText(row, R.id.title, shortName(perms.getOrigin()));
+          showView(row, R.id.icon);
+        }
+      } else {
+        if (position == getCount() - 1) {
+          // last position: "remove this site from gears"
+          hideView(row, R.id.subtitle);
+          hideView(row, R.id.info);
+          hideView(row, R.id.checkbox);
+          hideView(row, R.id.icon);
+          setText(row, R.id.title, R.string.settings_remove_site);
+        } else {
+          hideView(row, R.id.info);
+          hideView(row, R.id.icon);
+          showView(row, R.id.checkbox);
 
-      View nameView = row.findViewById(R.id.origin_name);
-      if (nameView != null) {
-        TextView originName = (TextView) nameView;
-        originName.setText(perms.getOrigin());
-      }
+          PermissionType type =
+              (PermissionType) mCurrentPermissions.get(position);
+          setText(row, R.id.title, type.getTitleRsc());
 
-      View removeButtonView = row.findViewById(R.id.origin_remove);
-      if (removeButtonView != null) {
-        Button removeButton = (Button) removeButtonView;
-        setRemoveButton(removeButton, perms);
-      }
-
-      for (int i = 0; i < mPermissions.size(); i++) {
-        PermissionType type = mPermissions.get(i);
-        int rowRsc = type.getRowRsc();
-        int allowedButtonRsc = type.getAllowedButtonRsc();
-        int deniedButtonRsc = type.getDeniedButtonRsc();
-
-        View rowView = row.findViewById(rowRsc);
-        if (rowView != null) {
-          int perm = perms.getPermission(type);
-          if (perm != PermissionType.PERMISSION_NOT_SET) {
-            createAndSetButtonListener(row.findViewById(allowedButtonRsc),
-                perms, type, PermissionController.ALLOWED_BUTTON);
-            createAndSetButtonListener(row.findViewById(deniedButtonRsc),
-                perms, type, PermissionController.DENIED_BUTTON);
-            rowView.setVisibility(View.VISIBLE);
-          } else {
-            rowView.setVisibility(View.GONE);
+          View checkboxView = row.findViewById(R.id.checkbox);
+          if (checkboxView != null) {
+            CheckBox checkbox = (CheckBox) checkboxView;
+            int perm = mCurrentSite.getPermission(type);
+            if (perm == PermissionType.PERMISSION_DENIED) {
+              setText(row, R.id.subtitle, type.getSubtitleOffRsc());
+              checkbox.setChecked(false);
+            } else {
+              setText(row, R.id.subtitle, type.getSubtitleOnRsc());
+              checkbox.setChecked(true);
+            }
           }
         }
       }
-
       return row;
     }
+
+    public void removeCurrentSite() {
+      mCurrentSite.setPermission(LOCAL_STORAGE,
+                                 PermissionType.PERMISSION_NOT_SET);
+      mCurrentSite.setPermission(LOCATION_DATA,
+                                 PermissionType.PERMISSION_NOT_SET);
+      mSitesPermissions.remove(mCurrentSite);
+      mCurrentSite = null;
+      setMainTitle();
+      notifyDataSetChanged();
+    }
+
+    public void onItemClick(AdapterView<?> parent,
+                            View view,
+                            int position,
+                            long id) {
+      if (mItems.size() == 0) {
+        return;
+      }
+      if (mCurrentSite == null) {
+         mCurrentSite = (OriginPermissions) mItems.get(position);
+         mCurrentPermissions = new Vector();
+         for (int i = 0; i < mPermissions.size(); i++) {
+           PermissionType type = mPermissions.get(i);
+           int perm = mCurrentSite.getPermission(type);
+           if (perm != PermissionType.PERMISSION_NOT_SET) {
+             mCurrentPermissions.add(type);
+           }
+         }
+         mContext.setTitle(shortName(mCurrentSite.getOrigin()));
+      } else {
+        if (position == getCount() - 1) { // last item (remove site)
+          // Ask the user to confirm
+          // If yes, removeCurrentSite() will be called via the dialog callback.
+          mActivity.showDialog(CONFIRMATION_REMOVE_DIALOG);
+        } else {
+          PermissionType type =
+              (PermissionType) mCurrentPermissions.get(position);
+          if (mCurrentSite.getPermission(type) ==
+              PermissionType.PERMISSION_ALLOWED) {
+            mCurrentSite.setPermission(type, PermissionType.PERMISSION_DENIED);
+          } else {
+            mCurrentSite.setPermission(type, PermissionType.PERMISSION_ALLOWED);
+          }
+        }
+      }
+      notifyDataSetChanged();
+    }
+
+    public boolean backButtonPressed() {
+      if (mCurrentSite != null) { // we intercept the back button
+        mCurrentSite = null;
+        setMainTitle();
+        notifyDataSetChanged();
+        return true;
+      }
+      return false;
+    }
+
   }
 
   /**
@@ -423,21 +407,6 @@
   }
 
   /**
-   * Utility method used by the settings dialog, signaling
-   * the user the settings have been modified.
-   * We reflect this by enabling the Allow button (disabled
-   * by default).
-   */
-  public void signalChanges() {
-    View view = findViewById(R.id.button_allow);
-    if (view != null) {
-      Button button = (Button) view;
-      button.setEnabled(true);
-    }
-    mChanges = true;
-  }
-
-  /**
    * Computes the difference between the original permissions and the
    * current ones. Returns a json-formatted string.
    * It is used by the Settings dialog.
@@ -479,18 +448,7 @@
   }
 
   public String closeDialog(int closingType) {
-    String ret = null;
-    switch (closingType) {
-      case ALWAYS_DENY:
-        ret = "{\"allow\": false }";
-        break;
-      case ALLOW:
-        ret = computeDiff(true);
-        break;
-      case DENY:
-        ret = computeDiff(false);
-        break;
-    }
+    String ret = computeDiff(mChanges);
 
     if (mDebug) {
       printPermissions();
diff --git a/src/com/android/browser/GearsShortcutDialog.java b/src/com/android/browser/GearsShortcutDialog.java
index deede12..11d936d 100644
--- a/src/com/android/browser/GearsShortcutDialog.java
+++ b/src/com/android/browser/GearsShortcutDialog.java
@@ -37,6 +37,7 @@
   private final String ICON_32 = "icon32x32";
   private final String ICON_48 = "icon48x48";
   private final String ICON_128 = "icon128x128";
+  private int mNotification = 0;
 
   public GearsShortcutDialog(Activity activity,
                              Handler handler,
@@ -45,20 +46,11 @@
   }
 
   public void setup() {
-    inflate(R.layout.gears_dialog_permission, R.id.panel_content);
+    inflate(R.layout.gears_dialog_shortcut, R.id.panel_content);
     setupButtons(R.string.shortcut_button_alwaysdeny,
                  R.string.shortcut_button_allow,
                  R.string.shortcut_button_deny);
 
-    View contentBorder = findViewById(R.id.content_border);
-    if (contentBorder != null) {
-      contentBorder.setBackgroundResource(R.color.shortcut_border);
-    }
-    View contentBackground = findViewById(R.id.content_background);
-    if (contentBackground != null) {
-      contentBackground.setBackgroundResource(R.color.shortcut_background);
-    }
-
     try {
       JSONObject json = new JSONObject(mDialogArguments);
 
@@ -69,17 +61,25 @@
 
       setupDialog();
 
-      setLabel(json, "name", R.id.origin_title);
+      setLabel(json, "name", R.id.shortcut_name);
       setLabel(json, "link", R.id.origin_subtitle);
       setLabel(json, "description", R.id.origin_message);
     } catch (JSONException e) {
       Log.e(TAG, "JSON exception", e);
     }
+
+    TextView msg = (TextView) findViewById(R.id.permission_dialog_message);
+    msg.setText(R.string.shortcut_message);
+
+    View shortcutIcon = findViewById(R.id.shortcut_panel);
+    if (shortcutIcon != null) {
+      shortcutIcon.setVisibility(View.VISIBLE);
+    }
   }
 
   public void setupDialog(TextView message, ImageView icon) {
-    message.setText(R.string.shortcut_message);
-    icon.setImageResource(R.drawable.gears_icon_48x48);
+    message.setText(R.string.shortcut_prompt);
+    icon.setImageResource(R.drawable.ic_dialog_menu_generic);
   }
 
   /**
@@ -136,6 +136,7 @@
         break;
       case ALLOW:
         ret = "{\"allow\": true, \"locations\": 0 }";
+        mNotification = R.string.shortcut_notification;
         break;
       case DENY:
         ret = null;
@@ -144,4 +145,7 @@
     return ret;
   }
 
+  public int notification() {
+    return mNotification;
+  }
 }
diff --git a/src/com/android/browser/MostVisitedActivity.java b/src/com/android/browser/MostVisitedActivity.java
index aeaf2a6..704ee27 100644
--- a/src/com/android/browser/MostVisitedActivity.java
+++ b/src/com/android/browser/MostVisitedActivity.java
@@ -31,8 +31,10 @@
 import android.widget.ListView;
 import android.widget.SimpleCursorAdapter;
 import android.widget.TextView;
+import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.view.ViewGroup.LayoutParams;
 
 import java.util.Vector;
 
@@ -47,6 +49,12 @@
         CombinedBookmarkHistoryActivity.getIconListenerSet(getContentResolver())
                 .addListener(new IconReceiver());
         setListAdapter(mAdapter);
+        ListView list = getListView();
+        LayoutInflater factory = LayoutInflater.from(this);
+        View v = factory.inflate(R.layout.empty_history, null);
+        addContentView(v, new LayoutParams(LayoutParams.FILL_PARENT,
+                LayoutParams.FILL_PARENT));
+        list.setEmptyView(v);
     }
 
     private class IconReceiver implements IconListener {