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

Side by Side 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, 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 BoolCallback = LocationSettingsImpl::BoolCallback;
14 using PromptContext = LocationSettings::PromptContext;
15 using PromptOutcome = LocationSettings::PromptOutcome;
16 using PromptOutcomeCallback = LocationSettingsImpl::PromptOutcomeCallback;
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 void LocationSettingsImpl::CanPromptToEnableSystemLocationSetting(
30 const base::Callback<void(bool can_prompt)>& callback) {
31 JNIEnv* env = AttachCurrentThread();
32 auto* callback_wrapper = new BoolCallback(callback);
33 Java_LocationSettings_canPromptToEnableSystemLocationSetting(
34 env, reinterpret_cast<jlong>(callback_wrapper));
35 }
36
37 void LocationSettingsImpl::PromptToEnableSystemLocationSetting(
38 const PromptContext prompt_context,
39 content::WebContents* web_contents,
40 const base::Callback<void(PromptOutcome prompt_outcome)>& callback) {
41 JNIEnv* env = AttachCurrentThread();
42 auto* callback_wrapper = new PromptOutcomeCallback(callback);
43 Java_LocationSettings_promptToEnableSystemLocationSetting(
44 env, prompt_context, web_contents->GetJavaWebContents(),
45 reinterpret_cast<jlong>(callback_wrapper));
46 }
47
48 BoolCallback::BoolCallback(
49 const base::Callback<void(bool can_prompt)>& callback)
50 : callback_(callback) {}
51
52 BoolCallback::~BoolCallback() {}
53
54 void BoolCallback::RunBoolCallback(
55 JNIEnv* env,
56 const base::android::JavaParamRef<jobject>& obj,
57 bool result) {
58 callback_.Run(result);
59 delete this;
60 }
61
62 PromptOutcomeCallback::PromptOutcomeCallback(
63 const base::Callback<void(PromptOutcome prompt_outcome)>& callback)
64 : callback_(callback) {}
65
66 PromptOutcomeCallback::~PromptOutcomeCallback() {}
67
68 void PromptOutcomeCallback::RunPromptOutcomeCallback(
69 JNIEnv* env,
70 const base::android::JavaParamRef<jobject>& obj,
71 int result) {
72 callback_.Run(static_cast<PromptOutcome>(result));
73 delete this;
74 }
75
76 bool LocationSettingsImpl::Register(JNIEnv* env) {
77 return RegisterNativesImpl(env);
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698