Implement 24 hour Geolocation infobar

Remove GeolocationPermissionPromt code as now its handled by infobar.
Remove LocationButton from navigation bar.

Change-Id: Id1c78da371556d1366afe22012f3b2efff803a39
diff --git a/res/layout-sw600dp/title_bar_nav.xml b/res/layout-sw600dp/title_bar_nav.xml
index 3595239..31b375c 100644
--- a/res/layout-sw600dp/title_bar_nav.xml
+++ b/res/layout-sw600dp/title_bar_nav.xml
@@ -56,12 +56,6 @@
         android:layout_weight="1.0"
         android:orientation="horizontal">
 
-        <com.android.browser.LocationButton
-            android:id="@+id/location_button"
-            style="@style/NavButton"
-            android:layout_width="48dp"
-            android:visibility="gone" />
-
         <ImageView
             android:id="@+id/url_icon"
             android:layout_width="32dip"
diff --git a/res/layout/geolocation_permissions_prompt.xml b/res/layout/geolocation_permissions_prompt.xml
deleted file mode 100755
index 9a345d6..0000000
--- a/res/layout/geolocation_permissions_prompt.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2009 The Android Open Source Project
-
-     Licensed under the Apache License, Version 2.0 (the "License");
-     you may not use this file except in compliance with the License.
-     You may obtain a copy of the License at
-
-          http://www.apache.org/licenses/LICENSE-2.0
-
-     Unless required by applicable law or agreed to in writing, software
-     distributed under the License is distributed on an "AS IS" BASIS,
-     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-     See the License for the specific language governing permissions and
-     limitations under the License.
-
-     This is the layout for the Geolocation permissions prompt.
--->
-
-<com.android.browser.GeolocationPermissionsPrompt
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:background="@color/TabPassiveMessageBackground"
-    android:layout_width="match_parent"
-    android:layout_height="wrap_content"
-    android:orientation="vertical">
-
-    <!-- Cosmetic separator -->
-    <View
-        android:layout_width="match_parent"
-        android:layout_height="1dp"
-        android:background="@color/TabPassiveMessageLine" />
-
-    <!-- 'google.com wants to know your location' -->
-    <TextView android:id="@+id/message"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:paddingBottom="4dp"
-        android:paddingStart="16dp"
-        android:paddingEnd="16dp"
-        android:paddingTop="16dp"
-        android:textAppearance="?android:attr/textAppearanceSmall" />
-
-    <CheckBox
-        android:id="@+id/remember"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="8dp"
-        android:layout_marginEnd="8dp"
-        android:text="@string/geolocation_permissions_prompt_remember"
-        android:textAppearance="?android:attr/textAppearanceSmall" />
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical"
-        android:divider="?android:attr/dividerHorizontal"
-        android:showDividers="beginning"
-        android:layout_marginTop="8dp"
-        android:dividerPadding="16dip" >
-        <LinearLayout
-            style="?android:attr/buttonBarStyle"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:orientation="horizontal"
-            android:paddingStart="2dip"
-            android:paddingEnd="2dip"
-            android:measureWithLargestChild="true"
-            android:background="@null">
-            <Button
-                android:id="@+id/dont_share_button"
-                style="?android:attr/buttonBarButtonStyle"
-                android:layout_weight="1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/geolocation_permissions_prompt_dont_share" />
-            <Button
-                android:id="@+id/share_for_limited_time_button"
-                style="?android:attr/buttonBarButtonStyle"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_weight="1"
-                android:text="@string/geolocation_permissions_prompt_share_for_limited_time"/>
-            <Button
-                android:id="@+id/share_button"
-                style="?android:attr/buttonBarButtonStyle"
-                android:layout_weight="1"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/geolocation_permissions_prompt_share" />
-        </LinearLayout>
-    </LinearLayout>
-
-</com.android.browser.GeolocationPermissionsPrompt>
diff --git a/res/layout/tab.xml b/res/layout/tab.xml
index 0c25901..a72cbe4 100755
--- a/res/layout/tab.xml
+++ b/res/layout/tab.xml
@@ -135,11 +135,4 @@
 
     </LinearLayout>
 
