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

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: Minor style updates 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
20 void 19 void
21 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread( 20 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread(
22 int render_process_id, 21 int render_process_id,
23 int render_view_id, 22 int render_view_id,
24 int bridge_id, 23 int bridge_id,
25 const GURL& requesting_frame, 24 const GURL& requesting_frame,
26 base::Callback<void(bool)> callback) { 25 base::Callback<void(bool)> callback) {
27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
28 const content::RenderViewHost* host = 27
28 const content::RenderViewHost* rvh =
boliu 2013/02/06 20:29:54 Is this id->AwContents code duplicated with Selim'
Kristian Monsen 2013/02/08 00:07:44 Coordinating with Selim, will use that before land
29 content::RenderViewHost::FromID(render_process_id, render_view_id); 29 content::RenderViewHost::FromID(render_process_id, render_view_id);
30 if (!rvh) {
31 callback.Run(false);
32 return;
33 }
34
30 content::WebContents* web_contents = 35 content::WebContents* web_contents =
31 content::WebContents::FromRenderViewHost(host); 36 content::WebContents::FromRenderViewHost(rvh);
37 if (!web_contents) {
38 callback.Run(false);
39 return;
40 }
41
32 AwContents* aw_contents = AwContents::FromWebContents(web_contents); 42 AwContents* aw_contents = AwContents::FromWebContents(web_contents);
33 aw_contents->OnGeolocationShowPrompt( 43 if (!aw_contents) {
34 render_process_id, 44 callback.Run(false);
35 render_view_id, 45 return;
36 bridge_id, 46 }
joth 2013/02/06 22:09:51 yeah, this will all be cleaner with a method facto
Kristian Monsen 2013/02/08 00:07:44 Done.
37 requesting_frame); 47
48 aw_contents->OnGeolocationShowPrompt(requesting_frame, callback);
38 } 49 }
39 50
40 void 51 void
41 AwGeolocationPermissionContext::RequestGeolocationPermission( 52 AwGeolocationPermissionContext::RequestGeolocationPermission(
42 int render_process_id, 53 int render_process_id,
43 int render_view_id, 54 int render_view_id,
44 int bridge_id, 55 int bridge_id,
45 const GURL& requesting_frame, 56 const GURL& requesting_frame,
46 base::Callback<void(bool)> callback) { 57 base::Callback<void(bool)> callback) {
47 content::BrowserThread::PostTask( 58 content::BrowserThread::PostTask(
(...skipping 15 matching lines...) Expand all
63 return new AwGeolocationPermissionContext(); 74 return new AwGeolocationPermissionContext();
64 } 75 }
65 76
66 void 77 void
67 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread( 78 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread(
68 int render_process_id, 79 int render_process_id,
69 int render_view_id, 80 int render_view_id,
70 int bridge_id, 81 int bridge_id,
71 const GURL& requesting_frame) { 82 const GURL& requesting_frame) {
72 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 83 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
73 // TODO(kristianm): Implement this 84
85 const content::RenderViewHost* rvh =
boliu 2013/02/06 20:29:54 Certainly don't duplicate this logic twice in the
Kristian Monsen 2013/02/08 00:07:44 Done.
86 content::RenderViewHost::FromID(render_process_id, render_view_id);
87 if (!rvh) {
88 return;
89 }
90
91 content::WebContents* web_contents =
92 content::WebContents::FromRenderViewHost(rvh);
93 if (!web_contents) {
94 return;
95 }
96
97 AwContents* aw_contents = AwContents::FromWebContents(web_contents);
98 if (aw_contents) {
99 aw_contents->OnGeolocationHidePrompt(requesting_frame);
100 }
74 } 101 }
75 102
76 void 103 void
77 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest( 104 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
78 int render_process_id, 105 int render_process_id,
79 int render_view_id, 106 int render_view_id,
80 int bridge_id, 107 int bridge_id,
81 const GURL& requesting_frame) { 108 const GURL& requesting_frame) {
82 content::BrowserThread::PostTask( 109 content::BrowserThread::PostTask(
83 content::BrowserThread::UI, FROM_HERE, 110 content::BrowserThread::UI, FROM_HERE,
84 base::Bind( 111 base::Bind(
85 &AwGeolocationPermissionContext:: 112 &AwGeolocationPermissionContext::
86 CancelGeolocationPermissionRequestOnUIThread, 113 CancelGeolocationPermissionRequestOnUIThread,
87 this, 114 this,
88 render_process_id, 115 render_process_id,
89 render_view_id, 116 render_view_id,
90 bridge_id, 117 bridge_id,
91 requesting_frame)); 118 requesting_frame));
92 } 119 }
93 120
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 121 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698