summaryrefslogtreecommitdiffstats
path: root/android_webview/native
diff options
context:
space:
mode:
authorkristianm@chromium.org <kristianm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-10 05:51:42 +0000
committerkristianm@chromium.org <kristianm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-10 05:51:42 +0000
commit4230ed9095c681d12b65cfab479672a2e7da247c (patch)
treea25d83eee1bdc0f48461f05e1436eb311bfd92d7 /android_webview/native
parent3b78761f7f74fafc2980c07ea4e13ea07a9526b7 (diff)
downloadchromium_src-4230ed9095c681d12b65cfab479672a2e7da247c.zip
chromium_src-4230ed9095c681d12b65cfab479672a2e7da247c.tar.gz
chromium_src-4230ed9095c681d12b65cfab479672a2e7da247c.tar.bz2
Implementing native chromium GeolocationPermissionContext
BUG= Review URL: https://chromiumcodereview.appspot.com/11763002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview/native')
-rw-r--r--android_webview/native/aw_contents.cc16
-rw-r--r--android_webview/native/aw_contents.h7
-rw-r--r--android_webview/native/aw_geolocation_permission_context.cc103
-rw-r--r--android_webview/native/aw_geolocation_permission_context.h60
-rw-r--r--android_webview/native/webview_native.gyp2
5 files changed, 188 insertions, 0 deletions
diff --git a/android_webview/native/aw_contents.cc b/android_webview/native/aw_contents.cc
index 4974fb6..a44fb06 100644
--- a/android_webview/native/aw_contents.cc
+++ b/android_webview/native/aw_contents.cc
@@ -614,6 +614,22 @@ bool RegisterAwContents(JNIEnv* env) {
return RegisterNativesImpl(env) >= 0;
}
+void AwContents::OnGeolocationShowPrompt(int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame) {
+ JNIEnv* env = AttachCurrentThread();
+ ScopedJavaLocalRef<jstring> j_requesting_frame(
+ ConvertUTF8ToJavaString(env, requesting_frame.spec()));
+ Java_AwContents_onGeolocationPermissionsShowPrompt(env,
+ java_ref_.get(env).obj(), render_process_id, render_view_id, bridge_id,
+ j_requesting_frame.obj());
+}
+
+void AwContents::OnGeolocationHidePrompt() {
+ // TODO(kristianm): Implement this
+}
+
jint AwContents::FindAllSync(JNIEnv* env, jobject obj, jstring search_string) {
return GetFindHelper()->FindAllSync(
ConvertJavaStringToUTF16(env, search_string));
diff --git a/android_webview/native/aw_contents.h b/android_webview/native/aw_contents.h
index ef39c56..6d02482 100644
--- a/android_webview/native/aw_contents.h
+++ b/android_webview/native/aw_contents.h
@@ -102,6 +102,13 @@ class AwContents : public FindHelper::Listener,
int scroll_x, int scroll_y);
void FocusFirstNode(JNIEnv* env, jobject obj);
+ // Geolocation API support
+ void OnGeolocationShowPrompt(int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame);
+ void OnGeolocationHidePrompt();
+
// Find-in-page API and related methods.
jint FindAllSync(JNIEnv* env, jobject obj, jstring search_string);
void FindAllAsync(JNIEnv* env, jobject obj, jstring search_string);
diff --git a/android_webview/native/aw_geolocation_permission_context.cc b/android_webview/native/aw_geolocation_permission_context.cc
new file mode 100644
index 0000000..959c464
--- /dev/null
+++ b/android_webview/native/aw_geolocation_permission_context.cc
@@ -0,0 +1,103 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "android_webview/native/aw_geolocation_permission_context.h"
+
+#include "android_webview/native/aw_contents.h"
+#include "base/bind.h"
+#include "base/callback.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
+#include "googleurl/src/gurl.h"
+
+namespace android_webview {
+
+AwGeolocationPermissionContext::~AwGeolocationPermissionContext() {
+}
+
+void
+AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ base::Callback<void(bool)> callback) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ const content::RenderViewHost* host =
+ content::RenderViewHost::FromID(render_process_id, render_view_id);
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderViewHost(host);
+ AwContents* aw_contents = AwContents::FromWebContents(web_contents);
+ aw_contents->OnGeolocationShowPrompt(
+ render_process_id,
+ render_view_id,
+ bridge_id,
+ requesting_frame);
+}
+
+void
+AwGeolocationPermissionContext::RequestGeolocationPermission(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ base::Callback<void(bool)> callback) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(
+ &AwGeolocationPermissionContext::
+ RequestGeolocationPermissionOnUIThread,
+ this,
+ render_process_id,
+ render_view_id,
+ bridge_id,
+ requesting_frame,
+ callback));
+}
+
+// static
+content::GeolocationPermissionContext*
+AwGeolocationPermissionContext::Create() {
+ return new AwGeolocationPermissionContext();
+}
+
+void
+AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ // TODO(kristianm): Implement this
+}
+
+void
+AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame) {
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(
+ &AwGeolocationPermissionContext::
+ CancelGeolocationPermissionRequestOnUIThread,
+ this,
+ render_process_id,
+ render_view_id,
+ bridge_id,
+ requesting_frame));
+}
+
+void InvokeCallback(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ bool value) {
+ // TODO(kristianm): Implement this
+}
+
+} // namespace android_webview
diff --git a/android_webview/native/aw_geolocation_permission_context.h b/android_webview/native/aw_geolocation_permission_context.h
new file mode 100644
index 0000000..3235c4d
--- /dev/null
+++ b/android_webview/native/aw_geolocation_permission_context.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ANDROID_WEBVIEW_NATIVE_AW_GEOLOCATION_PERMISSION_CONTEXT_H_
+#define ANDROID_WEBVIEW_NATIVE_AW_GEOLOCATION_PERMISSION_CONTEXT_H_
+
+#include "base/callback_forward.h"
+#include "content/public/browser/geolocation_permission_context.h"
+
+class GURL;
+
+namespace android_webview {
+
+class AwGeolocationPermissionContext :
+ public content::GeolocationPermissionContext {
+ public:
+ static content::GeolocationPermissionContext* Create();
+
+ // content::GeolocationPermissionContext implementation
+ virtual void RequestGeolocationPermission(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ base::Callback<void(bool)> callback) OVERRIDE;
+ virtual void CancelGeolocationPermissionRequest(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame) OVERRIDE;
+
+ void InvokeCallback(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ bool value);
+
+ protected:
+ virtual ~AwGeolocationPermissionContext();
+
+ private:
+ void RequestGeolocationPermissionOnUIThread(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame,
+ base::Callback<void(bool)> callback);
+
+ void CancelGeolocationPermissionRequestOnUIThread(
+ int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame);
+};
+
+} // namespace android_webview
+
+#endif // ANDROID_WEBVIEW_NATIVE_AW_GEOLOCATION_PERMISSION_CONTEXT_H_
diff --git a/android_webview/native/webview_native.gyp b/android_webview/native/webview_native.gyp
index 3ecb1a6..2d29820 100644
--- a/android_webview/native/webview_native.gyp
+++ b/android_webview/native/webview_native.gyp
@@ -32,6 +32,8 @@
'aw_contents.h',
'aw_contents_io_thread_client_impl.cc',
'aw_contents_io_thread_client_impl.h',
+ 'aw_geolocation_permission_context.cc',
+ 'aw_geolocation_permission_context.h',
'aw_http_auth_handler.cc',
'aw_http_auth_handler.h',
'aw_javascript_dialog_creator.cc',