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

Unified Diff: chrome/browser/chrome_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
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index f3e134c5c13e205461d3768cfea2535abc50d3c2..a393ea3627499ca1e043f111cef1f49a94ceee83 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -1922,7 +1922,8 @@ void ChromeContentBrowserClient::ShowDesktopNotification(
#endif
}
-void ChromeContentBrowserClient::RequestGeolocationPermission(
+void ChromeContentBrowserClient::RequestPermission(
+ content::PermissionType permission,
content::WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame,
@@ -1935,14 +1936,43 @@ void ChromeContentBrowserClient::RequestGeolocationPermission(
render_view_id,
bridge_id,
requesting_frame);
- GeolocationPermissionContextFactory::GetForProfile(
- Profile::FromBrowserContext(web_contents->GetBrowserContext()))->
- RequestPermission(web_contents, request_id,
- requesting_frame.GetOrigin(), user_gesture,
- result_callback);
+
+ switch (permission) {
+ case content::PERMISSION_MIDI_SYSEX:
+ MidiPermissionContextFactory::GetForProfile(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()))
+ ->RequestPermission(web_contents, request_id, requesting_frame,
+ user_gesture, result_callback);
+ break;
+ case content::PERMISSION_NOTIFICATIONS:
+ // TODO(miguelg) implement notifications once the platform refactor
+ // is finished.
+ LOG(WARNING) << "Permission request not implemented for " << permission;
+ break;
+ case content::PERMISSION_GEOLOCATION:
+ GeolocationPermissionContextFactory::GetForProfile(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()))
+ ->RequestPermission(web_contents, request_id,
+ requesting_frame.GetOrigin(), user_gesture,
+ result_callback);
+ break;
+#if defined(OS_ANDROID)
+ case content::PERMISSION_PROTECTED_MEDIA:
+ ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()))
+ ->RequestProtectedMediaIdentifierPermission(web_contents,
+ requesting_frame,
+ result_callback);
+ break;
+#endif
+ default:
+ LOG(WARNING) << "Permission not available " << permission;
+ }
+
}
-void ChromeContentBrowserClient::CancelGeolocationPermissionRequest(
+void ChromeContentBrowserClient::CancelPermissionRequest(
+ content::PermissionType permission,
content::WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame) {
@@ -1953,28 +1983,39 @@ void ChromeContentBrowserClient::CancelGeolocationPermissionRequest(
render_view_id,
bridge_id,
requesting_frame);
- GeolocationPermissionContextFactory::GetForProfile(
- Profile::FromBrowserContext(web_contents->GetBrowserContext()))->
- CancelPermissionRequest(web_contents, request_id);
+ switch (permission) {
+ case content::PERMISSION_MIDI_SYSEX:
+ MidiPermissionContextFactory::GetForProfile(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()))
+ ->CancelPermissionRequest(web_contents, request_id);
+ break;
+ case content::PERMISSION_NOTIFICATIONS:
+ // TODO(miguelg) implement notifications once the platform refactor
+ // is finished.
+ LOG(WARNING) << "Cancel Permission request not implemented for "
+ << permission;
+ break;
+ case content::PERMISSION_GEOLOCATION:
+ GeolocationPermissionContextFactory::GetForProfile(
+ Profile::FromBrowserContext(
+ web_contents->GetBrowserContext()))
+ ->CancelPermissionRequest(web_contents, request_id);
+ break;
+ #if defined(OS_ANDROID)
+ case content::PERMISSION_PROTECTED_MEDIA:
+ ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
+ Profile::FromBrowserContext(web_contents->GetBrowserContext()))
+ ->CancelProtectedMediaIdentifierPermissionRequests(
+ render_process_id,
+ render_view_id,
+ requesting_frame);
+ break;
+ #endif
+ default:
+ LOG(WARNING) << "Permission not available " << permission;
+ }
}
-void ChromeContentBrowserClient::RequestMidiSysExPermission(
- content::WebContents* web_contents,
- int bridge_id,
- const GURL& requesting_frame,
- bool user_gesture,
- base::Callback<void(bool)> result_callback,
- base::Closure* cancel_callback) {
- MidiPermissionContext* context =
- MidiPermissionContextFactory::GetForProfile(
- Profile::FromBrowserContext(web_contents->GetBrowserContext()));
- int renderer_id = web_contents->GetRenderProcessHost()->GetID();
- int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
- const PermissionRequestID id(renderer_id, render_view_id, bridge_id, GURL());
-
- context->RequestPermission(web_contents, id, requesting_frame,
- user_gesture, result_callback);
-}
void ChromeContentBrowserClient::DidUseGeolocationPermission(
content::WebContents* web_contents,
@@ -1986,25 +2027,6 @@ void ChromeContentBrowserClient::DidUseGeolocationPermission(
frame_url, main_frame_url, CONTENT_SETTINGS_TYPE_GEOLOCATION);
}
-void ChromeContentBrowserClient::RequestProtectedMediaIdentifierPermission(
- content::WebContents* web_contents,
- const GURL& origin,
- base::Callback<void(bool)> result_callback,
- base::Closure* cancel_callback) {
-#if defined(OS_ANDROID)
- ProtectedMediaIdentifierPermissionContext* context =
- ProtectedMediaIdentifierPermissionContextFactory::GetForProfile(
- Profile::FromBrowserContext(web_contents->GetBrowserContext()));
- context->RequestProtectedMediaIdentifierPermission(web_contents,
- origin,
- result_callback,
- cancel_callback);
-#else
- NOTIMPLEMENTED();
- result_callback.Run(false);
-#endif // defined(OS_ANDROID)
-}
-
bool ChromeContentBrowserClient::CanCreateWindow(
const GURL& opener_url,
const GURL& opener_top_level_frame_url,
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/media/protected_media_identifier_permission_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698