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

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: Group location settings dialog enums into a single java_cpp_enum rule 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
« no previous file with comments | « no previous file | chrome/browser/android/chrome_jni_registrar.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0d43663497aaf09d551ed3796e49522735194103 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,11 +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.LocationSettingsDialogContext.LocationSettingsDialogContextEnum;
+import org.chromium.components.location.LocationSettingsDialogOutcome;
import org.chromium.components.location.LocationUtils;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content_public.browser.WebContents;
@@ -47,9 +50,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 +60,30 @@ public class LocationSettings {
|| windowAndroid.canRequestPermission(Manifest.permission.ACCESS_FINE_LOCATION);
}
+ @CalledByNative
+ private static boolean canPromptToEnableSystemLocationSetting() {
+ return LocationUtils.getInstance().canPromptToEnableSystemLocationSetting();
+ }
+
+ @CalledByNative
+ private static void promptToEnableSystemLocationSetting(
+ @LocationSettingsDialogContextEnum 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 +103,12 @@ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698