| OLD | NEW |
| 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 |
| 20 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread( | 20 AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread( |
| 21 int render_process_id, | 21 int render_process_id, |
| 22 int render_view_id, | 22 int render_view_id, |
| 23 int bridge_id, | 23 int bridge_id, |
| 24 const GURL& requesting_frame, | 24 const GURL& requesting_frame, |
| 25 bool user_gesture, |
| 25 base::Callback<void(bool)> callback) { | 26 base::Callback<void(bool)> callback) { |
| 26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 27 | 28 |
| 28 AwContents* aw_contents = | 29 AwContents* aw_contents = |
| 29 AwContents::FromID(render_process_id, render_view_id); | 30 AwContents::FromID(render_process_id, render_view_id); |
| 30 if (!aw_contents) { | 31 if (!aw_contents) { |
| 31 callback.Run(false); | 32 callback.Run(false); |
| 32 return; | 33 return; |
| 33 } | 34 } |
| 34 aw_contents->ShowGeolocationPrompt(requesting_frame, callback); | 35 aw_contents->ShowGeolocationPrompt(requesting_frame, callback); |
| 35 } | 36 } |
| 36 | 37 |
| 37 void | 38 void |
| 38 AwGeolocationPermissionContext::RequestGeolocationPermission( | 39 AwGeolocationPermissionContext::RequestGeolocationPermission( |
| 39 int render_process_id, | 40 int render_process_id, |
| 40 int render_view_id, | 41 int render_view_id, |
| 41 int bridge_id, | 42 int bridge_id, |
| 42 const GURL& requesting_frame, | 43 const GURL& requesting_frame, |
| 44 bool user_gesture, |
| 43 base::Callback<void(bool)> callback) { | 45 base::Callback<void(bool)> callback) { |
| 44 content::BrowserThread::PostTask( | 46 content::BrowserThread::PostTask( |
| 45 content::BrowserThread::UI, FROM_HERE, | 47 content::BrowserThread::UI, FROM_HERE, |
| 46 base::Bind( | 48 base::Bind( |
| 47 &AwGeolocationPermissionContext:: | 49 &AwGeolocationPermissionContext:: |
| 48 RequestGeolocationPermissionOnUIThread, | 50 RequestGeolocationPermissionOnUIThread, |
| 49 this, | 51 this, |
| 50 render_process_id, | 52 render_process_id, |
| 51 render_view_id, | 53 render_view_id, |
| 52 bridge_id, | 54 bridge_id, |
| 53 requesting_frame, | 55 requesting_frame, |
| 56 user_gesture, |
| 54 callback)); | 57 callback)); |
| 55 } | 58 } |
| 56 | 59 |
| 57 // static | 60 // static |
| 58 content::GeolocationPermissionContext* | 61 content::GeolocationPermissionContext* |
| 59 AwGeolocationPermissionContext::Create(AwBrowserContext* browser_context) { | 62 AwGeolocationPermissionContext::Create(AwBrowserContext* browser_context) { |
| 60 return new AwGeolocationPermissionContext(); | 63 return new AwGeolocationPermissionContext(); |
| 61 } | 64 } |
| 62 | 65 |
| 63 void | 66 void |
| (...skipping 23 matching lines...) Expand all Loading... |
| 87 &AwGeolocationPermissionContext:: | 90 &AwGeolocationPermissionContext:: |
| 88 CancelGeolocationPermissionRequestOnUIThread, | 91 CancelGeolocationPermissionRequestOnUIThread, |
| 89 this, | 92 this, |
| 90 render_process_id, | 93 render_process_id, |
| 91 render_view_id, | 94 render_view_id, |
| 92 bridge_id, | 95 bridge_id, |
| 93 requesting_frame)); | 96 requesting_frame)); |
| 94 } | 97 } |
| 95 | 98 |
| 96 } // namespace android_webview | 99 } // namespace android_webview |
| OLD | NEW |