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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_geolocation_permission_context.cc

Issue 185813004: [Geolocation] Attach user gesture indicator to permission request call. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch android Created 6 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/browser_plugin/browser_plugin_geolocation_permission_c ontext.h" 5 #include "content/browser/browser_plugin/browser_plugin_geolocation_permission_c ontext.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" 8 #include "content/browser/browser_plugin/browser_plugin_guest.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
11 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
12 #include "content/public/browser/render_view_host.h" 12 #include "content/public/browser/render_view_host.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 BrowserPluginGeolocationPermissionContext:: 16 BrowserPluginGeolocationPermissionContext::
17 BrowserPluginGeolocationPermissionContext() { 17 BrowserPluginGeolocationPermissionContext() {
18 } 18 }
19 19
20 BrowserPluginGeolocationPermissionContext:: 20 BrowserPluginGeolocationPermissionContext::
21 ~BrowserPluginGeolocationPermissionContext() { 21 ~BrowserPluginGeolocationPermissionContext() {
22 } 22 }
23 23
24 void BrowserPluginGeolocationPermissionContext::RequestGeolocationPermission( 24 void BrowserPluginGeolocationPermissionContext::RequestGeolocationPermission(
25 int render_process_id, 25 int render_process_id,
26 int render_view_id, 26 int render_view_id,
27 int bridge_id, 27 int bridge_id,
28 const GURL& requesting_frame, 28 const GURL& requesting_frame,
29 bool user_gesture,
29 base::Callback<void(bool)> callback) { 30 base::Callback<void(bool)> callback) {
30 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 31 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
31 BrowserThread::PostTask( 32 BrowserThread::PostTask(
32 BrowserThread::UI, FROM_HERE, 33 BrowserThread::UI, FROM_HERE,
33 base::Bind( 34 base::Bind(
34 &BrowserPluginGeolocationPermissionContext:: 35 &BrowserPluginGeolocationPermissionContext::
35 RequestGeolocationPermission, 36 RequestGeolocationPermission,
36 this, 37 this,
37 render_process_id, 38 render_process_id,
38 render_view_id, 39 render_view_id,
39 bridge_id, 40 bridge_id,
40 requesting_frame, 41 requesting_frame,
42 user_gesture,
41 callback)); 43 callback));
42 return; 44 return;
43 } 45 }
44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
45 47
46 // Note that callback.Run(true) allows geolocation access, callback.Run(false) 48 // Note that callback.Run(true) allows geolocation access, callback.Run(false)
47 // denies geolocation access. 49 // denies geolocation access.
48 // We need to go to the renderer to ask embedder's js if we are allowed to 50 // We need to go to the renderer to ask embedder's js if we are allowed to
49 // have geolocation access. 51 // have geolocation access.
50 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id, 52 RenderViewHost* rvh = RenderViewHost::FromID(render_process_id,
51 render_view_id); 53 render_view_id);
52 if (rvh) { 54 if (rvh) {
53 DCHECK(rvh->GetProcess()->IsGuest()); 55 DCHECK(rvh->GetProcess()->IsGuest());
54 WebContentsImpl* guest_web_contents = 56 WebContentsImpl* guest_web_contents =
55 static_cast<WebContentsImpl*>(rvh->GetDelegate()->GetAsWebContents()); 57 static_cast<WebContentsImpl*>(rvh->GetDelegate()->GetAsWebContents());
56 BrowserPluginGuest* guest = guest_web_contents->GetBrowserPluginGuest(); 58 BrowserPluginGuest* guest = guest_web_contents->GetBrowserPluginGuest();
57 guest->AskEmbedderForGeolocationPermission(bridge_id, 59 guest->AskEmbedderForGeolocationPermission(bridge_id,
58 requesting_frame, 60 requesting_frame,
61 user_gesture,
59 callback); 62 callback);
60 } 63 }
61 } 64 }
62 65
63 void BrowserPluginGeolocationPermissionContext:: 66 void BrowserPluginGeolocationPermissionContext::
64 CancelGeolocationPermissionRequest(int render_process_id, 67 CancelGeolocationPermissionRequest(int render_process_id,
65 int render_view_id, 68 int render_view_id,
66 int bridge_id, 69 int bridge_id,
67 const GURL& requesting_frame) { 70 const GURL& requesting_frame) {
68 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 71 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
(...skipping 16 matching lines...) Expand all
85 DCHECK(rvh->GetProcess()->IsGuest()); 88 DCHECK(rvh->GetProcess()->IsGuest());
86 WebContentsImpl* guest_web_contents = 89 WebContentsImpl* guest_web_contents =
87 static_cast<WebContentsImpl*>(rvh->GetDelegate()->GetAsWebContents()); 90 static_cast<WebContentsImpl*>(rvh->GetDelegate()->GetAsWebContents());
88 BrowserPluginGuest* guest = guest_web_contents->GetBrowserPluginGuest(); 91 BrowserPluginGuest* guest = guest_web_contents->GetBrowserPluginGuest();
89 if (guest) 92 if (guest)
90 guest->CancelGeolocationRequest(bridge_id); 93 guest->CancelGeolocationRequest(bridge_id);
91 } 94 }
92 } 95 }
93 96
94 } // namespace content 97 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698