Merge "Get rid of the recovery dialog"
diff --git a/res/menu/snapshot_go_live.xml b/res/menu/snapshot_go_live.xml
new file mode 100644
index 0000000..aa6b38e
--- /dev/null
+++ b/res/menu/snapshot_go_live.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:id="@+id/snapshot_go_live"
+        android:title="@string/snapshot_go_live" />
+</menu>
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8ec35c9..b5de632 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -90,7 +90,13 @@
     <string name="ssl_expired">This certificate has expired.</string>
     <!-- Message in an SSL Error dialog -->
     <string name="ssl_not_yet_valid">This certificate is not valid yet.</string>
-    
+    <!-- Message in an SSL Error dialog -->
+    <string name="ssl_date_invalid">This certificate has an invalid date.</string>
+    <!-- Message in an SSL Error dialog -->
+    <string name="ssl_invalid">This certificate is invalid.</string>
+    <!-- Message in an SSL Error dialog -->
+    <string name="ssl_unknown">Unknown certificate error.</string>
+
     <!-- Toast informing the user that loading has stopped for the current page. -->
     <string name="stopping">Stopping\u2026</string>
     <!-- Menu item to stop the current page from loading. -->
@@ -567,6 +573,8 @@
     <!-- Do not tranlsate.  Development option -->
     <string name="pref_development_hardware_accel" translatable="false">Enable OpenGL Rendering</string>
     <!-- Do not tranlsate.  Development option -->
+    <string name="pref_development_hardware_accel_skia" translatable="false">Enable HW Accelerated Skia</string>
+    <!-- Do not tranlsate.  Development option -->
     <string name="pref_development_visual_indicator" translatable="false">Enable Visual Indicator</string>
     <!-- Do not tranlsate.  Development option -->
     <string name="js_engine_flags" translatable="false">Set JS flags</string>
@@ -1002,4 +1010,6 @@
     <string name="empty_snapshots_folder">There are no saved pages.</string>
     <!-- Menu option to delete the currently selected saved page [CHAR LIMIT=50] -->
     <string name="remove_snapshot">Delete saved page</string>
+    <!-- Popup menu option to load the live version of a saved page [CHAR LIMIT=20] -->
+    <string name="snapshot_go_live">Go live</string>
 </resources>
diff --git a/res/xml/debug_preferences.xml b/res/xml/debug_preferences.xml
index 1fc4f4c..2d15ab2 100644
--- a/res/xml/debug_preferences.xml
+++ b/res/xml/debug_preferences.xml
@@ -22,6 +22,11 @@
         android:defaultValue="true"
         android:title="@string/pref_development_hardware_accel" />
 
+    <CheckBoxPreference
+        android:key="enable_hardware_accel_skia"
+        android:defaultValue="false"
+        android:title="@string/pref_development_hardware_accel_skia" />
+
     <ListPreference
         android:key="user_agent"
         android:title="@string/pref_development_uastring"
@@ -29,13 +34,13 @@
         android:entryValues="@array/pref_development_ua_values"
         android:defaultValue="0"/>
 
-    <!-- The javascript console is enabled by default when the user has
-         also enabled debug mode by navigating to about:debug. -->
     <CheckBoxPreference
         android:key="enable_visual_indicator"
         android:defaultValue="false"
         android:title="@string/pref_development_visual_indicator" />
 
+    <!-- The javascript console is enabled by default when the user has
+         also enabled debug mode by navigating to about:debug. -->
     <CheckBoxPreference
         android:key="javascript_console"
         android:defaultValue="true"
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index 39abf33..cb86c42 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -224,6 +224,7 @@
         settings.setJavaScriptEnabled(enableJavascript());
         settings.setLightTouchEnabled(enableLightTouch());
         settings.setNavDump(enableNavDump());
+        settings.setHardwareAccelSkiaEnabled(isSkiaHardwareAccelerated());
         settings.setShowVisualIndicator(enableVisualIndicator());
         settings.setDefaultTextEncodingName(getDefaultTextEncoding());
         settings.setDefaultZoom(getDefaultZoom());
