| 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 #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 |
| 29 content::RenderViewHost::FromID(render_process_id, render_view_id); | 28 AwContents* aw_contents = |
| 30 content::WebContents* web_contents = | 29 AwContents::FromID(render_process_id, render_view_id); |
| 31 content::WebContents::FromRenderViewHost(host); | 30 if (!aw_contents) { |
| 32 AwContents* aw_contents = AwContents::FromWebContents(web_contents); | 31 callback.Run(false); |
| 33 aw_contents->OnGeolocationShowPrompt( | 32 return; |
| 34 render_process_id, | 33 } |
| 35 render_view_id, | 34 aw_contents->ShowGeolocationPrompt(requesting_frame, callback); |
| 36 bridge_id, | |
| 37 requesting_frame); | |
| 38 } | 35 } |
| 39 | 36 |
| 40 void | 37 void |
| 41 AwGeolocationPermissionContext::RequestGeolocationPermission( | 38 AwGeolocationPermissionContext::RequestGeolocationPermission( |
| 42 int render_process_id, | 39 int render_process_id, |
| 43 int render_view_id, | 40 int render_view_id, |
| 44 int bridge_id, | 41 int bridge_id, |
| 45 const GURL& requesting_frame, | 42 const GURL& requesting_frame, |
| 46 base::Callback<void(bool)> callback) { | 43 base::Callback<void(bool)> callback) { |
| 47 content::BrowserThread::PostTask( | 44 content::BrowserThread::PostTask( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 return new AwGeolocationPermissionContext(); | 60 return new AwGeolocationPermissionContext(); |
| 64 } | 61 } |
| 65 | 62 |
| 66 void | 63 void |
| 67 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread( | 64 AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread( |
| 68 int render_process_id, | 65 int render_process_id, |
| 69 int render_view_id, | 66 int render_view_id, |
| 70 int bridge_id, | 67 int bridge_id, |
| 71 const GURL& requesting_frame) { | 68 const GURL& requesting_frame) { |
| 72 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 73 // TODO(kristianm): Implement this | 70 |
| 71 AwContents* aw_contents = |
| 72 AwContents::FromID(render_process_id, render_view_id); |
| 73 if (aw_contents) { |
| 74 aw_contents->HideGeolocationPrompt(requesting_frame); |
| 75 } |
| 74 } | 76 } |
| 75 | 77 |
| 76 void | 78 void |
| 77 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest( | 79 AwGeolocationPermissionContext::CancelGeolocationPermissionRequest( |
| 78 int render_process_id, | 80 int render_process_id, |
| 79 int render_view_id, | 81 int render_view_id, |
| 80 int bridge_id, | 82 int bridge_id, |
| 81 const GURL& requesting_frame) { | 83 const GURL& requesting_frame) { |
| 82 content::BrowserThread::PostTask( | 84 content::BrowserThread::PostTask( |
| 83 content::BrowserThread::UI, FROM_HERE, | 85 content::BrowserThread::UI, FROM_HERE, |
| 84 base::Bind( | 86 base::Bind( |
| 85 &AwGeolocationPermissionContext:: | 87 &AwGeolocationPermissionContext:: |
| 86 CancelGeolocationPermissionRequestOnUIThread, | 88 CancelGeolocationPermissionRequestOnUIThread, |
| 87 this, | 89 this, |
| 88 render_process_id, | 90 render_process_id, |
| 89 render_view_id, | 91 render_view_id, |
| 90 bridge_id, | 92 bridge_id, |
| 91 requesting_frame)); | 93 requesting_frame)); |
| 92 } | 94 } |
| 93 | 95 |
| 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 | 96 } // namespace android_webview |
| OLD | NEW |