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

Unified Diff: android_webview/browser/aw_content_browser_client.cc

Issue 571483002: Refactor content client to include a single Request/CancelPermission method. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@geoloc_permission
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/browser/aw_content_browser_client.h ('k') | chrome/browser/chrome_content_browser_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/browser/aw_content_browser_client.cc
diff --git a/android_webview/browser/aw_content_browser_client.cc b/android_webview/browser/aw_content_browser_client.cc
index f45818cf917f1c128f881076d9327948ef8c3661..d50772984d437876acd1d3640b997ea97e5b11b0 100644
--- a/android_webview/browser/aw_content_browser_client.cc
+++ b/android_webview/browser/aw_content_browser_client.cc
@@ -139,17 +139,6 @@ class AwAccessTokenStore : public content::AccessTokenStore {
DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore);
};
-void CancelProtectedMediaIdentifierPermissionRequests(
- int render_process_id,
- int render_view_id,
- const GURL& origin) {
- AwBrowserPermissionRequestDelegate* delegate =
- AwBrowserPermissionRequestDelegate::FromID(render_process_id,
- render_view_id);
- if (delegate)
- delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
-}
-
} // namespace
std::string AwContentBrowserClient::GetAcceptLangsImpl() {
@@ -402,7 +391,8 @@ void AwContentBrowserClient::ShowDesktopNotification(
NOTREACHED() << "Android WebView does not support desktop notifications.";
}
-void AwContentBrowserClient::RequestGeolocationPermission(
+void AwContentBrowserClient::RequestPermission(
+ content::PermissionType permission,
content::WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame,
@@ -410,66 +400,66 @@ void AwContentBrowserClient::RequestGeolocationPermission(
const base::Callback<void(bool)>& result_callback) {
int render_process_id = web_contents->GetRenderProcessHost()->GetID();
int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
- AwBrowserPermissionRequestDelegate* delegate =
- AwBrowserPermissionRequestDelegate::FromID(render_process_id,
- render_view_id);
- if (delegate == NULL) {
- DVLOG(0) << "Dropping GeolocationPermission request";
- result_callback.Run(false);
- return;
- }
-
GURL origin = requesting_frame.GetOrigin();
- delegate->RequestGeolocationPermission(origin, result_callback);
-}
-
-void AwContentBrowserClient::CancelGeolocationPermissionRequest(
- content::WebContents* web_contents,
- int bridge_id,
- const GURL& requesting_frame) {
- int render_process_id = web_contents->GetRenderProcessHost()->GetID();
- int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
AwBrowserPermissionRequestDelegate* delegate =
AwBrowserPermissionRequestDelegate::FromID(render_process_id,
render_view_id);
- if (delegate)
- delegate->CancelGeolocationPermissionRequests(requesting_frame);
-}
-
-void AwContentBrowserClient::RequestMidiSysExPermission(
+ switch (permission) {
+ case content::PERMISSION_MIDI_SYSEX:
+ break;
+ case content::PERMISSION_NOTIFICATIONS:
+ LOG(WARNING) << "Permission Request not implemented for "
+ << permission;
+ break;
+ case content::PERMISSION_GEOLOCATION:
+ if (delegate == NULL) {
+ DVLOG(0) << "Dropping GeolocationPermission request";
+ result_callback.Run(false);
+ return;
+ }
+ delegate->RequestGeolocationPermission(origin, result_callback);
+ break;
+ case content::PERMISSION_PROTECTED_MEDIA:
+ if (delegate == NULL) {
+ DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request";
+ result_callback.Run(false);
+ return;
+ }
+ delegate->RequestProtectedMediaIdentifierPermission(
+ origin, result_callback);
+ break;
+ default:
+ LOG(WARNING) << "Permission not available " << permission;
+ }
+}
+
+void AwContentBrowserClient::CancelPermissionRequest(
+ content::PermissionType permission,
content::WebContents* web_contents,
int bridge_id,
- const GURL& requesting_frame,
- bool user_gesture,
- base::Callback<void(bool)> result_callback,
- base::Closure* cancel_callback) {
- // TODO(toyoshim): Android WebView is not supported yet.
- // See http://crbug.com/339767.
- result_callback.Run(false);
-}
-
-void AwContentBrowserClient::RequestProtectedMediaIdentifierPermission(
- content::WebContents* web_contents,
- const GURL& origin,
- base::Callback<void(bool)> result_callback,
- base::Closure* cancel_callback) {
+ const GURL& origin) {
int render_process_id = web_contents->GetRenderProcessHost()->GetID();
int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
AwBrowserPermissionRequestDelegate* delegate =
AwBrowserPermissionRequestDelegate::FromID(render_process_id,
render_view_id);
- if (delegate == NULL) {
- DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request";
- result_callback.Run(false);
+ if (!delegate)
return;
+ switch (permission) {
+ case content::PERMISSION_MIDI_SYSEX:
+ case content::PERMISSION_NOTIFICATIONS:
+ LOG(WARNING) << "Cancel Permission request not implemented for "
+ << permission;
+ break;
+ case content::PERMISSION_GEOLOCATION:
+ delegate->CancelGeolocationPermissionRequests(origin);
+ break;
+ case content::PERMISSION_PROTECTED_MEDIA:
+ delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
+ break;
+ default:
+ LOG(WARNING) << "Permission not available " << permission;
}
-
- if (cancel_callback) {
- *cancel_callback = base::Bind(
- CancelProtectedMediaIdentifierPermissionRequests,
- render_process_id, render_view_id, origin);
- }
- delegate->RequestProtectedMediaIdentifierPermission(origin, result_callback);
}
bool AwContentBrowserClient::CanCreateWindow(
« no previous file with comments | « android_webview/browser/aw_content_browser_client.h ('k') | chrome/browser/chrome_content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698