-    <!-- Geolocation permissions prompt -->
-    <ViewStub android:id="@+id/geolocation_permissions_prompt"
-        android:layout="@layout/geolocation_permissions_prompt"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" />
-
-
 </com.android.browser.DraggableFrameLayout>
diff --git a/res/layout/title_bar_nav.xml b/res/layout/title_bar_nav.xml
index 83ef6bd..d7ab2b1 100644
--- a/res/layout/title_bar_nav.xml
+++ b/res/layout/title_bar_nav.xml
@@ -36,13 +36,6 @@
             android:src="@drawable/ic_deco_incognito_normal"
             android:visibility="gone" />
 
-        <com.android.browser.LocationButton
-            android:id="@+id/location_button"
-            style="@style/NavButton"
-            android:layout_width="wrap_content"
-            android:paddingEnd="2dp"
-            android:visibility="gone" />
-
         <ImageView
             android:id="@+id/magnify"
             android:layout_width="44dp"
diff --git a/src/com/android/browser/GeolocationPermissionsPrompt.java b/src/com/android/browser/GeolocationPermissionsPrompt.java
deleted file mode 100755
index a429b2d..0000000
--- a/src/com/android/browser/GeolocationPermissionsPrompt.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.browser;
-
-import org.codeaurora.swe.GeolocationPermissions;
-import org.codeaurora.swe.GeolocationPermissions.GeolocationPolicyChange;
-import org.codeaurora.swe.GeolocationPermissions.GeolocationPolicyListener;
-import org.json.JSONArray;
-
-import android.content.Context;
-import android.net.Uri;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-public class GeolocationPermissionsPrompt extends LinearLayout implements
-        GeolocationPolicyListener {
-    private TextView mMessage;
-    private Button mShareButton;
-    private Button mShareForLimitedTimeButton;
-    private Button mDontShareButton;
-    private CheckBox mRemember;
-    private android.webkit.GeolocationPermissions.Callback mCallback;
-    private String mOrigin;
-    private GeolocationPermissions mGeolocationPermissions;
-
-    private static final long MILLIS_PER_DAY = 86400000;
-
-    public GeolocationPermissionsPrompt(Context context) {
-        this(context, null);
-    }
-
-    public GeolocationPermissionsPrompt(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-    }
-
-    public void init(boolean privateBrowsing) {
-        mMessage = (TextView) findViewById(R.id.message);
-        mShareButton = (Button) findViewById(R.id.share_button);
-        mShareForLimitedTimeButton = (Button)
-                findViewById(R.id.share_for_limited_time_button);
-        mDontShareButton = (Button) findViewById(R.id.dont_share_button);
-        mRemember = (CheckBox) findViewById(R.id.remember);
-
-        mRemember.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
-            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-                mShareForLimitedTimeButton.setEnabled(isChecked);
-            }
-        });
-
-        mShareButton.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                handleButtonClick(true, GeolocationPermissions.DO_NOT_EXPIRE);
-            }
-        });
-        mShareForLimitedTimeButton.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                handleButtonClick(true, System.currentTimeMillis() + MILLIS_PER_DAY);
-            }
-        });
-        mDontShareButton.setOnClickListener(new View.OnClickListener() {
-            public void onClick(View v) {
-                handleButtonClick(false, GeolocationPermissions.DO_NOT_EXPIRE);
-            }
-        });
-
-        mGeolocationPermissions = (privateBrowsing ? GeolocationPermissions.getIncognitoInstance()
-                : GeolocationPermissions.getInstance());
-        mGeolocationPermissions.addListener(this);
-    }
-
-    /**
-     * Shows the prompt for the given origin. When the user clicks on one of
-     * the buttons, the supplied callback is be called.
-     */
-    public void show(String origin,
-            android.webkit.GeolocationPermissions.Callback callback) {
-        mOrigin = origin;
-        mCallback = callback;
-        Uri uri = Uri.parse(mOrigin);
-        setMessage("http".equals(uri.getScheme()) ?  mOrigin.substring(7) : mOrigin);
-        // The checkbox should always be intially checked.
-        mRemember.setChecked(true);
-        setVisibility(View.VISIBLE);
-    }
-
-    /**
-     * This method is called when the user modifies the geolocation policy in a different Tab.
-     */
-    public void onGeolocationPolicyChanged(GeolocationPolicyChange change) {
-        int action = change.getAction();
-
-        if (action == GeolocationPermissions.ALL_POLICIES_REMOVED) {
-            // do not dismiss when policy is removed
-            return;
-        } else if (change.getOrigin() != null && mOrigin.equals(change.getOrigin())) {
-            boolean allow = false;
-            switch (action) {
-                case GeolocationPermissions.ORIGIN_POLICY_REMOVED:
-                    // do not dismiss when policy is removed
-                    break;
-                case GeolocationPermissions.ORIGIN_ALLOWED:
-                    allow = true;
-                case GeolocationPermissions.ORIGIN_DENIED:
-                    hide();
-                    JSONArray jsonArray = new JSONArray();
-                    jsonArray.put(System.currentTimeMillis());
-                    jsonArray.put(mOrigin);
-                    // no need to retain policy since it has already been saved
-                    mCallback.invoke(jsonArray.toString(), allow, false /*retain*/);
-                    break;
-                default:
-                    return;
-            }
-        }
-    }
-
-    /**
-     * This method is called when the user navigates to a new URL (onPageStarted). In this case,
-     * we respond as if user denied access without retaining the policy.
-     */
-    public void dismiss() {
-        hide();
-        JSONArray jsonArray = new JSONArray();
-        jsonArray.put(System.currentTimeMillis());
-        jsonArray.put(mOrigin);
-        mCallback.invoke(jsonArray.toString(), false /*allow*/, false /*retain*/);
-    }
-    /**
-     * Hides the prompt.
-     */
-    public void hide() {
-        setVisibility(View.GONE);
-        mGeolocationPermissions.removeListener(this);
-    }
-
-    /**
-     * Handles a click on one the buttons by invoking the callback.
-     */
-    private void handleButtonClick(boolean allow, long expirationTime) {
-        hide();
-
-        boolean remember = mRemember.isChecked();
-        if (remember) {
-            Toast toast = Toast.makeText(
-                    getContext(),
-                    allow ? R.string.geolocation_permissions_prompt_toast_allowed :
-                            R.string.geolocation_permissions_prompt_toast_disallowed,
-                    Toast.LENGTH_LONG);
-            toast.setGravity(Gravity.BOTTOM, 0, 0);
-            toast.show();
-        }
-
-        // Encode the expirationTime and origin as a JSON string.
-        JSONArray jsonArray = new JSONArray();
-        jsonArray.put(expirationTime);
-        jsonArray.put(mOrigin);
-        mCallback.invoke(jsonArray.toString(), allow, remember);
-    }
-
-    /**
-     * Sets the prompt's message.
-     */
-    private void setMessage(CharSequence origin) {
-        mMessage.setText(String.format(
-            getResources().getString(R.string.geolocation_permissions_prompt_message),
-            origin));
-    }
-}
diff --git a/src/com/android/browser/LocationButton.java b/src/com/android/browser/LocationButton.java
deleted file mode 100644
index 1bc3afb..0000000
--- a/src/com/android/browser/LocationButton.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- *  Copyright (c) 2014, The Linux Foundation. All rights reserved.
- *
- *  Redistribution and use in source and binary forms, with or without
- *  modification, are permitted provided that the following conditions are
- *  met:
- *      * Redistributions of source code must retain the above copyright
- *       notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- *       copyright notice, this list of conditions and the following
- *       disclaimer in the documentation and/or other materials provided
- *       with the distribution.
- *     * Neither the name of The Linux Foundation nor the names of its
- *       contributors may be used to endorse or promote products derived
- *       from this software without specific prior written permission.
- *
- *  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- *  ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- *  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- *  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- *  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- *  IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-package com.android.browser;
-
-import org.codeaurora.swe.GeolocationPermissions;
-import org.codeaurora.swe.GeolocationPermissions.GeolocationPolicyChange;
-import org.codeaurora.swe.GeolocationPermissions.GeolocationPolicyListener;
-import org.json.JSONArray;
-
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.net.Uri;
-import android.util.AttributeSet;
-import android.view.View;
-import android.webkit.ValueCallback;
-import android.widget.ImageButton;
-
-public class LocationButton extends ImageButton implements GeolocationPolicyListener {
-    private GeolocationPermissions mGeolocationPermissions;
-    private long mCurrentTabId;
-    private String mCurrentOrigin;
-    private boolean mCurrentIncognito;
-
-    private static final long MILLIS_PER_DAY = 86400000;
-
-    protected long geolocationPolicyExpiration;
-    protected boolean geolocationPolicyOriginAllowed;
-
-    public LocationButton(Context context) {
-        super(context);
-    }
-
-    public LocationButton(Context context, AttributeSet attrs) {
-        super(context, attrs);
-
-    }
-
-    public LocationButton(Context context, AttributeSet attrs, int defStyle) {
-        super(context, attrs, defStyle);
-    }
-
-    @Override
-    protected void onFinishInflate() {
-        super.onFinishInflate();
-        init();
-    }
-
-    private void updateGeolocationPermissions() {
-        mGeolocationPermissions = mCurrentIncognito ?
-                                    GeolocationPermissions.getIncognitoInstance() :
-                                    GeolocationPermissions.getInstance();
-
-        mGeolocationPermissions.addListener(this);
-    }
-
-    // TODO: Perform this initilalization only after the engine initialization is complete.
-    private void init() {
-        mCurrentTabId = -1;
-        mCurrentOrigin = null;
-        mCurrentIncognito = false;
-
-        setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                if (!mCurrentOrigin.isEmpty()) {
-                    final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
-                    updateGeolocationPermissions();
-                    final GeolocationPermissions geolocationPermissions = mGeolocationPermissions;
-                    DialogInterface.OnClickListener alertDialogListener =
-                            new AlertDialog.OnClickListener() {
-                        public void onClick(DialogInterface dlg, int which) {
-                            String origin = mCurrentOrigin;
-                            int selectedPosition = ((AlertDialog)dlg)
-                                    .getListView().getCheckedItemPosition();
-                            switch (selectedPosition) {
-                                case 0: // Deny forever
-                                    geolocationPermissions.deny(origin);
-                                    break;
-                                case 1: // Extend for 24 hours
-                                    // encode the expiration time and origin as a JSON string
-                                    JSONArray jsonArray = new JSONArray();
-                                    jsonArray.put(System.currentTimeMillis() + MILLIS_PER_DAY);
-                                    jsonArray.put(origin);
-                                    geolocationPermissions.allow(jsonArray.toString());
-                                    break;
-                                case 2: // Allow forever
-                                    geolocationPermissions.allow(origin);
-                                    break;
-                                case 3: // Always ask
-                                    geolocationPermissions.clear(origin);
-                                    break;
-                                default:
-                                    break;
-                            }
-                        }};
-
-                    builder.setTitle(String.format(getResources()
-                            .getString(R.string.geolocation_settings_page_dialog_title),
-                                "http".equals(Uri.parse(mCurrentOrigin).getScheme()) ?
-                                        mCurrentOrigin.substring(7) : mCurrentOrigin))
-                        .setPositiveButton(R.string.geolocation_settings_page_dialog_ok_button,
-                                           alertDialogListener)
-                        .setNegativeButton(R.string.geolocation_settings_page_dialog_cancel_button, null);
-
-                    final ValueCallback<Long> getExpirationCallback = new ValueCallback<Long>() {
-                        public void onReceiveValue(Long expirationTime) {
-                            if (expirationTime != null) {
-                                geolocationPolicyExpiration = expirationTime.longValue();
-                                // Set radio button and location icon
-                                if (!geolocationPolicyOriginAllowed) {
-                                    // 0: Deny forever
-                                    builder.setSingleChoiceItems(R.array.geolocation_settings_choices, 0, null);
-                                } else {
-                                    if (geolocationPolicyExpiration
-                                            != GeolocationPermissions.DO_NOT_EXPIRE) {
-                                        // 1: Allow for 24 hours
-                                        builder.setSingleChoiceItems(R.array.geolocation_settings_choices, 1, null);
-                                    } else {
-                                        // 2: Allow forever
-                                        builder.setSingleChoiceItems(R.array.geolocation_settings_choices, 2, null);
-                                    }
-                                }
-                            }
-                            builder.show();
-                        }};
-
-                    final ValueCallback<Boolean> getAllowedCallback = new ValueCallback<Boolean>() {
-                        public void onReceiveValue(Boolean allowed) {
-                            if (allowed != null) {
-                                geolocationPolicyOriginAllowed = allowed.booleanValue();
-                                //Get the policy expiration time
-                                geolocationPermissions
-                                    .getExpirationTime(mCurrentOrigin, getExpirationCallback);
-                            }
-                        }};
-
-                    geolocationPermissions.hasOrigin(mCurrentOrigin,
-                        new ValueCallback<Boolean>() {
-                            public void onReceiveValue(Boolean hasOrigin) {
-                                if (hasOrigin != null && hasOrigin.booleanValue()) {
-                                    //Get whether origin is allowed or denied
-                                    geolocationPermissions.getAllowed(mCurrentOrigin,
-                                            getAllowedCallback);
-                                }
-                            }
-                        });
-                    }
-                }
-            });
-    }
-
-    public void onTabDataChanged(Tab tab) {
-        long tabId = tab.getId();
-        String origin = GeolocationPermissions.getOriginFromUrl(tab.getUrl());
-        boolean incognito = tab.isPrivateBrowsingEnabled();
-
-        if (mCurrentTabId != tabId) {
-            mCurrentTabId = tabId;
-            mCurrentOrigin = origin;
-            // Switch GeolocationPermissions if we went from a regular to an
-            // incognito tab or vice versa
-            if (mCurrentIncognito != incognito) {
-                mCurrentIncognito = incognito;
-                mGeolocationPermissions = mCurrentIncognito ?
-                        GeolocationPermissions.getIncognitoInstance() :
-                        GeolocationPermissions.getInstance();
-                mGeolocationPermissions.addListener(this);
-            }
-            update();
-        }
-        // Update icon if we are in the same Tab and origin has changed
-        else if (!((mCurrentOrigin == null && origin == null) ||
-                (mCurrentOrigin != null && origin != null
-                        && mCurrentOrigin.equals(origin)))) {
-            mCurrentOrigin = origin;
-            update();
-        }
-    }
-
-    /**
-     * This method is called when we navigate away from an origin on the same Tab or
-     * when a new Tab is created.
-     */
-    private void update() {
-        if (mCurrentOrigin != null) {
-            updateGeolocationPermissions();
-            mGeolocationPermissions.hasOrigin(mCurrentOrigin,
-                    new ValueCallback<Boolean>() {
-                public void onReceiveValue(Boolean hasOrigin) {
-                    if (hasOrigin != null && hasOrigin.booleanValue()) {
-                        mGeolocationPermissions.getAllowed(mCurrentOrigin,
-                                new ValueCallback<Boolean>() {
-                            public void onReceiveValue(Boolean allowed) {
-                                if (allowed != null) {
-                                    if (allowed.booleanValue()) {
-                                        LocationButton.this.setImageResource(R.drawable.ic_action_gps_on);
-                                        LocationButton.this.setVisibility(VISIBLE);
-                                    } else {
-                                        LocationButton.this.setImageResource(R.drawable.ic_action_gps_off);
-                                        LocationButton.this.setVisibility(VISIBLE);
-                                    }
-                                }
-                            }
-                        });
-                    } else {
-                        LocationButton.this.setVisibility(GONE);
-                    }
-                }
-            });
-        } else {
-            this.setVisibility(GONE);
-        }
-    }
-
-    public void onGeolocationPolicyChanged(GeolocationPolicyChange change) {
-        if (mCurrentOrigin != null) {
-            int action = change.getAction();
-
-            if (action == GeolocationPermissions.ALL_POLICIES_REMOVED) {
-                this.setVisibility(GONE);
-                return;
-            } else if (change.getOrigin() != null && mCurrentOrigin.equals(change.getOrigin())) {
-                switch (action) {
-                    case GeolocationPermissions.ORIGIN_ALLOWED:
-                        this.setImageResource(R.drawable.ic_action_gps_on);
-                        this.setVisibility(VISIBLE);
-                        break;
-                    case GeolocationPermissions.ORIGIN_DENIED:
-                        this.setImageResource(R.drawable.ic_action_gps_off);
-                        this.setVisibility(VISIBLE);
-                        break;
-                    case GeolocationPermissions.ORIGIN_POLICY_REMOVED:
-                        this.setVisibility(GONE);
-                        break;
-                    default:
-                        break;
-                }
-            }
-        }
-    }
-}
diff --git a/src/com/android/browser/NavigationBarBase.java b/src/com/android/browser/NavigationBarBase.java
index 96a9896..ebeae65 100644
--- a/src/com/android/browser/NavigationBarBase.java
+++ b/src/com/android/browser/NavigationBarBase.java
@@ -60,7 +60,6 @@
     protected TitleBar mTitleBar;
     protected UiController mUiController;
     protected UrlInputView mUrlInput;
