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

Side by Side Diff: android_webview/native/aw_geolocation_permission_context.cc

Issue 273523007: Dispatch geolocation IPCs on the UI thread. Aside from simplifying the code to avoid a lot of threa… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 6 years, 7 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
« no previous file with comments | « android_webview/native/aw_geolocation_permission_context.h ('k') | base/callback_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 13
14 namespace android_webview { 14 namespace android_webview {
15 15
16 AwGeolocationPermissionContext::~AwGeolocationPermissionContext() { 16 AwGeolocationPermissionContext::~AwGeolocationPermissionContext() {
17 } 17 }
18 18
19 void 19 void AwGeolocationPermissionContext::RequestGeolocationPermission(
20 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread( 20 content::WebContents* web_contents,
21 int render_process_id,
22 int render_view_id,
23 int bridge_id, 21 int bridge_id,
24 const GURL& requesting_frame, 22 const GURL& requesting_frame,
25 bool user_gesture, 23 bool user_gesture,
26 base::Callback<void(bool)> callback) { 24 base::Callback<void(bool)> callback) {
27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 25 AwContents* aw_contents = AwContents::FromWebContents(web_contents);
28
29 AwContents* aw_contents =
30 AwContents::FromID(render_process_id, render_view_id);
31 if (!aw_contents) { 26 if (!aw_contents) {
32 callback.Run(false); 27 callback.Run(false);
33 return; 28 return;
34 } 29 }
35 aw_contents->ShowGeolocationPrompt(requesting_frame, callback); 30 aw_contents->ShowGeolocationPrompt(requesting_frame, callback);
36 } 31 }
37 32
38 void
39 AwGeolocationPermissionContext::RequestGeolocationPermission(
40 int render_process_id,
41 int render_view_id,
42 int bridge_id,
43 const GURL& requesting_frame,
44 bool user_gesture,
45 base::Callback<void(bool)> callback) {
46 content::BrowserThread::PostTask(
47 content::BrowserThread::UI, FROM_HERE,
48 base::Bind(
49 &AwGeolocationPermissionContext::
50 RequestGeolocationPermissionOnUIThread,
51 this,
52 render_process_id,
53 render_view_id,
54 bridge_id,
55 requesting_frame,
56 user_gesture,
57 callback));
58 }
59
60 // static 33 // static
61 content::GeolocationPermissionContext* 34 content::GeolocationPermissionContext*
62 AwGeolocationPermissionContext::Create(AwBrowserContext* browser_context) { 35 AwGeolocationPermissionContext::Create(AwBrowserContext* browser_context) {
63 return new AwGeolocationPermissionContext(); 36 return new AwGeolocationPermissionContext();
64 } 37 }
65 38
66 void 39 void AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
67 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread( 40 content::WebContents* web_contents,
68 int render_process_id,
69 int render_view_id,
70 int bridge_id, 41 int bridge_id,
71 const GURL& requesting_frame) { 42 const GURL& requesting_frame) {
72 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 43 AwContents* aw_contents = AwContents::FromWebContents(web_contents);
73
74 AwContents* aw_contents =
75 AwContents::FromID(render_process_id, render_view_id);
76 if (aw_contents) { 44 if (aw_contents) {
77 aw_contents->HideGeolocationPrompt(requesting_frame); 45 aw_contents->HideGeolocationPrompt(requesting_frame);
78 } 46 }
79 } 47 }
80 48
81 void
82 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
83 int render_process_id,
84 int render_view_id,
85 int bridge_id,
86 const GURL& requesting_frame) {
87 content::BrowserThread::PostTask(
88 content::BrowserThread::UI, FROM_HERE,
89 base::Bind(
90 &AwGeolocationPermissionContext::
91 CancelGeolocationPermissionRequestOnUIThread,
92 this,
93 render_process_id,
94 render_view_id,
95 bridge_id,
96 requesting_frame));
97 }
98
99 } // namespace android_webview 49 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/native/aw_geolocation_permission_context.h ('k') | base/callback_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698