| 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..94996ef9530268cd8e5c0d8b10840e190ea6c9db 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,80 @@ public class LocationUtils {
|
| }
|
|
|
| /**
|
| + * Asynchronously checks if a prompt can be triggered to ask the user to turn on the system
|
| + * location setting on their device, and returns true iff a prompt can be triggered.
|
| + *
|
| + * <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 void canPromptToEnableSystemLocationSetting(Callback<Boolean> callback) {
|
| + callback.onResult(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 PromptContext enum in
|
| + * https://cs.chromium.org/chromium/src/chrome/browser/android/location_settings.h
|
| + */
|
| + @Retention(RetentionPolicy.SOURCE)
|
| + @IntDef({PromptContext.GESTURE, PromptContext.SEARCH})
|
| + public @interface PromptContext {
|
| + /**
|
| + * 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;
|
| + /** 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 PromptOutcome enum in
|
| + * https://cs.chromium.org/chromium/src/chrome/browser/android/location_settings.h
|
| + */
|
| + @Retention(RetentionPolicy.SOURCE)
|
| + @IntDef({PromptOutcome.GRANTED, PromptOutcome.DENIED, PromptOutcome.NO_PROMPT})
|
| + public @interface PromptOutcome {
|
| + /** 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(
|
| + @PromptContext int promptContext, WindowAndroid window,
|
| + @PromptOutcome Callback<Integer> callback) {
|
| + callback.onResult(PromptOutcome.NO_PROMPT);
|
| + }
|
| +
|
| + /**
|
| * Returns an intent to launch Android Location Settings.
|
| */
|
| public Intent getSystemLocationSettingsIntent() {
|
|
|