-    protected LocationButton mLocationButton;
 
     private ImageView mFavicon;
     private ImageView mLockIcon;
@@ -86,7 +85,6 @@
     protected void onFinishInflate() {
         super.onFinishInflate();
         mLockIcon = (ImageView) findViewById(R.id.lock);
-        mLocationButton = (LocationButton) findViewById(R.id.location_button);
         mFavicon = (ImageView) findViewById(R.id.favicon);
         mUrlInput = (UrlInputView) findViewById(R.id.url);
         mUrlInput.setUrlInputListener(this);
@@ -430,7 +428,6 @@
     }
 
     public void onTabDataChanged(Tab tab) {
-        mLocationButton.onTabDataChanged(tab);
     }
 
     public void onVoiceResult(String s) {
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index 4ca8937..78e929a 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -50,7 +50,6 @@
 import android.view.View;
 import android.view.ViewStub;
 import android.webkit.ConsoleMessage;
-import android.webkit.GeolocationPermissions;
 import android.webkit.URLUtil;
 import android.webkit.WebResourceResponse;
 import android.webkit.WebStorage;
@@ -134,8 +133,6 @@
     // The tab ID
     private long mId = -1;
 
-    // The Geolocation permissions prompt
-    private GeolocationPermissionsPrompt mGeolocationPermissionsPrompt;
     // Main WebView wrapper
     private View mContainer;
     // Main WebView
@@ -333,12 +330,6 @@
                 mTouchIconLoader = null;
             }
 