@@ -629,6 +630,13 @@
         return mPrefs.getBoolean(PREF_ENABLE_HARDWARE_ACCEL, true);
     }
 
+    public boolean isSkiaHardwareAccelerated() {
+        if (!isDebugEnabled()) {
+            return false;
+        }
+        return mPrefs.getBoolean(PREF_ENABLE_HARDWARE_ACCEL_SKIA, false);
+    }
+
     public int getUserAgent() {
         if (!isDebugEnabled()) {
             return 0;
diff --git a/src/com/android/browser/GoogleAccountLogin.java b/src/com/android/browser/GoogleAccountLogin.java
index 3896560..2bd3c8c 100644
--- a/src/com/android/browser/GoogleAccountLogin.java
+++ b/src/com/android/browser/GoogleAccountLogin.java
@@ -67,6 +67,7 @@
     private String mLsid;
     private int mState;  // {NONE(0), SID(1), LSID(2)}
     private boolean mTokensInvalidated;
+    private String mUserAgent;
 
     private GoogleAccountLogin(Activity activity, Account account,
             Runnable runnable) {
@@ -74,6 +75,7 @@
         mAccount = account;
         mWebView = new WebView(mActivity);
         mRunnable = runnable;
+        mUserAgent = mWebView.getSettings().getUserAgentString();
 
         // XXX: Doing pre-login causes onResume to skip calling
         // resumeWebViewTimers. So to avoid problems with timers not running, we
@@ -106,17 +108,8 @@
                 .appendQueryParameter("SID", mSid)
                 .appendQueryParameter("LSID", mLsid)
                 .build().toString();
-        // Check mRunnable to see if the request has been canceled.  Otherwise
-        // we might access a destroyed WebView.
-        String ua = null;
-        synchronized (this) {
-            if (mRunnable == null) {
-                return;
-            }
-            ua = mWebView.getSettings().getUserAgentString();
-        }
         // Intentionally not using Proxy.
-        AndroidHttpClient client = AndroidHttpClient.newInstance(ua);
+        AndroidHttpClient client = AndroidHttpClient.newInstance(mUserAgent);
         HttpPost request = new HttpPost(url);
 
         String result = null;
diff --git a/src/com/android/browser/PageDialogsHandler.java b/src/com/android/browser/PageDialogsHandler.java
index 015a9bb..3f64758 100644
--- a/src/com/android/browser/PageDialogsHandler.java
+++ b/src/com/android/browser/PageDialogsHandler.java
@@ -306,32 +306,23 @@
         final LinearLayout placeholder =
                 (LinearLayout)certificateView.findViewById(com.android.internal.R.id.placeholder);
 
+        LinearLayout ll = (LinearLayout)factory.inflate(R.layout.ssl_warning, placeholder);
+        TextView textView = (TextView)ll.findViewById(R.id.warning);
+
         if (error.hasError(SslError.SSL_UNTRUSTED)) {
-            LinearLayout ll = (LinearLayout)factory
-                .inflate(R.layout.ssl_warning, placeholder);
-            ((TextView)ll.findViewById(R.id.warning))
-                .setText(R.string.ssl_untrusted);
-        }
-
-        if (error.hasError(SslError.SSL_IDMISMATCH)) {
-            LinearLayout ll = (LinearLayout)factory
-                .inflate(R.layout.ssl_warning, placeholder);
-            ((TextView)ll.findViewById(R.id.warning))
-                .setText(R.string.ssl_mismatch);
-        }
-
-        if (error.hasError(SslError.SSL_EXPIRED)) {
-            LinearLayout ll = (LinearLayout)factory
-                .inflate(R.layout.ssl_warning, placeholder);
-            ((TextView)ll.findViewById(R.id.warning))
-                .setText(R.string.ssl_expired);
-        }
-
-        if (error.hasError(SslError.SSL_NOTYETVALID)) {
-            LinearLayout ll = (LinearLayout)factory
-                .inflate(R.layout.ssl_warning, placeholder);
-            ((TextView)ll.findViewById(R.id.warning))
-                .setText(R.string.ssl_not_yet_valid);
+            textView.setText(R.string.ssl_untrusted);
+        } else if (error.hasError(SslError.SSL_IDMISMATCH)) {
+            textView.setText(R.string.ssl_mismatch);
+        } else if (error.hasError(SslError.SSL_EXPIRED)) {
+            textView.setText(R.string.ssl_expired);
+        } else if (error.hasError(SslError.SSL_NOTYETVALID)) {
+            textView.setText(R.string.ssl_not_yet_valid);
+        } else if (error.hasError(SslError.SSL_DATE_INVALID)) {
+            textView.setText(R.string.ssl_date_invalid);
+        } else if (error.hasError(SslError.SSL_INVALID)) {
+            textView.setText(R.string.ssl_invalid);
+        } else {
+            textView.setText(R.string.ssl_unknown);
         }
 
         mSSLCertificateOnErrorHandler = handler;
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index ce8ec9f..65218e5 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -48,6 +48,7 @@
     // Keys for debug_preferences.xml
     // ----------------------
     static final String PREF_ENABLE_HARDWARE_ACCEL = "enable_hardware_accel";
+    static final String PREF_ENABLE_HARDWARE_ACCEL_SKIA = "enable_hardware_accel_skia";
     static final String PREF_USER_AGENT = "user_agent";
 
     // ----------------------
diff --git a/src/com/android/browser/SnapshotBar.java b/src/com/android/browser/SnapshotBar.java
index 9fb68cf..ba0bf98 100644
--- a/src/com/android/browser/SnapshotBar.java
+++ b/src/com/android/browser/SnapshotBar.java
@@ -23,16 +23,22 @@
 import android.util.AttributeSet;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.Menu;
+import android.view.MenuItem;
 import android.view.ViewConfiguration;
 import android.view.ViewPropertyAnimator;
+import android.webkit.WebView;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
+import android.widget.PopupMenu;
+import android.widget.PopupMenu.OnMenuItemClickListener;
 import android.widget.TextView;
 
 import java.text.DateFormat;
 import java.util.Date;
 
-public class SnapshotBar extends LinearLayout implements OnClickListener {
+public class SnapshotBar extends LinearLayout implements OnClickListener,
+        OnMenuItemClickListener {
 
     private static final int MSG_SHOW_TITLE = 1;
     private static final long DURATION_SHOW_DATE = BaseUi.HIDE_TITLEBAR_DELAY;
@@ -171,7 +177,11 @@
         if (mBookmarks == v) {
             mTitleBar.getUiController().bookmarksOrHistoryPicker(false);
         } else if (mGoLive == v) {
-            goLive();
+            PopupMenu popup = new PopupMenu(mContext, mGoLive);
+            Menu menu = popup.getMenu();
+            popup.getMenuInflater().inflate(R.menu.snapshot_go_live, menu);
+            popup.setOnMenuItemClickListener(this);
+            popup.show();
         } else if (mTabSwitcher == v) {
             ((PhoneUi) mTitleBar.getUi()).toggleNavScreen();
         } else if (mOverflowMenu == v) {
@@ -188,6 +198,16 @@
         }
     }
 
+    @Override
+    public boolean onMenuItemClick(MenuItem item) {
+        switch (item.getItemId()) {
+        case R.id.snapshot_go_live:
+            goLive();
+            return true;
+        }
+        return false;
+    }
+
     private void goLive() {
         Tab t = mTitleBar.getUi().getActiveTab();
         t.loadUrl(t.getUrl(), null);
diff --git a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
index 7d174ee..bd3e289 100644
--- a/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
+++ b/src/com/android/browser/widget/BookmarkThumbnailWidgetService.java
@@ -114,7 +114,7 @@
         pref.edit()
             .putLong(STATE_CURRENT_FOLDER, rootFolder)
             .putLong(STATE_ROOT_FOLDER, rootFolder)
-            .commit();
+            .apply();
     }
 
     /**