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

Unified Diff: chrome/browser/android/location_settings_impl.cc

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 | « chrome/browser/android/location_settings_impl.h ('k') | chrome/browser/android/mock_location_settings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/location_settings_impl.cc
diff --git a/chrome/browser/android/location_settings_impl.cc b/chrome/browser/android/location_settings_impl.cc
index 9da10a1b624368c3967635d2ece2772a9651cefb..5ddf275d05e1972ca58c1b96e026bcc6dc6fce81 100644
--- a/chrome/browser/android/location_settings_impl.cc
+++ b/chrome/browser/android/location_settings_impl.cc
@@ -10,6 +10,9 @@
using base::android::AttachCurrentThread;
+using LocationSettingsDialogOutcomeCallback =
+ LocationSettings::LocationSettingsDialogOutcomeCallback;
+
LocationSettingsImpl::LocationSettingsImpl() {}
LocationSettingsImpl::~LocationSettingsImpl() {}
@@ -20,3 +23,41 @@ bool LocationSettingsImpl::CanSitesRequestLocationPermission(
return Java_LocationSettings_canSitesRequestLocationPermission(
env, web_contents->GetJavaWebContents());
}
+
+bool LocationSettingsImpl::CanPromptToEnableSystemLocationSetting() {
+ JNIEnv* env = AttachCurrentThread();
+ return Java_LocationSettings_canPromptToEnableSystemLocationSetting(env);
+}
+
+void LocationSettingsImpl::PromptToEnableSystemLocationSetting(
+ const LocationSettingsDialogContext prompt_context,
+ content::WebContents* web_contents,
+ LocationSettingsDialogOutcomeCallback callback) {
+ JNIEnv* env = AttachCurrentThread();
+ // Transfers the ownership of the callback to the Java callback. The Java
+ // callback is guaranteed to be called unless the user never replies to the
+ // dialog, and the callback pointer will be destroyed in
+ // OnLocationSettingsDialogOutcome.
+ auto* callback_ptr =
+ new LocationSettingsDialogOutcomeCallback(std::move(callback));
+ Java_LocationSettings_promptToEnableSystemLocationSetting(
+ env, prompt_context, web_contents->GetJavaWebContents(),
+ reinterpret_cast<jlong>(callback_ptr));
+}
+
+static void OnLocationSettingsDialogOutcome(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jclass>& jcaller,
+ jlong callback_ptr,
+ int result) {
+ auto* callback =
+ reinterpret_cast<LocationSettingsDialogOutcomeCallback*>(callback_ptr);
+ std::move(*callback).Run(static_cast<LocationSettingsDialogOutcome>(result));
+ // Destroy the callback whose ownership was transferred in
+ // PromptToEnableSystemLocationSetting.
+ delete callback;
+}
+
+bool LocationSettingsImpl::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
« no previous file with comments | « chrome/browser/android/location_settings_impl.h ('k') | chrome/browser/android/mock_location_settings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698