-            // Loading a new page voids any ongoing Geolocation permission
-            // requests.
-            if (mGeolocationPermissionsPrompt != null) {
-                mGeolocationPermissionsPrompt.dismiss();
-            }
-
             // finally update the UI in the activity if it is in the foreground
             mWebViewController.onPageStarted(Tab.this, view, favicon);
 
@@ -956,32 +947,6 @@
                             quotaUpdater);
         }
 
-        /**
-         * Instructs the browser to show a prompt to ask the user to set the
-         * Geolocation permission state for the specified origin.
-         * @param origin The origin for which Geolocation permissions are
-         *     requested.
-         * @param callback The callback to call once the user has set the
-         *     Geolocation permission state.
-         */
-        @Override
-        public void onGeolocationPermissionsShowPrompt(String origin,
-                GeolocationPermissions.Callback callback) {
-            if (mInForeground) {
-                getGeolocationPermissionsPrompt().show(origin, callback);
-            }
-        }
-
-        /**
-         * Instructs the browser to hide the Geolocation permissions prompt.
-         */
-        @Override
-        public void onGeolocationPermissionsHidePrompt() {
-            if (mInForeground && mGeolocationPermissionsPrompt != null) {
-                mGeolocationPermissionsPrompt.hide();
-            }
-        }
-
         /* Adds a JavaScript error message to the system log and if the JS
          * console is enabled in the about:debug options, to that console
          * also.
@@ -1329,12 +1294,6 @@
             return;
         }
 
-        // If the WebView is changing, the page will be reloaded, so any ongoing
-        // Geolocation permission requests are void.
-        if (mGeolocationPermissionsPrompt != null) {
-            mGeolocationPermissionsPrompt.hide();
-        }
-
         mWebViewController.onSetWebView(this, w);
 
         if (mMainView != null) {
@@ -1671,19 +1630,6 @@
         mSubViewContainer = subViewContainer;
     }
 
-    /**
-     * @return The geolocation permissions prompt for this tab.
-     */
-    GeolocationPermissionsPrompt getGeolocationPermissionsPrompt() {
-        if (mGeolocationPermissionsPrompt == null) {
-            ViewStub stub = (ViewStub) mContainer
-                    .findViewById(R.id.geolocation_permissions_prompt);
-            mGeolocationPermissionsPrompt = (GeolocationPermissionsPrompt) stub
-                    .inflate();
-            mGeolocationPermissionsPrompt.init(mCurrentState.mIncognito);
-        }
-        return mGeolocationPermissionsPrompt;
-    }
 
     /**
      * @return The application id string
diff --git a/src/com/android/browser/preferences/WebsiteSettingsFragment.java b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
index 4301971..ad16635 100644
--- a/src/com/android/browser/preferences/WebsiteSettingsFragment.java
+++ b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
@@ -59,7 +59,6 @@
 
 import org.codeaurora.swe.GeolocationPermissions;
 import org.codeaurora.swe.WebStorage;
-import org.json.JSONArray;
 
 /**
  * Manage the settings for an origin.
@@ -630,12 +629,10 @@
                                     case 0: // Deny forever
                                         geolocationPermissions.deny(origin);
                                         break;
-                                    case 1: // Allow for 24 hours
-                                        // encode the expiration time and origin as a JSON string
-                                        JSONArray jsonArray = new JSONArray();
-                                        jsonArray.put(System.currentTimeMillis() + MILLIS_PER_DAY);
-                                        jsonArray.put(origin);
-                                        geolocationPermissions.allow(jsonArray.toString());
+                                    case 1:
+                                        // Allow for 24 hours
+                                        geolocationPermissions.allow(origin,
+                                                System.currentTimeMillis() + MILLIS_PER_DAY);
                                         break;
                                     case 2: // Allow forever
                                         geolocationPermissions.allow(origin);
@@ -662,53 +659,21 @@
                                                alertDialogListener)
                             .setNegativeButton(R.string.geolocation_settings_page_dialog_cancel_button, null);
 
-                        final ValueCallback<Long> getExpirationCallback =
-                                new ValueCallback<Long>() {
-                            public void onReceiveValue(Long expirationTime) {
-                                if (expirationTime != null) {
-                                    geolocationPolicyExpiration = expirationTime.longValue();
-                                    // Set radio button and location icon
-                                    if (!geolocationPolicyOriginAllowed) {
-                                        // 0: Deny forever
-                                        builder.setSingleChoiceItems(R.array.geolocation_settings_choices, 0, null);
-                                    } else {
-                                        if (geolocationPolicyExpiration
-                                                != GeolocationPermissions.DO_NOT_EXPIRE) {
-                                        // 1: Allow for 24 hours
-                                        builder.setSingleChoiceItems(R.array.geolocation_settings_choices, 1, null);
-                                        } else {
-                                        // 2: Allow forever
-                                        builder.setSingleChoiceItems(R.array.geolocation_settings_choices, 2, null);
-                                        }
-                                    }
-                                }
-                                builder.show();
-                            }
-                        };
-
-                        final ValueCallback<Boolean> getAllowedCallback =
-                                new ValueCallback<Boolean>() {
-                            public void onReceiveValue(Boolean allowed) {
-                                if (allowed != null) {
-                                    geolocationPolicyOriginAllowed = allowed.booleanValue();
-                                    //Get the policy expiration time
-                                    geolocationPermissions.getExpirationTime(origin,
-                                            getExpirationCallback);
-                                }
-                            }
-                        };
-
-                        geolocationPermissions.hasOrigin(origin,
-                                new ValueCallback<Boolean>() {
-                            public void onReceiveValue(Boolean hasOrigin) {
-                                if (hasOrigin != null && hasOrigin.booleanValue()) {
-                                    //Get whether origin is allowed or denied
-                                    geolocationPermissions.getAllowed(origin,
-                                            getAllowedCallback);
-                                }
-                            }
-                        });
-                        break;
+                        switch(geolocationPermissions.getContentSetting(origin)) {
+                            case BLOCK:
+                                builder.setSingleChoiceItems(R.array.geolocation_settings_choices,
+                                        0, null);
+                                break;
+                            case ALLOW_24H:
+                                builder.setSingleChoiceItems(R.array.geolocation_settings_choices,
+                                        1, null);
+                                break;
+                            case ALLOW:
+                                builder.setSingleChoiceItems(R.array.geolocation_settings_choices,
+                                        2, null);
+                                break;
+                        }
+                        builder.show();
                 }
             } else {
                 Site site = (Site) view.getTag();