diff options
author | Tarun Nainani <tnainani@codeaurora.org> | 2015-05-18 18:58:12 -0700 |
---|---|---|
committer | jrizzoli <joey@cyanogenmoditalia.it> | 2015-08-28 13:15:44 +0200 |
commit | d598b9e4e4a4fa24cb4506b3df58856f0f9be240 (patch) | |
tree | 3d695fade77c44b724b0b9cb9fb01c4aace18abe /src | |
parent | c0e1d433f8e15511dccb14e44e6517040fd9e86a (diff) | |
download | android_packages_apps_Gello-d598b9e4e4a4fa24cb4506b3df58856f0f9be240.tar.gz android_packages_apps_Gello-d598b9e4e4a4fa24cb4506b3df58856f0f9be240.tar.bz2 android_packages_apps_Gello-d598b9e4e4a4fa24cb4506b3df58856f0f9be240.zip |
Implement 24 hour Geolocation infobar
Remove GeolocationPermissionPromt code as now its handled by infobar.
Remove LocationButton from navigation bar.
Change-Id: Id1c78da371556d1366afe22012f3b2efff803a39
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/browser/GeolocationPermissionsPrompt.java | 194 | ||||
-rw-r--r-- | src/com/android/browser/LocationButton.java | 270 | ||||
-rw-r--r-- | src/com/android/browser/NavigationBarBase.java | 3 | ||||
-rw-r--r-- | src/com/android/browser/Tab.java | 54 | ||||
-rw-r--r-- | src/com/android/browser/preferences/WebsiteSettingsFragment.java | 73 |
5 files changed, 19 insertions, 575 deletions
diff --git a/src/com/android/browser/GeolocationPermissionsPrompt.java b/src/com/android/browser/GeolocationPermissionsPrompt.java deleted file mode 100755 index a429b2d9..00000000 --- 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 1bc3afb6..00000000 --- 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 96a98964..ebeae651 100644 --- a/src/com/android/browser/NavigationBarBase.java +++ b/src/com/android/browser/NavigationBarBase.java @@ -60,7 +60,6 @@ public class NavigationBarBase extends LinearLayout implements protected TitleBar mTitleBar; protected UiController mUiController; protected UrlInputView mUrlInput; - protected LocationButton mLocationButton; private ImageView mFavicon; private ImageView mLockIcon; @@ -86,7 +85,6 @@ public class NavigationBarBase extends LinearLayout implements 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 class NavigationBarBase extends LinearLayout implements } 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 4ca8937e..78e929a2 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -50,7 +50,6 @@ import android.view.LayoutInflater; 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 @@ class Tab implements PictureListener { // 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 @@ class Tab implements PictureListener { 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 @@ class Tab implements PictureListener { 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 @@ class Tab implements PictureListener { 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 @@ class Tab implements PictureListener { 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 43019719..ad166357 100644 --- a/src/com/android/browser/preferences/WebsiteSettingsFragment.java +++ b/src/com/android/browser/preferences/WebsiteSettingsFragment.java @@ -59,7 +59,6 @@ import java.util.Set; import org.codeaurora.swe.GeolocationPermissions; import org.codeaurora.swe.WebStorage; -import org.json.JSONArray; /** * Manage the settings for an origin. @@ -630,12 +629,10 @@ public class WebsiteSettingsFragment extends ListFragment implements OnClickList 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 @@ public class WebsiteSettingsFragment extends ListFragment implements OnClickList 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(); |