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

Side by Side Diff: chrome/browser/android/location_settings_impl.cc

Issue 2709883005: Stubs for triggering the LSD in Clank (Closed)
Patch Set: Incorporate first batch of comments Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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 LocationSettingsDialogPromptOutcome =
14 LocationSettings::LocationSettingsDialogPromptOutcome;
15 using LocationSettingsDialogPromptOutcomeCallback =
16 LocationSettings::LocationSettingsDialogPromptOutcomeCallback;
17
13 LocationSettingsImpl::LocationSettingsImpl() {} 18 LocationSettingsImpl::LocationSettingsImpl() {}
14 19
15 LocationSettingsImpl::~LocationSettingsImpl() {} 20 LocationSettingsImpl::~LocationSettingsImpl() {}
16 21
17 bool LocationSettingsImpl::CanSitesRequestLocationPermission( 22 bool LocationSettingsImpl::CanSitesRequestLocationPermission(
18 content::WebContents* web_contents) { 23 content::WebContents* web_contents) {
19 JNIEnv* env = AttachCurrentThread(); 24 JNIEnv* env = AttachCurrentThread();
20 return Java_LocationSettings_canSitesRequestLocationPermission( 25 return Java_LocationSettings_canSitesRequestLocationPermission(
21 env, web_contents->GetJavaWebContents()); 26 env, web_contents->GetJavaWebContents());
22 } 27 }
28
29 bool LocationSettingsImpl::CanPromptToEnableSystemLocationSetting() {
30 JNIEnv* env = AttachCurrentThread();
31 return Java_LocationSettings_canPromptToEnableSystemLocationSetting(env);
32 }
33
34 void LocationSettingsImpl::PromptToEnableSystemLocationSetting(
35 const LocationSettingsDialogPromptContext prompt_context,
36 content::WebContents* web_contents,
37 LocationSettingsDialogPromptOutcomeCallback callback) {
38 JNIEnv* env = AttachCurrentThread();
39 auto* callback_ptr = new LocationSettingsDialogPromptOutcomeCallback(
40 std::move(callback));
41 Java_LocationSettings_promptToEnableSystemLocationSetting(
42 env, prompt_context, web_contents->GetJavaWebContents(),
43 reinterpret_cast<jlong>(callback_ptr));
44 }
45
46 static void OnLocationSettingsDialogPromptOutcomeReceived(
47 JNIEnv* env,
48 const base::android::JavaParamRef<jclass>& jcaller,
49 jlong callback_ptr,
50 int result) {
51 auto* callback =
52 reinterpret_cast<LocationSettingsDialogPromptOutcomeCallback*>(
53 callback_ptr);
54 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!
55 result));
56 delete callback;
57 }
58
59 bool LocationSettingsImpl::Register(JNIEnv* env) {
60 return RegisterNativesImpl(env);
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698