Chromium Code Reviews| Index: components/location/android/java/src/org/chromium/components/location/LocationUtils.java |
| diff --git a/components/location/android/java/src/org/chromium/components/location/LocationUtils.java b/components/location/android/java/src/org/chromium/components/location/LocationUtils.java |
| index 204a45abbfa61675a6bc845b0b127aa02ce5bf57..60be7e7007d4f15e86390190f880f41a2a7574f4 100644 |
| --- a/components/location/android/java/src/org/chromium/components/location/LocationUtils.java |
| +++ b/components/location/android/java/src/org/chromium/components/location/LocationUtils.java |
| @@ -11,13 +11,19 @@ import android.content.pm.PackageManager; |
| import android.os.Build; |
| import android.os.Process; |
| import android.provider.Settings; |
| +import android.support.annotation.IntDef; |
| import android.text.TextUtils; |
| import org.chromium.base.ApiCompatibilityUtils; |
| +import org.chromium.base.Callback; |
| import org.chromium.base.ContextUtils; |
| import org.chromium.base.ThreadUtils; |
| import org.chromium.base.VisibleForTesting; |
| import org.chromium.base.annotations.SuppressFBWarnings; |
| +import org.chromium.ui.base.WindowAndroid; |
| + |
| +import java.lang.annotation.Retention; |
| +import java.lang.annotation.RetentionPolicy; |
| /** |
| * Provides methods for querying Chrome's ability to use Android's location services. |
| @@ -83,6 +89,87 @@ public class LocationUtils { |
| } |
| /** |
| + * Returns true iff a prompt can be triggered to ask the user to turn on the system location |
| + * setting on their device. |
| + * |
| + * <p>In particular, returns false if the system location setting is already enabled or if some |
| + * of the features required to trigger a system location setting prompt are not available. |
| + */ |
| + public boolean canPromptToEnableSystemLocationSetting() { |
| + return false; |
| + } |
| + |
| + /** |
| + * Describes the context in which a system location setting prompt is triggered to allow the |
| + * prompt UI to be customized to the given context. |
| + * |
| + * <p>Keep in sync with the LocationSettingsDialogContext enum in |
| + * //chrome/browser/android/location_settings.h |
| + */ |
| + @Retention(RetentionPolicy.SOURCE) |
| + @IntDef({ |
| + LocationSettingsDialogContext.GESTURE, |
| + LocationSettingsDialogContext.SEARCH, |
| + }) |
| + public @interface LocationSettingsDialogContext { |
| + /** |
| + * Prompt triggered in the context of a user gesture on a web page or on a preliminary domain or |
| + * app permission prompt. |
| + */ |
| + int GESTURE = 1; |
|
Ted C
2017/03/02 00:21:56
should be indented +4 more for all the contents of
qfiard
2017/03/02 13:28:13
Obsolete now that the Java enum is autogenerated.
|
| + /** Prompt triggered in the context of a search. */ |
| + int SEARCH = 2; |
| + } |
| + |
| + /** |
| + * Describes the outcome of a system location setting prompt triggered by |
| + * {@link promptToEnableSystemLocationSetting()}. |
| + * |
| + * <p>Keep in sync with the LocationSettingsDialogOutcome enum in |
| + * //chrome/browser/android/location_settings.h |
| + */ |
| + @Retention(RetentionPolicy.SOURCE) |
| + @IntDef({ |
| + LocationSettingsDialogOutcome.GRANTED, |
| + LocationSettingsDialogOutcome.DENIED, |
| + LocationSettingsDialogOutcome.NO_PROMPT, |
| + }) |
| + public @interface LocationSettingsDialogOutcome { |
| + /** The user accepted the prompt and the system location setting has been flipped to granted. */ |
| + int GRANTED = 1; |
| + |
| + /** The user rejected the prompt and the system location setting has not been flipped. */ |
| + int DENIED = 2; |
| + |
| + /** |
| + * The prompt could not be triggered. |
| + * |
| + * <p>When {@link canPromptToEnableSystemLocationSetting()} returns true, this should only |
| + * happen in exceptional circonstances, e.g. |
| + * |
| + * <ul> |
| + * <li>In the case of a race condition where the system location setting is flipped elsewhere |
| + * before the prompt could be triggered; |
| + * <li>In the case where some of the features required to trigger a system location setting |
| + * prompt became unavailable or unresponsive after the response from |
| + * {@link canPromptToEnableSystemLocationSetting()} was received. |
| + * </ul> |
| + */ |
| + int NO_PROMPT = 3; |
| + } |
| + |
| + /** |
| + * Triggers a prompt to ask the user to turn on the system location setting on their device. |
| + * |
| + * <p>The prompt will be triggered within the specified window. |
| + */ |
| + public void promptToEnableSystemLocationSetting( |
| + @LocationSettingsDialogContext int promptContext, WindowAndroid window, |
| + @LocationSettingsDialogOutcome Callback<Integer> callback) { |
| + callback.onResult(LocationSettingsDialogOutcome.NO_PROMPT); |
| + } |
| + |
| + /** |
| * Returns an intent to launch Android Location Settings. |
| */ |
| public Intent getSystemLocationSettingsIntent() { |