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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "android_webview/native/aw_geolocation_permission_context.h" 5 #include "android_webview/native/aw_geolocation_permission_context.h"
6 6
7 #include "android_webview/native/aw_contents.h" 7 #include "android_webview/native/aw_contents.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
13 #include "googleurl/src/gurl.h"
14 13
15 namespace android_webview { 14 namespace android_webview {
16 15
17 AwGeolocationPermissionContext::~AwGeolocationPermissionContext() { 16 AwGeolocationPermissionContext::~AwGeolocationPermissionContext() {
18 } 17 }
19 18
19 namespace {
20
21 // 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
22 // has landed
23 AwContents* GetAwContents(int render_process_id,
24 int render_view_id,
25 int bridge_id) {
26 const content::RenderViewHost* rvh =
27 content::RenderViewHost::FromID(render_process_id, render_view_id);
28 if (!rvh) {
29 return NULL;
30 }
31
32 content::WebContents* web_contents =
33 content::WebContents::FromRenderViewHost(rvh);
34 if (!web_contents) {
35 return NULL;
36 }
37
38 return AwContents::FromWebContents(web_contents);
39 }
40
41 } // anonymous namespace
42
20 void 43 void
21 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread( 44 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread(
22 int render_process_id, 45 int render_process_id,
23 int render_view_id, 46 int render_view_id,
24 int bridge_id, 47 int bridge_id,
25 const GURL& requesting_frame, 48 const GURL& requesting_frame,
26 base::Callback<void(bool)> callback) { 49 base::Callback<void(bool)> callback) {
27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 50 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
28 const content::RenderViewHost* host = 51
29 content::RenderViewHost::FromID(render_process_id, render_view_id); 52 AwContents* aw_contents =
30 content::WebContents* web_contents = 53 GetAwContents(render_process_id, render_view_id, bridge_id);
31 content::WebContents::FromRenderViewHost(host); 54 if (!aw_contents) {
32 AwContents* aw_contents = AwContents::FromWebContents(web_contents); 55 callback.Run(false);
33 aw_contents->OnGeolocationShowPrompt( 56 return;
34 render_process_id, 57 }
35 render_view_id, 58 aw_contents->OnGeolocationShowPrompt(requesting_frame, callback);
36 bridge_id,
37 requesting_frame);
38 } 59 }
39 60
40 void 61 void
41 AwGeolocationPermissionContext::RequestGeolocationPermission( 62 AwGeolocationPermissionContext::RequestGeolocationPermission(
42 int render_process_id, 63 int render_process_id,
43 int render_view_id, 64 int render_view_id,
44 int bridge_id, 65 int bridge_id,
45 const GURL& requesting_frame, 66 const GURL& requesting_frame,
46 base::Callback<void(bool)> callback) { 67 base::Callback<void(bool)> callback) {
47 content::BrowserThread::PostTask( 68 content::BrowserThread::PostTask(
(...skipping 15 matching lines...) Expand all
63 return new AwGeolocationPermissionContext(); 84 return new AwGeolocationPermissionContext();
64 } 85 }
65 86
66 void 87 void
67 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread( 88 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread(
68 int render_process_id, 89 int render_process_id,
69 int render_view_id, 90 int render_view_id,
70 int bridge_id, 91 int bridge_id,
71 const GURL& requesting_frame) { 92 const GURL& requesting_frame) {
72 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 93 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
73 // TODO(kristianm): Implement this 94
95 AwContents* aw_contents =
96 GetAwContents(render_process_id, render_view_id, bridge_id);
97 if (aw_contents) {
98 aw_contents->OnGeolocationHidePrompt(requesting_frame);
99 }
74 } 100 }
75 101
76 void 102 void
77 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest( 103 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
78 int render_process_id, 104 int render_process_id,
79 int render_view_id, 105 int render_view_id,
80 int bridge_id, 106 int bridge_id,
81 const GURL& requesting_frame) { 107 const GURL& requesting_frame) {
82 content::BrowserThread::PostTask( 108 content::BrowserThread::PostTask(
83 content::BrowserThread::UI, FROM_HERE, 109 content::BrowserThread::UI, FROM_HERE,
84 base::Bind( 110 base::Bind(
85 &AwGeolocationPermissionContext:: 111 &AwGeolocationPermissionContext::
86 CancelGeolocationPermissionRequestOnUIThread, 112 CancelGeolocationPermissionRequestOnUIThread,
87 this, 113 this,
88 render_process_id, 114 render_process_id,
89 render_view_id, 115 render_view_id,
90 bridge_id, 116 bridge_id,
91 requesting_frame)); 117 requesting_frame));
92 } 118 }
93 119
94 void InvokeCallback(
95 int render_process_id,
96 int render_view_id,
97 int bridge_id,
98 const GURL& requesting_frame,
99 bool value) {
100 // TODO(kristianm): Implement this
101 }
102
103 } // namespace android_webview 120 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698