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

Unified Diff: android_webview/native/aw_geolocation_permission_context.cc

Issue 12211047: Implementing geolocation for the Android Webview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed issues from reviews Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/native/aw_geolocation_permission_context.cc
diff --git a/android_webview/native/aw_geolocation_permission_context.cc b/android_webview/native/aw_geolocation_permission_context.cc
index 959c4647c54dfeeb6fe5201466b3f1057f59fb63..cc7f8e1e1543e097ec98b3912df83e5864ac22b3 100644
--- a/android_webview/native/aw_geolocation_permission_context.cc
+++ b/android_webview/native/aw_geolocation_permission_context.cc
@@ -10,13 +10,36 @@
#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() {
}
+namespace {
+
+// TODO(kristianm): Removed this when https://codereview.chromium.org/12207061/
benm (inactive) 2013/02/07 17:22:39 guess you can do this now :)
Kristian Monsen 2013/02/08 00:07:44 Done. I didn't send out a review mail for this pat
+// has landed
+AwContents* GetAwContents(int render_process_id,
+ int render_view_id,
+ int bridge_id) {
+ const content::RenderViewHost* rvh =
+ content::RenderViewHost::FromID(render_process_id, render_view_id);
+ if (!rvh) {
+ return NULL;
+ }
+
+ content::WebContents* web_contents =
+ content::WebContents::FromRenderViewHost(rvh);
+ if (!web_contents) {
+ return NULL;
+ }
+
+ return AwContents::FromWebContents(web_contents);
+}
+
+} // anonymous namespace
+
void
AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread(
int render_process_id,
@@ -25,16 +48,14 @@ AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread(
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);
+
+ AwContents* aw_contents =
+ GetAwContents(render_process_id, render_view_id, bridge_id);
+ if (!aw_contents) {
+ callback.Run(false);
+ return;
+ }
+ aw_contents->OnGeolocationShowPrompt(requesting_frame, callback);
}
void
@@ -70,7 +91,12 @@ AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread(
int bridge_id,
const GURL& requesting_frame) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- // TODO(kristianm): Implement this
+
+ AwContents* aw_contents =
+ GetAwContents(render_process_id, render_view_id, bridge_id);
+ if (aw_contents) {
+ aw_contents->OnGeolocationHidePrompt(requesting_frame);
+ }
}
void
@@ -91,13 +117,4 @@ AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
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

Powered by Google App Engine
This is Rietveld 408576698