| 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..3c58d9050363f1fcf948b63854c8b1799d5fc576 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 LocationSettingsDialogPromptContext enum in
|
| + * //chrome/browser/android/location_settings.h
|
| + */
|
| + @Retention(RetentionPolicy.SOURCE)
|
| + @IntDef({
|
| + LocationSettingsDialogPromptContext.GESTURE,
|
| + LocationSettingsDialogPromptContext.SEARCH,
|
| + })
|
| + public @interface LocationSettingsDialogPromptContext {
|
| + /**
|
| + * 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 LocationSettingsDialogPromptOutcome enum in
|
| + * //chrome/browser/android/location_settings.h
|
| + */
|
| + @Retention(RetentionPolicy.SOURCE)
|
| + @IntDef({
|
| + LocationSettingsDialogPromptOutcome.GRANTED,
|
| + LocationSettingsDialogPromptOutcome.DENIED,
|
| + LocationSettingsDialogPromptOutcome.NO_PROMPT,
|
| + })
|
| + public @interface LocationSettingsDialogPromptOutcome {
|
| + /** 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(
|
| + @LocationSettingsDialogPromptContext int promptContext, WindowAndroid window,
|
| + @LocationSettingsDialogPromptOutcome Callback<Integer> callback) {
|
| + callback.onResult(LocationSettingsDialogPromptOutcome.NO_PROMPT);
|
| + }
|
| +
|
| + /**
|
| * Returns an intent to launch Android Location Settings.
|
| */
|
| public Intent getSystemLocationSettingsIntent() {
|
|
|