Chromium Code Reviews| 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..aef9b99c298a6181d1324cc71284c03f977beb8d 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 LocationSettingsDialogPromptOutcome = |
| + LocationSettings::LocationSettingsDialogPromptOutcome; |
| +using LocationSettingsDialogPromptOutcomeCallback = |
| + LocationSettings::LocationSettingsDialogPromptOutcomeCallback; |
| + |
| LocationSettingsImpl::LocationSettingsImpl() {} |
| LocationSettingsImpl::~LocationSettingsImpl() {} |
| @@ -20,3 +25,37 @@ 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 LocationSettingsDialogPromptContext prompt_context, |
| + content::WebContents* web_contents, |
| + LocationSettingsDialogPromptOutcomeCallback callback) { |
| + JNIEnv* env = AttachCurrentThread(); |
| + auto* callback_ptr = new LocationSettingsDialogPromptOutcomeCallback( |
| + std::move(callback)); |
| + Java_LocationSettings_promptToEnableSystemLocationSetting( |
| + env, prompt_context, web_contents->GetJavaWebContents(), |
| + reinterpret_cast<jlong>(callback_ptr)); |
| +} |
| + |
| +static void OnLocationSettingsDialogPromptOutcomeReceived( |
| + JNIEnv* env, |
| + const base::android::JavaParamRef<jclass>& jcaller, |
| + jlong callback_ptr, |
| + int result) { |
| + auto* callback = |
| + reinterpret_cast<LocationSettingsDialogPromptOutcomeCallback*>( |
| + callback_ptr); |
| + std::move(*callback).Run(static_cast<LocationSettingsDialogPromptOutcome>( |
|
benwells
2017/03/01 03:51:27
I don't really understand the call to std::move he
qfiard
2017/03/01 08:48:18
I followed the instructions in https://cs.chromium
benwells
2017/03/01 10:47:45
Ah ... well there you go, thanks for educating me!
|
| + result)); |
| + delete callback; |
| +} |
| + |
| +bool LocationSettingsImpl::Register(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |