Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1688)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java

Issue 2709883005: Stubs for triggering the LSD in Clank (Closed)
Patch Set: Declare the dependency of components/location on WindowAndroid Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java
index 7d45e0e1096a680b1cc6c1c530316eae908eda7e..a0cfcdaafbb955fa8ea4b3c966447ee6245c8270 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/LocationSettings.java
@@ -6,13 +6,16 @@ package org.chromium.chrome.browser.preferences;
import android.Manifest;
+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.CalledByNative;
+import org.chromium.base.annotations.NativeClassQualifiedName;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.chrome.browser.ChromeApplication;
import org.chromium.components.location.LocationUtils;
+import org.chromium.components.location.LocationUtils.PromptOutcome;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.WindowAndroid;
@@ -50,9 +53,7 @@ public class LocationSettings {
@CalledByNative
private static boolean canSitesRequestLocationPermission(WebContents webContents) {
- ContentViewCore cvc = ContentViewCore.fromWebContents(webContents);
- if (cvc == null) return false;
- WindowAndroid windowAndroid = cvc.getWindowAndroid();
+ WindowAndroid windowAndroid = windowFromWebContents(webContents);
if (windowAndroid == null) return false;
LocationUtils locationUtils = LocationUtils.getInstance();
@@ -62,6 +63,34 @@ public class LocationSettings {
|| windowAndroid.canRequestPermission(Manifest.permission.ACCESS_FINE_LOCATION);
}
+ @CalledByNative
+ public static void canPromptToEnableSystemLocationSetting(final long nativeCallback) {
+ LocationUtils.getInstance().canPromptToEnableSystemLocationSetting(new Callback<Boolean>() {
+ @Override
+ public void onResult(Boolean result) {
+ nativeRunBoolCallback(nativeCallback, result);
+ }
+ });
+ }
+
+ @CalledByNative
+ public static void promptToEnableSystemLocationSetting(
+ int promptContext, WebContents webContents, final long nativeCallback) {
+ WindowAndroid window = windowFromWebContents(webContents);
+ if (window == null) {
+ nativeRunPromptOutcomeCallback(nativeCallback, PromptOutcome.NO_PROMPT);
+ return;
+ }
+ LocationUtils.getInstance().promptToEnableSystemLocationSetting(
+ promptContext, window,
+ new Callback<Integer>() {
+ @Override
+ public void onResult(Integer result) {
+ nativeRunPromptOutcomeCallback(nativeCallback, result);
+ }
+ });
+ }
+
/**
* Returns true if location is enabled system-wide and the Chrome location setting is enabled.
*/
@@ -81,4 +110,16 @@ public class LocationSettings {
public static void setInstanceForTesting(LocationSettings instance) {
sInstance = instance;
}
+
+ private static WindowAndroid windowFromWebContents(WebContents webContents) {
+ ContentViewCore contentViewCore = ContentViewCore.fromWebContents(webContents);
+ if (contentViewCore == null) return null;
+ return contentViewCore.getWindowAndroid();
+ }
+
+ @NativeClassQualifiedName("LocationSettingsImpl::BoolCallback")
+ private static native void nativeRunBoolCallback(long nativeBoolCallback, boolean result);
benwells 2017/02/28 06:26:36 You should call these something more meaningful /
+ @NativeClassQualifiedName("LocationSettingsImpl::PromptOutcomeCallback")
+ private static native void nativeRunPromptOutcomeCallback(
+ long nativePromptOutcomeCallback, int result);
}
« no previous file with comments | « no previous file | chrome/browser/android/chrome_jni_registrar.cc » ('j') | chrome/browser/android/location_settings.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698