Merge change I237fc084 into eclair

* changes:
  Makes Geolocation permissions prompt pretty.
diff --git a/res/layout/browser_subwindow.xml b/res/layout/browser_subwindow.xml
index 5b00bf7..0eb9e72 100644
--- a/res/layout/browser_subwindow.xml
+++ b/res/layout/browser_subwindow.xml
@@ -30,6 +30,8 @@
             <WebView android:id="@+id/webview"
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
+                android:fadeScrollbars="true"
+                android:scrollbarStyle="outsideOverlay"
                 android:layout_weight="1" />
         </LinearLayout>
     </FrameLayout>
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index 589fff0..15f986e 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -990,6 +990,13 @@
         if (mFakeTitleBar == null && mActiveTabsPage == null
                 && !mActivityInPause && decor != null
                 && decor.getWindowToken() != null) {
+            Rect visRect = new Rect();
+            if (!mBrowserFrameLayout.getGlobalVisibleRect(visRect)) {
+                if (LOGD_ENABLED) {
+                    Log.d(LOGTAG, "showFakeTitleBar visRect failed");
+                }
+                return;
+            }
             final WebView webView = getTopWindow();
             mFakeTitleBar = new TitleBar(this);
             mFakeTitleBar.setTitleAndUrl(null, webView.getUrl());
@@ -1017,9 +1024,7 @@
             // XXX : Without providing an offset, the fake title bar will be
             // placed underneath the status bar.  Use the global visible rect
             // of mBrowserFrameLayout to determine the bottom of the status bar
-            Rect rectangle = new Rect();
-            mBrowserFrameLayout.getGlobalVisibleRect(rectangle);
-            params.y = rectangle.top;
+            params.y = visRect.top;
             // Add a holder for the title bar.  It also holds a shadow to show
             // below the title bar.
             if (mFakeTitleBarHolder == null) {
@@ -2316,12 +2321,15 @@
     private static final int CANCEL_CREDS_REQUEST    = 103;
     private static final int RELEASE_WAKELOCK        = 107;
 
+    private static final int UPDATE_BOOKMARK_THUMBNAIL = 108;
+
     // Private handler for handling javascript and saving passwords
     private Handler mHandler = new Handler() {
 
         public void handleMessage(Message msg) {
             switch (msg.what) {
                 case FOCUS_NODE_HREF:
+                {
                     String url = (String) msg.getData().get("url");
                     if (url == null || url.length() == 0) {
                         break;
@@ -2364,6 +2372,7 @@
                             break;
                     }
                     break;
+                }
 
                 case LOAD_URL:
                     loadURL(getTopWindow(), (String) msg.obj);
@@ -2382,6 +2391,13 @@
                         mWakeLock.release();
                     }
                     break;
+
+                case UPDATE_BOOKMARK_THUMBNAIL:
+                    WebView view = (WebView) msg.obj;
+                    if (view != null) {
+                        updateScreenshot(view);
+                    }
+                    break;
             }
         }
     };
@@ -2459,10 +2475,10 @@
         Canvas canvas = new Canvas(bm);
         // May need to tweak these values to determine what is the
         // best scale factor
-        int contentWidth = view.getContentWidth();
-        if (contentWidth > 0) {
-            float scaleFactor = (float) getDesiredThumbnailWidth(this)
-                    / (float) contentWidth;
+        int thumbnailWidth = thumbnail.getWidth();
+        if (thumbnailWidth > 0) {
+            float scaleFactor = (float) getDesiredThumbnailWidth(this) /
+                    (float)thumbnailWidth;
             canvas.scale(scaleFactor, scaleFactor);
         }
         thumbnail.draw(canvas);
@@ -2505,6 +2521,12 @@
             resetLockIcon(url);
             setUrlTitle(url, null);
 
+            // We've started to load a new page. If there was a pending message
+            // to save a screenshot then we will now take the new page and
+            // save an incorrect screenshot. Therefore, remove any pending
+            // thumbnail messages from the queue.
+            mHandler.removeMessages(UPDATE_BOOKMARK_THUMBNAIL);
+
             // If we start a touch icon load and then load a new page, we don't
             // want to cancel the current touch icon loader. But, we do want to
             // create a new one when the touch icon url is known.
@@ -2585,7 +2607,8 @@
             if (!mDidStopLoad) {
                 // Only update the bookmark screenshot if the user did not
                 // cancel the load early.
-                updateScreenshot(view);
+                Message updateScreenshot = Message.obtain(mHandler, UPDATE_BOOKMARK_THUMBNAIL, view);
+                mHandler.sendMessageDelayed(updateScreenshot, 500);
             }
 
             // Update the lock icon image only once we are done loading
@@ -2903,8 +2926,6 @@
             Log.e(LOGTAG, "onReceivedError " + errorCode + " " + failingUrl
                     + " " + description);
 
-                mNeedExtraScreenShot = true;
-
             // We need to reset the title after an error.
             resetTitleAndRevertLockIcon();
         }
@@ -3234,14 +3255,6 @@
                         hideFakeTitleBar();
                     }
                 }
-                if (mNeedExtraScreenShot) {
-                    // if there was an error loading this page, capture a new
-                    // screenshot to ensure that we get the correct thumbnail
-                    // as onPageFinished may have been called before the error
-                    // page was displayed.
-                    updateScreenshot(view);
-                    mNeedExtraScreenShot = false;
-                }
             } else if (!mInLoad) {
                 // onPageFinished may have already been called but a subframe
                 // is still loading and updating the progress. Reset mInLoad
@@ -4413,10 +4426,6 @@
     private boolean mPageStarted;
     private boolean mActivityInPause = true;
 
-    // If the frame fails to load, we should snap a second screenshot
-    // to ensure that we get the right thumbnail (i.e. of the error page).
-    private boolean mNeedExtraScreenShot = false;
-
     private boolean mMenuIsDown;
 
     private static boolean mInTrace;
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index 3de60a3..2f15a9c 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -1022,6 +1022,8 @@
     private WebView createNewWebView() {
         // Create a new WebView
         WebView w = new WebView(mActivity);
+        w.setScrollbarFadingEnabled(true);
+        w.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_OVERLAY);
         w.setMapTrackballToArrowKeys(false); // use trackball directly
         // Enable the built-in zoom
         w.getSettings().setBuiltInZoomControls(true);