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

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: Rebase onto head 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 a2877eabc2ab77c5746c3b425416991ae8692147..ef729cd5ae611a3c157f561830fa803914812594 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,12 +6,14 @@ package org.chromium.chrome.browser.preferences;
import android.Manifest;
+import org.chromium.base.Callback;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.chrome.browser.AppHooks;
import org.chromium.components.location.LocationUtils;
+import org.chromium.components.location.LocationUtils.LocationSettingsDialogOutcome;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.WindowAndroid;
@@ -47,9 +49,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();
@@ -59,6 +59,30 @@ public class LocationSettings {
|| windowAndroid.canRequestPermission(Manifest.permission.ACCESS_FINE_LOCATION);
}
+ @CalledByNative
+ public static boolean canPromptToEnableSystemLocationSetting() {
Ted C 2017/03/02 00:21:56 do these need to be public?
qfiard 2017/03/02 13:28:13 No, thanks for the tip.
+ return LocationUtils.getInstance().canPromptToEnableSystemLocationSetting();
+ }
+
+ @CalledByNative
+ public static void promptToEnableSystemLocationSetting(
+ int promptContext, WebContents webContents, final long nativeCallback) {
+ WindowAndroid window = windowFromWebContents(webContents);
+ if (window == null) {
+ nativeOnLocationSettingsDialogOutcome(
+ nativeCallback, LocationSettingsDialogOutcome.NO_PROMPT);
+ return;
+ }
+ LocationUtils.getInstance().promptToEnableSystemLocationSetting(
+ promptContext, window,
+ new Callback<Integer>() {
+ @Override
+ public void onResult(Integer result) {
+ nativeOnLocationSettingsDialogOutcome(nativeCallback, result);
+ }
+ });
+ }
+
/**
* Returns true if location is enabled system-wide and the Chrome location setting is enabled.
*/
@@ -78,4 +102,13 @@ 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();
+ }
+
+ private static native void nativeOnLocationSettingsDialogOutcome(
+ long callback, 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