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

Side by Side Diff: android_webview/browser/aw_permission_manager.cc

Issue 1158813002: Use RenderFrameHost for ::RequestPermission() and ::CancelPermission(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser/aw_permission_manager.h" 5 #include "android_webview/browser/aw_permission_manager.h"
6 6
7 #include "android_webview/browser/aw_browser_permission_request_delegate.h" 7 #include "android_webview/browser/aw_browser_permission_request_delegate.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "content/public/browser/permission_type.h" 9 #include "content/public/browser/permission_type.h"
10 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/render_process_host.h" 11 #include "content/public/browser/render_process_host.h"
11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/web_contents.h"
13 12
14 namespace android_webview { 13 namespace android_webview {
15 14
16 namespace { 15 namespace {
17 16
18 void CallbackPermisisonStatusWrapper( 17 void CallbackPermisisonStatusWrapper(
19 const base::Callback<void(content::PermissionStatus)>& callback, 18 const base::Callback<void(content::PermissionStatus)>& callback,
20 bool allowed) { 19 bool allowed) {
21 callback.Run(allowed ? content::PERMISSION_STATUS_GRANTED 20 callback.Run(allowed ? content::PERMISSION_STATUS_GRANTED
22 : content::PERMISSION_STATUS_DENIED); 21 : content::PERMISSION_STATUS_DENIED);
23 } 22 }
24 23
25 } // anonymous namespace 24 } // anonymous namespace
26 25
27 AwPermissionManager::AwPermissionManager() 26 AwPermissionManager::AwPermissionManager()
28 : content::PermissionManager() { 27 : content::PermissionManager() {
29 } 28 }
30 29
31 AwPermissionManager::~AwPermissionManager() { 30 AwPermissionManager::~AwPermissionManager() {
32 } 31 }
33 32
34 void AwPermissionManager::RequestPermission( 33 void AwPermissionManager::RequestPermission(
35 content::PermissionType permission, 34 content::PermissionType permission,
36 content::WebContents* web_contents, 35 content::RenderFrameHost* render_frame_host,
37 int request_id, 36 int request_id,
38 const GURL& origin, 37 const GURL& origin,
39 bool user_gesture, 38 bool user_gesture,
40 const base::Callback<void(content::PermissionStatus)>& callback) { 39 const base::Callback<void(content::PermissionStatus)>& callback) {
41 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 40 int render_process_id = render_frame_host->GetProcess()->GetID();
42 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 41 int render_frame_id = render_frame_host->GetRoutingID();
43 AwBrowserPermissionRequestDelegate* delegate = 42 AwBrowserPermissionRequestDelegate* delegate =
44 AwBrowserPermissionRequestDelegate::FromID(render_process_id, 43 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
45 render_view_id); 44 render_frame_host);
46 if (!delegate) { 45 if (!delegate) {
47 DVLOG(0) << "Dropping permission request for " 46 DVLOG(0) << "Dropping permission request for "
48 << static_cast<int>(permission); 47 << static_cast<int>(permission);
49 callback.Run(content::PERMISSION_STATUS_DENIED); 48 callback.Run(content::PERMISSION_STATUS_DENIED);
50 return; 49 return;
51 } 50 }
52 51
53 switch (permission) { 52 switch (permission) {
54 case content::PermissionType::GEOLOCATION: 53 case content::PermissionType::GEOLOCATION:
55 delegate->RequestGeolocationPermission( 54 delegate->RequestGeolocationPermission(
(...skipping 12 matching lines...) Expand all
68 break; 67 break;
69 case content::PermissionType::NUM: 68 case content::PermissionType::NUM:
70 NOTREACHED() << "PermissionType::NUM was not expected here."; 69 NOTREACHED() << "PermissionType::NUM was not expected here.";
71 callback.Run(content::PERMISSION_STATUS_DENIED); 70 callback.Run(content::PERMISSION_STATUS_DENIED);
72 break; 71 break;
73 } 72 }
74 } 73 }
75 74
76 void AwPermissionManager::CancelPermissionRequest( 75 void AwPermissionManager::CancelPermissionRequest(
77 content::PermissionType permission, 76 content::PermissionType permission,
78 content::WebContents* web_contents, 77 content::RenderFrameHost* render_frame_host,
79 int request_id, 78 int request_id,
80 const GURL& origin) { 79 const GURL& origin) {
81 int render_process_id = web_contents->GetRenderProcessHost()->GetID(); 80 int render_process_id = render_frame_host->GetProcess()->GetID();
82 int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 81 int render_frame_id = render_frame_host->GetRoutingID();
83 AwBrowserPermissionRequestDelegate* delegate = 82 AwBrowserPermissionRequestDelegate* delegate =
84 AwBrowserPermissionRequestDelegate::FromID(render_process_id, 83 AwBrowserPermissionRequestDelegate::FromID(render_process_id,
85 render_view_id); 84 render_frame_id);
86 if (!delegate) 85 if (!delegate)
87 return; 86 return;
88 87
89 switch (permission) { 88 switch (permission) {
90 case content::PermissionType::GEOLOCATION: 89 case content::PermissionType::GEOLOCATION:
91 delegate->CancelGeolocationPermissionRequests(origin); 90 delegate->CancelGeolocationPermissionRequests(origin);
92 break; 91 break;
93 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: 92 case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER:
94 delegate->CancelProtectedMediaIdentifierPermissionRequests(origin); 93 delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
95 break; 94 break;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const GURL& embedding_origin, 129 const GURL& embedding_origin,
131 const base::Callback<void(content::PermissionStatus)>& callback) { 130 const base::Callback<void(content::PermissionStatus)>& callback) {
132 return -1; 131 return -1;
133 } 132 }
134 133
135 void AwPermissionManager::UnsubscribePermissionStatusChange( 134 void AwPermissionManager::UnsubscribePermissionStatusChange(
136 int subscription_id) { 135 int subscription_id) {
137 } 136 }
138 137
139 } // namespace android_webview 138 } // namespace android_webview
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698