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

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

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/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..0f77c7e993e0624c221dd3631cb887801a1303fa 100644
--- a/chrome/browser/android/location_settings_impl.cc
+++ b/chrome/browser/android/location_settings_impl.cc
@@ -10,6 +10,11 @@
using base::android::AttachCurrentThread;
+using BoolCallback = LocationSettingsImpl::BoolCallback;
+using PromptContext = LocationSettings::PromptContext;
+using PromptOutcome = LocationSettings::PromptOutcome;
+using PromptOutcomeCallback = LocationSettingsImpl::PromptOutcomeCallback;
+
LocationSettingsImpl::LocationSettingsImpl() {}
LocationSettingsImpl::~LocationSettingsImpl() {}
@@ -20,3 +25,54 @@ bool LocationSettingsImpl::CanSitesRequestLocationPermission(
return Java_LocationSettings_canSitesRequestLocationPermission(
env, web_contents->GetJavaWebContents());
}
+
+void LocationSettingsImpl::CanPromptToEnableSystemLocationSetting(
+ const base::Callback<void(bool can_prompt)>& callback) {
+ JNIEnv* env = AttachCurrentThread();
+ auto* callback_wrapper = new BoolCallback(callback);
+ Java_LocationSettings_canPromptToEnableSystemLocationSetting(
+ env, reinterpret_cast<jlong>(callback_wrapper));
+}
+
+void LocationSettingsImpl::PromptToEnableSystemLocationSetting(
+ const PromptContext prompt_context,
+ content::WebContents* web_contents,
+ const base::Callback<void(PromptOutcome prompt_outcome)>& callback) {
+ JNIEnv* env = AttachCurrentThread();
+ auto* callback_wrapper = new PromptOutcomeCallback(callback);
+ Java_LocationSettings_promptToEnableSystemLocationSetting(
+ env, prompt_context, web_contents->GetJavaWebContents(),
+ reinterpret_cast<jlong>(callback_wrapper));
+}
+
+BoolCallback::BoolCallback(
+ const base::Callback<void(bool can_prompt)>& callback)
+ : callback_(callback) {}
+
+BoolCallback::~BoolCallback() {}
+
+void BoolCallback::RunBoolCallback(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ bool result) {
+ callback_.Run(result);
+ delete this;
+}
+
+PromptOutcomeCallback::PromptOutcomeCallback(
+ const base::Callback<void(PromptOutcome prompt_outcome)>& callback)
+ : callback_(callback) {}
+
+PromptOutcomeCallback::~PromptOutcomeCallback() {}
+
+void PromptOutcomeCallback::RunPromptOutcomeCallback(
+ JNIEnv* env,
+ const base::android::JavaParamRef<jobject>& obj,
+ int result) {
+ callback_.Run(static_cast<PromptOutcome>(result));
+ delete this;
+}
+
+bool LocationSettingsImpl::Register(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}

Powered by Google App Engine
This is Rietveld 408576698