1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "android_webview/native/aw_geolocation_permission_context.h"
7 #include "android_webview/native/aw_contents.h"
9 #include "base/callback.h"
10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h"
14 namespace android_webview
{
16 AwGeolocationPermissionContext::~AwGeolocationPermissionContext() {
20 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread(
21 int render_process_id
,
24 const GURL
& requesting_frame
,
25 base::Callback
<void(bool)> callback
) {
26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI
));
28 AwContents
* aw_contents
=
29 AwContents::FromID(render_process_id
, render_view_id
);
34 aw_contents
->ShowGeolocationPrompt(requesting_frame
, callback
);
38 AwGeolocationPermissionContext::RequestGeolocationPermission(
39 int render_process_id
,
42 const GURL
& requesting_frame
,
43 base::Callback
<void(bool)> callback
) {
44 content::BrowserThread::PostTask(
45 content::BrowserThread::UI
, FROM_HERE
,
47 &AwGeolocationPermissionContext::
48 RequestGeolocationPermissionOnUIThread
,
58 content::GeolocationPermissionContext
*
59 AwGeolocationPermissionContext::Create(AwBrowserContext
* browser_context
) {
60 return new AwGeolocationPermissionContext();
64 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread(
65 int render_process_id
,
68 const GURL
& requesting_frame
) {
69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI
));
71 AwContents
* aw_contents
=
72 AwContents::FromID(render_process_id
, render_view_id
);
74 aw_contents
->HideGeolocationPrompt(requesting_frame
);
79 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
80 int render_process_id
,
83 const GURL
& requesting_frame
) {
84 content::BrowserThread::PostTask(
85 content::BrowserThread::UI
, FROM_HERE
,
87 &AwGeolocationPermissionContext::
88 CancelGeolocationPermissionRequestOnUIThread
,
96 } // namespace android_webview