| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/location_settings_impl.h" | 5 #include "chrome/browser/android/location_settings_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
| 9 #include "jni/LocationSettings_jni.h" | 9 #include "jni/LocationSettings_jni.h" |
| 10 | 10 |
| 11 using base::android::AttachCurrentThread; | 11 using base::android::AttachCurrentThread; |
| 12 | 12 |
| 13 using LocationSettingsDialogOutcomeCallback = | 13 using LocationSettingsDialogOutcomeCallback = |
| 14 LocationSettings::LocationSettingsDialogOutcomeCallback; | 14 LocationSettings::LocationSettingsDialogOutcomeCallback; |
| 15 | 15 |
| 16 LocationSettingsImpl::LocationSettingsImpl() {} | 16 LocationSettingsImpl::LocationSettingsImpl() {} |
| 17 | 17 |
| 18 LocationSettingsImpl::~LocationSettingsImpl() {} | 18 LocationSettingsImpl::~LocationSettingsImpl() {} |
| 19 | 19 |
| 20 bool LocationSettingsImpl::CanSitesRequestLocationPermission( | 20 bool LocationSettingsImpl::HasAndroidLocationPermission() { |
| 21 JNIEnv* env = AttachCurrentThread(); |
| 22 return Java_LocationSettings_hasAndroidLocationPermission(env); |
| 23 } |
| 24 |
| 25 bool LocationSettingsImpl::CanPromptForAndroidLocationPermission( |
| 21 content::WebContents* web_contents) { | 26 content::WebContents* web_contents) { |
| 22 JNIEnv* env = AttachCurrentThread(); | 27 JNIEnv* env = AttachCurrentThread(); |
| 23 return Java_LocationSettings_canSitesRequestLocationPermission( | 28 return Java_LocationSettings_canPromptForAndroidLocationPermission( |
| 24 env, web_contents->GetJavaWebContents()); | 29 env, web_contents->GetJavaWebContents()); |
| 25 } | 30 } |
| 26 | 31 |
| 32 bool LocationSettingsImpl::IsSystemLocationSettingEnabled() { |
| 33 JNIEnv* env = AttachCurrentThread(); |
| 34 return Java_LocationSettings_isSystemLocationSettingEnabled(env); |
| 35 } |
| 36 |
| 27 bool LocationSettingsImpl::CanPromptToEnableSystemLocationSetting() { | 37 bool LocationSettingsImpl::CanPromptToEnableSystemLocationSetting() { |
| 28 JNIEnv* env = AttachCurrentThread(); | 38 JNIEnv* env = AttachCurrentThread(); |
| 29 return Java_LocationSettings_canPromptToEnableSystemLocationSetting(env); | 39 return Java_LocationSettings_canPromptToEnableSystemLocationSetting(env); |
| 30 } | 40 } |
| 31 | 41 |
| 32 void LocationSettingsImpl::PromptToEnableSystemLocationSetting( | 42 void LocationSettingsImpl::PromptToEnableSystemLocationSetting( |
| 33 const LocationSettingsDialogContext prompt_context, | 43 const LocationSettingsDialogContext prompt_context, |
| 34 content::WebContents* web_contents, | 44 content::WebContents* web_contents, |
| 35 LocationSettingsDialogOutcomeCallback callback) { | 45 LocationSettingsDialogOutcomeCallback callback) { |
| 36 JNIEnv* env = AttachCurrentThread(); | 46 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 54 reinterpret_cast<LocationSettingsDialogOutcomeCallback*>(callback_ptr); | 64 reinterpret_cast<LocationSettingsDialogOutcomeCallback*>(callback_ptr); |
| 55 std::move(*callback).Run(static_cast<LocationSettingsDialogOutcome>(result)); | 65 std::move(*callback).Run(static_cast<LocationSettingsDialogOutcome>(result)); |
| 56 // Destroy the callback whose ownership was transferred in | 66 // Destroy the callback whose ownership was transferred in |
| 57 // PromptToEnableSystemLocationSetting. | 67 // PromptToEnableSystemLocationSetting. |
| 58 delete callback; | 68 delete callback; |
| 59 } | 69 } |
| 60 | 70 |
| 61 bool LocationSettingsImpl::Register(JNIEnv* env) { | 71 bool LocationSettingsImpl::Register(JNIEnv* env) { |
| 62 return RegisterNativesImpl(env); | 72 return RegisterNativesImpl(env); |
| 63 } | 73 } |
| OLD | NEW |