diff options
author | miguelg <miguelg@chromium.org> | 2014-10-27 03:58:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-27 10:58:21 +0000 |
commit | b7beb08c377e86a8b9b224a5064a2cf0b737a679 (patch) | |
tree | 7b60513d8d397c43c845f33f8de3cc3f7d0a7ee0 /content/browser | |
parent | 07d7187cd6e12b6d9ebc242363061d096c1613af (diff) | |
download | chromium_src-b7beb08c377e86a8b9b224a5064a2cf0b737a679.zip chromium_src-b7beb08c377e86a8b9b224a5064a2cf0b737a679.tar.gz chromium_src-b7beb08c377e86a8b9b224a5064a2cf0b737a679.tar.bz2 |
Group the different permission related methods in the content api.
BUG=392145
Review URL: https://codereview.chromium.org/622793002
Cr-Commit-Position: refs/heads/master@{#301338}
Diffstat (limited to 'content/browser')
-rw-r--r-- | content/browser/frame_host/render_frame_host_impl.cc | 29 | ||||
-rw-r--r-- | content/browser/frame_host/render_frame_host_impl.h | 4 | ||||
-rw-r--r-- | content/browser/geolocation/geolocation_dispatcher_host.cc | 13 | ||||
-rw-r--r-- | content/browser/media/cdm/browser_cdm_manager.cc | 21 | ||||
-rw-r--r-- | content/browser/media/midi_dispatcher_host.cc | 16 | ||||
-rw-r--r-- | content/browser/media/midi_dispatcher_host.h | 1 |
6 files changed, 53 insertions, 31 deletions
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index d45a2b0..50b3499 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc @@ -998,14 +998,22 @@ void RenderFrameHostImpl::OnRunBeforeUnloadConfirm( void RenderFrameHostImpl::OnRequestPlatformNotificationPermission( const GURL& origin, int request_id) { - base::Callback<void(blink::WebNotificationPermission)> done_callback = - base::Bind( - &RenderFrameHostImpl::PlatformNotificationPermissionRequestDone, - weak_ptr_factory_.GetWeakPtr(), - request_id); + base::Callback<void(bool)> done_callback = base::Bind( + &RenderFrameHostImpl::PlatformNotificationPermissionRequestDone, + weak_ptr_factory_.GetWeakPtr(), + request_id); + + if (!delegate()->GetAsWebContents()) + return; - GetContentClient()->browser()->RequestDesktopNotificationPermission( - origin, this, done_callback); + // TODO(peter): plumb user_gesture and bridge_id. + GetContentClient()->browser()->RequestPermission( + content::PERMISSION_NOTIFICATIONS, + delegate()->GetAsWebContents(), + routing_id_, + origin, + true, // user_gesture, + done_callback); } void RenderFrameHostImpl::OnShowDesktopNotification( @@ -1459,7 +1467,12 @@ void RenderFrameHostImpl::InvalidateMojoConnection() { } void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( - int request_id, blink::WebNotificationPermission permission) { + int request_id, + bool granted) { + blink::WebNotificationPermission permission = + granted ? blink::WebNotificationPermissionAllowed + : blink::WebNotificationPermissionDenied; + Send(new PlatformNotificationMsg_PermissionRequestComplete( routing_id_, request_id, permission)); } diff --git a/content/browser/frame_host/render_frame_host_impl.h b/content/browser/frame_host/render_frame_host_impl.h index b1669f2..c63ae27 100644 --- a/content/browser/frame_host/render_frame_host_impl.h +++ b/content/browser/frame_host/render_frame_host_impl.h @@ -22,7 +22,6 @@ #include "content/public/browser/render_frame_host.h" #include "content/public/common/javascript_message_type.h" #include "net/http/http_response_headers.h" -#include "third_party/WebKit/public/platform/WebNotificationPermission.h" #include "third_party/WebKit/public/web/WebTextDirection.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/page_transition_types.h" @@ -462,8 +461,7 @@ class CONTENT_EXPORT RenderFrameHostImpl // it will be used to kill processes that commit unauthorized URLs. bool CanCommitURL(const GURL& url); - void PlatformNotificationPermissionRequestDone( - int request_id, blink::WebNotificationPermission permission); + void PlatformNotificationPermissionRequestDone(int request_id, bool granted); // Update the the singleton FrameAccessibility instance with a map // from accessibility node id to the frame routing id of a cross-process diff --git a/content/browser/geolocation/geolocation_dispatcher_host.cc b/content/browser/geolocation/geolocation_dispatcher_host.cc index d7286d9..d677ba0 100644 --- a/content/browser/geolocation/geolocation_dispatcher_host.cc +++ b/content/browser/geolocation/geolocation_dispatcher_host.cc @@ -165,7 +165,8 @@ void GeolocationDispatcherHost::UpdateGeoposition( while (top_frame->GetParent()) { top_frame = top_frame->GetParent(); } - GetContentClient()->browser()->DidUseGeolocationPermission( + GetContentClient()->browser()->RegisterPermissionUsage( + content::PERMISSION_GEOLOCATION, web_contents(), frame->GetLastCommittedURL().GetOrigin(), top_frame->GetLastCommittedURL().GetOrigin()); @@ -186,14 +187,17 @@ void GeolocationDispatcherHost::OnRequestPermission( render_frame_id, render_process_id, bridge_id, requesting_origin); pending_permissions_.push_back(pending_permission); - GetContentClient()->browser()->RequestGeolocationPermission( + GetContentClient()->browser()->RequestPermission( + content::PERMISSION_GEOLOCATION, web_contents(), bridge_id, requesting_origin, user_gesture, base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse, weak_factory_.GetWeakPtr(), - render_process_id, render_frame_id, bridge_id)); + render_process_id, + render_frame_id, + bridge_id)); } void GeolocationDispatcherHost::OnStartUpdating( @@ -286,7 +290,8 @@ void GeolocationDispatcherHost::CancelPermissionRequestsForFrame( for (size_t i = 0; i < pending_permissions_.size(); ++i) { if (pending_permissions_[i].render_process_id == render_process_id && pending_permissions_[i].render_frame_id == render_frame_id) { - GetContentClient()->browser()->CancelGeolocationPermissionRequest( + GetContentClient()->browser()->CancelPermissionRequest( + content::PERMISSION_GEOLOCATION, web_contents(), pending_permissions_[i].bridge_id, pending_permissions_[i].origin); diff --git a/content/browser/media/cdm/browser_cdm_manager.cc b/content/browser/media/cdm/browser_cdm_manager.cc index ff88aba..d3d4630 100644 --- a/content/browser/media/cdm/browser_cdm_manager.cc +++ b/content/browser/media/cdm/browser_cdm_manager.cc @@ -252,20 +252,21 @@ void BrowserCdmManager::OnCreateSession( RenderFrameHost::FromID(render_process_id_, render_frame_id); WebContents* web_contents = WebContents::FromRenderFrameHost(rfh); DCHECK(web_contents); - - base::Closure cancel_callback; - GetContentClient()->browser()->RequestProtectedMediaIdentifierPermission( + GetContentClient()->browser()->RequestPermission( + content::PERMISSION_PROTECTED_MEDIA, web_contents, + 0, // bridge id security_origin, + // Only implemented for Android infobars which do not support + // user gestures. + true, base::Bind(&BrowserCdmManager::CreateSessionIfPermitted, this, - render_frame_id, cdm_id, session_id, - mime_type, init_data), - &cancel_callback); - - if (cancel_callback.is_null()) - return; - cdm_cancel_permission_map_[GetId(render_frame_id, cdm_id)] = cancel_callback; + render_frame_id, + cdm_id, + session_id, + mime_type, + init_data)); } void BrowserCdmManager::OnUpdateSession( diff --git a/content/browser/media/midi_dispatcher_host.cc b/content/browser/media/midi_dispatcher_host.cc index 4d7ebff..944dae5 100644 --- a/content/browser/media/midi_dispatcher_host.cc +++ b/content/browser/media/midi_dispatcher_host.cc @@ -78,15 +78,17 @@ void MidiDispatcherHost::OnRequestSysExPermission( render_process_id, render_frame_id, bridge_id); pending_permissions_.push_back(pending_permission); - GetContentClient()->browser()->RequestMidiSysExPermission( + GetContentClient()->browser()->RequestPermission( + PERMISSION_MIDI_SYSEX, web_contents(), bridge_id, origin, user_gesture, base::Bind(&MidiDispatcherHost::WasSysExPermissionGranted, weak_factory_.GetWeakPtr(), - render_process_id, render_frame_id, bridge_id), - &pending_permissions_.back().cancel); + render_process_id, + render_frame_id, + bridge_id)); } void MidiDispatcherHost::CancelPermissionRequestsForFrame( @@ -97,8 +99,12 @@ void MidiDispatcherHost::CancelPermissionRequestsForFrame( for (size_t i = 0; i < pending_permissions_.size(); ++i) { if (pending_permissions_[i].render_process_id == render_process_id && pending_permissions_[i].render_frame_id == render_frame_id) { - if (!pending_permissions_[i].cancel.is_null()) - pending_permissions_[i].cancel.Run(); + GetContentClient()->browser()->CancelPermissionRequest( + PERMISSION_MIDI_SYSEX, + web_contents(), + pending_permissions_[i].bridge_id, + render_frame_host->GetLastCommittedURL()); + pending_permissions_.erase(pending_permissions_.begin() + i); return; } diff --git a/content/browser/media/midi_dispatcher_host.h b/content/browser/media/midi_dispatcher_host.h index 586e864..a487178 100644 --- a/content/browser/media/midi_dispatcher_host.h +++ b/content/browser/media/midi_dispatcher_host.h @@ -51,7 +51,6 @@ class MidiDispatcherHost : public WebContentsObserver { int render_process_id; int render_frame_id; int bridge_id; - base::Closure cancel; }; std::vector<PendingPermission> pending_permissions_; |