Commit b7beb08c authored by miguelg's avatar miguelg Committed by Commit bot

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}
parent 07d7187c
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "content/public/browser/browser_message_filter.h" #include "content/public/browser/browser_message_filter.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_security_policy.h" #include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/permission_type.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -140,17 +141,6 @@ class AwAccessTokenStore : public content::AccessTokenStore { ...@@ -140,17 +141,6 @@ class AwAccessTokenStore : public content::AccessTokenStore {
DISALLOW_COPY_AND_ASSIGN(AwAccessTokenStore); 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 } // namespace
std::string AwContentBrowserClient::GetAcceptLangsImpl() { std::string AwContentBrowserClient::GetAcceptLangsImpl() {
...@@ -402,7 +392,8 @@ void AwContentBrowserClient::ShowDesktopNotification( ...@@ -402,7 +392,8 @@ void AwContentBrowserClient::ShowDesktopNotification(
NOTREACHED() << "Android WebView does not support desktop notifications."; NOTREACHED() << "Android WebView does not support desktop notifications.";
} }
void AwContentBrowserClient::RequestGeolocationPermission( void AwContentBrowserClient::RequestPermission(
content::PermissionType permission,
content::WebContents* web_contents, content::WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame, const GURL& requesting_frame,
...@@ -410,66 +401,68 @@ void AwContentBrowserClient::RequestGeolocationPermission( ...@@ -410,66 +401,68 @@ void AwContentBrowserClient::RequestGeolocationPermission(
const base::Callback<void(bool)>& result_callback) { const base::Callback<void(bool)>& result_callback) {
int render_process_id = web_contents->GetRenderProcessHost()->GetID(); int render_process_id = web_contents->GetRenderProcessHost()->GetID();
int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); 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(); 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* delegate =
AwBrowserPermissionRequestDelegate::FromID(render_process_id, AwBrowserPermissionRequestDelegate::FromID(render_process_id,
render_view_id); render_view_id);
if (delegate) switch (permission) {
delegate->CancelGeolocationPermissionRequests(requesting_frame); case content::PERMISSION_GEOLOCATION:
if (!delegate) {
DVLOG(0) << "Dropping GeolocationPermission request";
result_callback.Run(false);
return;
}
delegate->RequestGeolocationPermission(origin, result_callback);
break;
case content::PERMISSION_PROTECTED_MEDIA:
if (!delegate) {
DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request";
result_callback.Run(false);
return;
}
delegate->RequestProtectedMediaIdentifierPermission(origin,
result_callback);
break;
case content::PERMISSION_MIDI_SYSEX:
case content::PERMISSION_NOTIFICATIONS:
case content::PERMISSION_PUSH_MESSAGING:
NOTIMPLEMENTED() << "RequestPermission not implemented for "
<< permission;
break;
case content::PERMISSION_NUM:
NOTREACHED() << "Invalid RequestPermission for " << permission;
break;
}
} }
void AwContentBrowserClient::RequestMidiSysExPermission( void AwContentBrowserClient::CancelPermissionRequest(
content::PermissionType permission,
content::WebContents* web_contents, content::WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame, const GURL& origin) {
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) {
int render_process_id = web_contents->GetRenderProcessHost()->GetID(); int render_process_id = web_contents->GetRenderProcessHost()->GetID();
int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
AwBrowserPermissionRequestDelegate* delegate = AwBrowserPermissionRequestDelegate* delegate =
AwBrowserPermissionRequestDelegate::FromID(render_process_id, AwBrowserPermissionRequestDelegate::FromID(render_process_id,
render_view_id); render_view_id);
if (delegate == NULL) { if (!delegate)
DVLOG(0) << "Dropping ProtectedMediaIdentifierPermission request";
result_callback.Run(false);
return; return;
switch (permission) {
case content::PERMISSION_GEOLOCATION:
delegate->CancelGeolocationPermissionRequests(origin);
break;
case content::PERMISSION_PROTECTED_MEDIA:
delegate->CancelProtectedMediaIdentifierPermissionRequests(origin);
break;
case content::PERMISSION_MIDI_SYSEX:
case content::PERMISSION_NOTIFICATIONS:
case content::PERMISSION_PUSH_MESSAGING:
NOTIMPLEMENTED() << "CancelPermission not implemented for " << permission;
break;
case content::PERMISSION_NUM:
NOTREACHED() << "Invalid CancelPermission for " << permission;
break;
} }
if (cancel_callback) {
*cancel_callback = base::Bind(
CancelProtectedMediaIdentifierPermissionRequests,
render_process_id, render_view_id, origin);
}
delegate->RequestProtectedMediaIdentifierPermission(origin, result_callback);
} }
bool AwContentBrowserClient::CanCreateWindow( bool AwContentBrowserClient::CanCreateWindow(
......
...@@ -118,28 +118,17 @@ class AwContentBrowserClient : public content::ContentBrowserClient { ...@@ -118,28 +118,17 @@ class AwContentBrowserClient : public content::ContentBrowserClient {
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
scoped_ptr<content::DesktopNotificationDelegate> delegate, scoped_ptr<content::DesktopNotificationDelegate> delegate,
base::Closure* cancel_callback) override; base::Closure* cancel_callback) override;
virtual void RequestGeolocationPermission( virtual void RequestPermission(
content::PermissionType permission,
content::WebContents* web_contents, content::WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame, const GURL& requesting_frame,
bool user_gesture, bool user_gesture,
const base::Callback<void(bool)>& result_callback) override; const base::Callback<void(bool)>& result_callback) override;
virtual void CancelGeolocationPermissionRequest( virtual void CancelPermissionRequest(content::PermissionType permission,
content::WebContents* web_contents, content::WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame) override; const GURL& origin) override;
virtual void 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) override;
virtual void RequestProtectedMediaIdentifierPermission(
content::WebContents* web_contents,
const GURL& origin,
base::Callback<void(bool)> result_callback,
base::Closure* cancel_callback) override;
virtual bool CanCreateWindow(const GURL& opener_url, virtual bool CanCreateWindow(const GURL& opener_url,
const GURL& opener_top_level_frame_url, const GURL& opener_top_level_frame_url,
const GURL& source_origin, const GURL& source_origin,
......
...@@ -180,11 +180,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { ...@@ -180,11 +180,6 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
int render_process_id, int render_process_id,
int render_frame_id) override; int render_frame_id) override;
content::MediaObserver* GetMediaObserver() override; content::MediaObserver* GetMediaObserver() override;
void RequestDesktopNotificationPermission(
const GURL& source_origin,
content::RenderFrameHost* render_frame_host,
const base::Callback<void(blink::WebNotificationPermission)>& callback)
override;
blink::WebNotificationPermission CheckDesktopNotificationPermission( blink::WebNotificationPermission CheckDesktopNotificationPermission(
const GURL& source_origin, const GURL& source_origin,
content::ResourceContext* context, content::ResourceContext* context,
...@@ -194,30 +189,21 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient { ...@@ -194,30 +189,21 @@ class ChromeContentBrowserClient : public content::ContentBrowserClient {
content::RenderFrameHost* render_frame_host, content::RenderFrameHost* render_frame_host,
scoped_ptr<content::DesktopNotificationDelegate> delegate, scoped_ptr<content::DesktopNotificationDelegate> delegate,
base::Closure* cancel_callback) override; base::Closure* cancel_callback) override;
void RequestGeolocationPermission( void RequestPermission(
content::PermissionType permission,
content::WebContents* web_contents, content::WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame, const GURL& requesting_frame,
bool user_gesture, bool user_gesture,
const base::Callback<void(bool)>& result_callback) override; const base::Callback<void(bool)>& result_callback) override;
void CancelGeolocationPermissionRequest( void CancelPermissionRequest(content::PermissionType permission,
content::WebContents* web_contents, content::WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame) override; const GURL& requesting_frame) override;
void RequestMidiSysExPermission(content::WebContents* web_contents, void RegisterPermissionUsage(content::PermissionType permission,
int bridge_id, content::WebContents* web_contents,
const GURL& requesting_frame, const GURL& frame_url,
bool user_gesture, const GURL& main_frame_url) override;
base::Callback<void(bool)> result_callback,
base::Closure* cancel_callback) override;
void DidUseGeolocationPermission(content::WebContents* web_contents,
const GURL& frame_url,
const GURL& main_frame_url) override;
void RequestProtectedMediaIdentifierPermission(
content::WebContents* web_contents,
const GURL& origin,
base::Callback<void(bool)> result_callback,
base::Closure* cancel_callback) override;
bool CanCreateWindow(const GURL& opener_url, bool CanCreateWindow(const GURL& opener_url,
const GURL& opener_top_level_frame_url, const GURL& opener_top_level_frame_url,
const GURL& source_origin, const GURL& source_origin,
......
...@@ -51,7 +51,7 @@ void PermissionContextBase::RequestPermission( ...@@ -51,7 +51,7 @@ void PermissionContextBase::RequestPermission(
void PermissionContextBase::CancelPermissionRequest( void PermissionContextBase::CancelPermissionRequest(
content::WebContents* web_contents, content::WebContents* web_contents,
const PermissionRequestID& id) { const PermissionRequestID& id) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (PermissionBubbleManager::Enabled()) { if (PermissionBubbleManager::Enabled()) {
PermissionBubbleRequest* cancelling = PermissionBubbleRequest* cancelling =
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "chrome/browser/content_settings/permission_context_uma_util.h" #include "chrome/browser/content_settings/permission_context_uma_util.h"
#include "content/public/browser/permission_type.h"
#include "url/gurl.h" #include "url/gurl.h"
// UMA keys need to be statically initialized so plain function would not // UMA keys need to be statically initialized so plain function would not
// work. Use a Macro instead. // work. Use a Macro instead.
#define PERMISSION_ACTION_UMA(secure_origin, \ #define PERMISSION_ACTION_UMA(secure_origin, \
...@@ -41,20 +41,6 @@ enum PermissionAction { ...@@ -41,20 +41,6 @@ enum PermissionAction {
PERMISSION_ACTION_NUM, PERMISSION_ACTION_NUM,
}; };
// Enum for UMA purposes, make sure you update histograms.xml if you add new
// permission actions. Never delete or reorder an entry; only add new entries
// immediately before PERMISSION_NUM
enum PermissionType {
PERMISSION_UNKNOWN = 0,
PERMISSION_MIDI_SYSEX = 1,
PERMISSION_PUSH_MESSAGING = 2,
PERMISSION_NOTIFICATIONS = 3,
PERMISSION_GEOLOCATION = 4,
// Always keep this at the end.
PERMISSION_NUM,
};
void RecordPermissionAction( void RecordPermissionAction(
ContentSettingsType permission, ContentSettingsType permission,
PermissionAction action, PermissionAction action,
...@@ -105,38 +91,36 @@ void RecordPermissionAction( ...@@ -105,38 +91,36 @@ void RecordPermissionAction(
void RecordPermissionRequest( void RecordPermissionRequest(
ContentSettingsType permission, bool secure_origin) { ContentSettingsType permission, bool secure_origin) {
PermissionType type; content::PermissionType type;
switch (permission) { switch (permission) {
case CONTENT_SETTINGS_TYPE_GEOLOCATION: case CONTENT_SETTINGS_TYPE_GEOLOCATION:
type = PERMISSION_GEOLOCATION; type = content::PERMISSION_GEOLOCATION;
break; break;
case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
type = PERMISSION_NOTIFICATIONS; type = content::PERMISSION_NOTIFICATIONS;
break; break;
case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
type = PERMISSION_MIDI_SYSEX; type = content::PERMISSION_MIDI_SYSEX;
break; break;
case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
type = PERMISSION_PUSH_MESSAGING; type = content::PERMISSION_PUSH_MESSAGING;
break; break;
default: default:
NOTREACHED() << "PERMISSION " << permission << " not accounted for"; NOTREACHED() << "PERMISSION " << permission << " not accounted for";
type = PERMISSION_UNKNOWN; return;
} }
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"ContentSettings.PermissionRequested", "ContentSettings.PermissionRequested", type, content::PERMISSION_NUM);
type,
PERMISSION_NUM);
if (secure_origin) { if (secure_origin) {
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"ContentSettings.PermissionRequested_SecureOrigin", "ContentSettings.PermissionRequested_SecureOrigin",
type, type,
PERMISSION_NUM); content::PERMISSION_NUM);
} else { } else {
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"ContentSettings.PermissionRequested_InsecureOrigin", "ContentSettings.PermissionRequested_InsecureOrigin",
type, type,
PERMISSION_NUM); content::PERMISSION_NUM);
} }
} }
......
...@@ -48,20 +48,13 @@ void ProtectedMediaIdentifierPermissionContext:: ...@@ -48,20 +48,13 @@ void ProtectedMediaIdentifierPermissionContext::
RequestProtectedMediaIdentifierPermission( RequestProtectedMediaIdentifierPermission(
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& origin, const GURL& origin,
base::Callback<void(bool)> result_callback, base::Callback<void(bool)> result_callback) {
base::Closure* cancel_callback) {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
if (shutting_down_) if (shutting_down_)
return; return;
int render_process_id = web_contents->GetRenderProcessHost()->GetID(); int render_process_id = web_contents->GetRenderProcessHost()->GetID();
int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID(); int render_view_id = web_contents->GetRenderViewHost()->GetRoutingID();
if (cancel_callback) {
*cancel_callback = base::Bind(
&ProtectedMediaIdentifierPermissionContext::
CancelProtectedMediaIdentifierPermissionRequests,
this, render_process_id, render_view_id, origin);
}
const PermissionRequestID id( const PermissionRequestID id(
render_process_id, render_view_id, 0, origin); render_process_id, render_view_id, 0, origin);
......
...@@ -31,8 +31,11 @@ class ProtectedMediaIdentifierPermissionContext ...@@ -31,8 +31,11 @@ class ProtectedMediaIdentifierPermissionContext
void RequestProtectedMediaIdentifierPermission( void RequestProtectedMediaIdentifierPermission(
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& origin, const GURL& origin,
base::Callback<void(bool)> result_callback, base::Callback<void(bool)> result_callback);
base::Closure* cancel_callback);
void CancelProtectedMediaIdentifierPermissionRequests(int render_process_id,
int render_view_id,
const GURL& origin);
// Called on the UI thread when the profile is about to be destroyed. // Called on the UI thread when the profile is about to be destroyed.
void ShutdownOnUIThread(); void ShutdownOnUIThread();
...@@ -48,11 +51,6 @@ class ProtectedMediaIdentifierPermissionContext ...@@ -48,11 +51,6 @@ class ProtectedMediaIdentifierPermissionContext
// if necessary. // if necessary.
PermissionQueueController* QueueController(); PermissionQueueController* QueueController();
void CancelProtectedMediaIdentifierPermissionRequests(
int render_process_id,
int render_view_id,
const GURL& origin);
// Notifies whether or not the corresponding bridge is allowed to use // Notifies whether or not the corresponding bridge is allowed to use
// protected media identifier via // protected media identifier via
// SetProtectedMediaIdentifierPermissionResponse(). Called on the UI thread. // SetProtectedMediaIdentifierPermissionResponse(). Called on the UI thread.
......
...@@ -102,11 +102,12 @@ std::string DesktopNotificationService::AddIconNotification( ...@@ -102,11 +102,12 @@ std::string DesktopNotificationService::AddIconNotification(
DesktopNotificationService::DesktopNotificationService(Profile* profile) DesktopNotificationService::DesktopNotificationService(Profile* profile)
: PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS), : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS),
profile_(profile), profile_(profile)
#if defined(ENABLE_EXTENSIONS) #if defined(ENABLE_EXTENSIONS)
extension_registry_observer_(this), ,
extension_registry_observer_(this)
#endif #endif
weak_factory_(this) { {
OnStringListPrefChanged( OnStringListPrefChanged(
prefs::kMessageCenterDisabledExtensionIds, &disabled_extension_ids_); prefs::kMessageCenterDisabledExtensionIds, &disabled_extension_ids_);
OnStringListPrefChanged( OnStringListPrefChanged(
...@@ -142,7 +143,7 @@ void DesktopNotificationService::RequestNotificationPermission( ...@@ -142,7 +143,7 @@ void DesktopNotificationService::RequestNotificationPermission(
const PermissionRequestID& request_id, const PermissionRequestID& request_id,
const GURL& requesting_origin, const GURL& requesting_origin,
bool user_gesture, bool user_gesture,
const NotificationPermissionCallback& callback) { const base::Callback<void(bool)>& result_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
#if defined(ENABLE_EXTENSIONS) #if defined(ENABLE_EXTENSIONS)
...@@ -169,19 +170,16 @@ void DesktopNotificationService::RequestNotificationPermission( ...@@ -169,19 +170,16 @@ void DesktopNotificationService::RequestNotificationPermission(
extensions::APIPermission::kNotifications, extensions::APIPermission::kNotifications,
extension, extension,
web_contents->GetRenderViewHost())) { web_contents->GetRenderViewHost())) {
callback.Run(blink::WebNotificationPermissionAllowed); result_callback.Run(true);
return; return;
} }
#endif #endif
RequestPermission( RequestPermission(web_contents,
web_contents, request_id,
request_id, requesting_origin,
requesting_origin, user_gesture,
user_gesture, result_callback);
base::Bind(&DesktopNotificationService::OnNotificationPermissionRequested,
weak_factory_.GetWeakPtr(),
callback));
} }
void DesktopNotificationService::ShowDesktopNotification( void DesktopNotificationService::ShowDesktopNotification(
...@@ -357,15 +355,6 @@ void DesktopNotificationService::UpdateContentSetting( ...@@ -357,15 +355,6 @@ void DesktopNotificationService::UpdateContentSetting(
} }
} }
void DesktopNotificationService::OnNotificationPermissionRequested(
const NotificationPermissionCallback& callback, bool allowed) {
blink::WebNotificationPermission permission = allowed ?
blink::WebNotificationPermissionAllowed :
blink::WebNotificationPermissionDenied;
callback.Run(permission);
}
void DesktopNotificationService::FirePermissionLevelChangedEvent( void DesktopNotificationService::FirePermissionLevelChangedEvent(
const NotifierId& notifier_id, bool enabled) { const NotifierId& notifier_id, bool enabled) {
#if defined(ENABLE_EXTENSIONS) #if defined(ENABLE_EXTENSIONS)
......
...@@ -54,10 +54,6 @@ namespace user_prefs { ...@@ -54,10 +54,6 @@ namespace user_prefs {
class PrefRegistrySyncable; class PrefRegistrySyncable;
} }
// Callback to be invoked when the result of a permission request is known.
typedef base::Callback<void(blink::WebNotificationPermission)>
NotificationPermissionCallback;
// The DesktopNotificationService is an object, owned by the Profile, // The DesktopNotificationService is an object, owned by the Profile,
// which provides the creation of desktop "toasts" to web pages and workers. // which provides the creation of desktop "toasts" to web pages and workers.
class DesktopNotificationService : public PermissionContextBase class DesktopNotificationService : public PermissionContextBase
...@@ -89,7 +85,7 @@ class DesktopNotificationService : public PermissionContextBase ...@@ -89,7 +85,7 @@ class DesktopNotificationService : public PermissionContextBase
const PermissionRequestID& request_id, const PermissionRequestID& request_id,
const GURL& requesting_origin, const GURL& requesting_origin,
bool user_gesture, bool user_gesture,
const NotificationPermissionCallback& callback); const base::Callback<void(bool)>& result_callback);
// Show a desktop notification. If |cancel_callback| is non-null, it's set to // Show a desktop notification. If |cancel_callback| is non-null, it's set to
// a callback which can be used to cancel the notification. // a callback which can be used to cancel the notification.
...@@ -121,12 +117,6 @@ class DesktopNotificationService : public PermissionContextBase ...@@ -121,12 +117,6 @@ class DesktopNotificationService : public PermissionContextBase
// Called when the disabled_extension_id pref has been changed. // Called when the disabled_extension_id pref has been changed.
void OnDisabledExtensionIdsChanged(); void OnDisabledExtensionIdsChanged();
// Used as a callback once a permission has been decided to convert |allowed|
// to one of the blink::WebNotificationPermission values.
void OnNotificationPermissionRequested(
const base::Callback<void(blink::WebNotificationPermission)>& callback,
bool allowed);
void FirePermissionLevelChangedEvent( void FirePermissionLevelChangedEvent(
const message_center::NotifierId& notifier_id, const message_center::NotifierId& notifier_id,
bool enabled); bool enabled);
...@@ -165,8 +155,6 @@ class DesktopNotificationService : public PermissionContextBase ...@@ -165,8 +155,6 @@ class DesktopNotificationService : public PermissionContextBase
extension_registry_observer_; extension_registry_observer_;
#endif #endif
base::WeakPtrFactory<DesktopNotificationService> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService);
}; };
......
...@@ -998,14 +998,22 @@ void RenderFrameHostImpl::OnRunBeforeUnloadConfirm( ...@@ -998,14 +998,22 @@ void RenderFrameHostImpl::OnRunBeforeUnloadConfirm(
void RenderFrameHostImpl::OnRequestPlatformNotificationPermission( void RenderFrameHostImpl::OnRequestPlatformNotificationPermission(
const GURL& origin, int request_id) { const GURL& origin, int request_id) {
base::Callback<void(blink::WebNotificationPermission)> done_callback = base::Callback<void(bool)> done_callback = base::Bind(
base::Bind( &RenderFrameHostImpl::PlatformNotificationPermissionRequestDone,
&RenderFrameHostImpl::PlatformNotificationPermissionRequestDone, weak_ptr_factory_.GetWeakPtr(),
weak_ptr_factory_.GetWeakPtr(), request_id);
request_id);
if (!delegate()->GetAsWebContents())
return;
GetContentClient()->browser()->RequestDesktopNotificationPermission( // TODO(peter): plumb user_gesture and bridge_id.
origin, this, done_callback); GetContentClient()->browser()->RequestPermission(
content::PERMISSION_NOTIFICATIONS,
delegate()->GetAsWebContents(),
routing_id_,
origin,
true, // user_gesture,
done_callback);
} }
void RenderFrameHostImpl::OnShowDesktopNotification( void RenderFrameHostImpl::OnShowDesktopNotification(
...@@ -1459,7 +1467,12 @@ void RenderFrameHostImpl::InvalidateMojoConnection() { ...@@ -1459,7 +1467,12 @@ void RenderFrameHostImpl::InvalidateMojoConnection() {
} }
void RenderFrameHostImpl::PlatformNotificationPermissionRequestDone( 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( Send(new PlatformNotificationMsg_PermissionRequestComplete(
routing_id_, request_id, permission)); routing_id_, request_id, permission));
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/common/javascript_message_type.h" #include "content/public/common/javascript_message_type.h"
#include "net/http/http_response_headers.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 "third_party/WebKit/public/web/WebTextDirection.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
...@@ -462,8 +461,7 @@ class CONTENT_EXPORT RenderFrameHostImpl ...@@ -462,8 +461,7 @@ class CONTENT_EXPORT RenderFrameHostImpl
// it will be used to kill processes that commit unauthorized URLs. // it will be used to kill processes that commit unauthorized URLs.
bool CanCommitURL(const GURL& url); bool CanCommitURL(const GURL& url);
void PlatformNotificationPermissionRequestDone( void PlatformNotificationPermissionRequestDone(int request_id, bool granted);
int request_id, blink::WebNotificationPermission permission);
// Update the the singleton FrameAccessibility instance with a map // Update the the singleton FrameAccessibility instance with a map
// from accessibility node id to the frame routing id of a cross-process // from accessibility node id to the frame routing id of a cross-process
......
...@@ -165,7 +165,8 @@ void GeolocationDispatcherHost::UpdateGeoposition( ...@@ -165,7 +165,8 @@ void GeolocationDispatcherHost::UpdateGeoposition(
while (top_frame->GetParent()) { while (top_frame->GetParent()) {
top_frame = top_frame->GetParent(); top_frame = top_frame->GetParent();
} }
GetContentClient()->browser()->DidUseGeolocationPermission( GetContentClient()->browser()->RegisterPermissionUsage(
content::PERMISSION_GEOLOCATION,
web_contents(), web_contents(),
frame->GetLastCommittedURL().GetOrigin(), frame->GetLastCommittedURL().GetOrigin(),
top_frame->GetLastCommittedURL().GetOrigin()); top_frame->GetLastCommittedURL().GetOrigin());
...@@ -186,14 +187,17 @@ void GeolocationDispatcherHost::OnRequestPermission( ...@@ -186,14 +187,17 @@ void GeolocationDispatcherHost::OnRequestPermission(
render_frame_id, render_process_id, bridge_id, requesting_origin); render_frame_id, render_process_id, bridge_id, requesting_origin);
pending_permissions_.push_back(pending_permission); pending_permissions_.push_back(pending_permission);
GetContentClient()->browser()->RequestGeolocationPermission( GetContentClient()->browser()->RequestPermission(
content::PERMISSION_GEOLOCATION,
web_contents(), web_contents(),
bridge_id, bridge_id,
requesting_origin, requesting_origin,
user_gesture, user_gesture,
base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse, base::Bind(&GeolocationDispatcherHost::SendGeolocationPermissionResponse,
weak_factory_.GetWeakPtr(), weak_factory_.GetWeakPtr(),
render_process_id, render_frame_id, bridge_id)); render_process_id,
render_frame_id,
bridge_id));
} }
void GeolocationDispatcherHost::OnStartUpdating( void GeolocationDispatcherHost::OnStartUpdating(
...@@ -286,7 +290,8 @@ void GeolocationDispatcherHost::CancelPermissionRequestsForFrame( ...@@ -286,7 +290,8 @@ void GeolocationDispatcherHost::CancelPermissionRequestsForFrame(
for (size_t i = 0; i < pending_permissions_.size(); ++i) { for (size_t i = 0; i < pending_permissions_.size(); ++i) {
if (pending_permissions_[i].render_process_id == render_process_id && if (pending_permissions_[i].render_process_id == render_process_id &&
pending_permissions_[i].render_frame_id == render_frame_id) { pending_permissions_[i].render_frame_id == render_frame_id) {
GetContentClient()->browser()->CancelGeolocationPermissionRequest( GetContentClient()->browser()->CancelPermissionRequest(
content::PERMISSION_GEOLOCATION,
web_contents(), web_contents(),
pending_permissions_[i].bridge_id, pending_permissions_[i].bridge_id,
pending_permissions_[i].origin); pending_permissions_[i].origin);
......
...@@ -252,20 +252,21 @@ void BrowserCdmManager::OnCreateSession( ...@@ -252,20 +252,21 @@ void BrowserCdmManager::OnCreateSession(
RenderFrameHost::FromID(render_process_id_, render_frame_id); RenderFrameHost::FromID(render_process_id_, render_frame_id);
WebContents* web_contents = WebContents::FromRenderFrameHost(rfh); WebContents* web_contents = WebContents::FromRenderFrameHost(rfh);
DCHECK(web_contents); DCHECK(web_contents);
GetContentClient()->browser()->RequestPermission(
base::Closure cancel_callback; content::PERMISSION_PROTECTED_MEDIA,
GetContentClient()->browser()->RequestProtectedMediaIdentifierPermission(
web_contents, web_contents,
0, // bridge id
security_origin, security_origin,
// Only implemented for Android infobars which do not support
// user gestures.
true,
base::Bind(&BrowserCdmManager::CreateSessionIfPermitted, base::Bind(&BrowserCdmManager::CreateSessionIfPermitted,
this, this,
render_frame_id, cdm_id, session_id, render_frame_id,
mime_type, init_data), cdm_id,
&cancel_callback); session_id,
mime_type,
if (cancel_callback.is_null()) init_data));
return;
cdm_cancel_permission_map_[GetId(render_frame_id, cdm_id)] = cancel_callback;
} }
void BrowserCdmManager::OnUpdateSession( void BrowserCdmManager::OnUpdateSession(
......
...@@ -78,15 +78,17 @@ void MidiDispatcherHost::OnRequestSysExPermission( ...@@ -78,15 +78,17 @@ void MidiDispatcherHost::OnRequestSysExPermission(
render_process_id, render_frame_id, bridge_id); render_process_id, render_frame_id, bridge_id);
pending_permissions_.push_back(pending_permission); pending_permissions_.push_back(pending_permission);
GetContentClient()->browser()->RequestMidiSysExPermission( GetContentClient()->browser()->RequestPermission(
PERMISSION_MIDI_SYSEX,
web_contents(), web_contents(),
bridge_id, bridge_id,
origin, origin,
user_gesture, user_gesture,
base::Bind(&MidiDispatcherHost::WasSysExPermissionGranted, base::Bind(&MidiDispatcherHost::WasSysExPermissionGranted,
weak_factory_.GetWeakPtr(), weak_factory_.GetWeakPtr(),
render_process_id, render_frame_id, bridge_id), render_process_id,
&pending_permissions_.back().cancel); render_frame_id,
bridge_id));
} }
void MidiDispatcherHost::CancelPermissionRequestsForFrame( void MidiDispatcherHost::CancelPermissionRequestsForFrame(
...@@ -97,8 +99,12 @@ void MidiDispatcherHost::CancelPermissionRequestsForFrame( ...@@ -97,8 +99,12 @@ void MidiDispatcherHost::CancelPermissionRequestsForFrame(
for (size_t i = 0; i < pending_permissions_.size(); ++i) { for (size_t i = 0; i < pending_permissions_.size(); ++i) {
if (pending_permissions_[i].render_process_id == render_process_id && if (pending_permissions_[i].render_process_id == render_process_id &&
pending_permissions_[i].render_frame_id == render_frame_id) { pending_permissions_[i].render_frame_id == render_frame_id) {
if (!pending_permissions_[i].cancel.is_null()) GetContentClient()->browser()->CancelPermissionRequest(
pending_permissions_[i].cancel.Run(); PERMISSION_MIDI_SYSEX,
web_contents(),
pending_permissions_[i].bridge_id,
render_frame_host->GetLastCommittedURL());
pending_permissions_.erase(pending_permissions_.begin() + i); pending_permissions_.erase(pending_permissions_.begin() + i);
return; return;
} }
......
...@@ -51,7 +51,6 @@ class MidiDispatcherHost : public WebContentsObserver { ...@@ -51,7 +51,6 @@ class MidiDispatcherHost : public WebContentsObserver {
int render_process_id; int render_process_id;
int render_frame_id; int render_frame_id;
int bridge_id; int bridge_id;
base::Closure cancel;
}; };
std::vector<PendingPermission> pending_permissions_; std::vector<PendingPermission> pending_permissions_;
......
...@@ -162,6 +162,7 @@ ...@@ -162,6 +162,7 @@
'public/browser/page_navigator.cc', 'public/browser/page_navigator.cc',
'public/browser/page_navigator.h', 'public/browser/page_navigator.h',
'public/browser/pepper_flash_settings_helper.h', 'public/browser/pepper_flash_settings_helper.h',
'public/browser/permission_type.h',
'public/browser/plugin_data_remover.h', 'public/browser/plugin_data_remover.h',
'public/browser/plugin_service.h', 'public/browser/plugin_service.h',
'public/browser/plugin_service_filter.h', 'public/browser/plugin_service_filter.h',
......
...@@ -227,7 +227,8 @@ ContentBrowserClient::CheckDesktopNotificationPermission( ...@@ -227,7 +227,8 @@ ContentBrowserClient::CheckDesktopNotificationPermission(
return blink::WebNotificationPermissionAllowed; return blink::WebNotificationPermissionAllowed;
} }
void ContentBrowserClient::RequestGeolocationPermission( void ContentBrowserClient::RequestPermission(
PermissionType permission,
WebContents* web_contents, WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame, const GURL& requesting_frame,
...@@ -236,32 +237,6 @@ void ContentBrowserClient::RequestGeolocationPermission( ...@@ -236,32 +237,6 @@ void ContentBrowserClient::RequestGeolocationPermission(
result_callback.Run(true); result_callback.Run(true);
} }
// TODO(miguelg): replace all Create*Permission with a single
// CreatePermission(enum permission) method.
void ContentBrowserClient::CancelGeolocationPermissionRequest(
WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame) {
}
void ContentBrowserClient::RequestMidiSysExPermission(
WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame,
bool user_gesture,
base::Callback<void(bool)> result_callback,
base::Closure* cancel_callback) {
result_callback.Run(true);
}
void ContentBrowserClient::RequestProtectedMediaIdentifierPermission(
WebContents* web_contents,
const GURL& origin,
base::Callback<void(bool)> result_callback,
base::Closure* cancel_callback) {
result_callback.Run(true);
}
bool ContentBrowserClient::CanCreateWindow( bool ContentBrowserClient::CanCreateWindow(
const GURL& opener_url, const GURL& opener_url,
const GURL& opener_top_level_frame_url, const GURL& opener_top_level_frame_url,
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/values.h" #include "base/values.h"
#include "content/public/browser/certificate_request_result_type.h" #include "content/public/browser/certificate_request_result_type.h"
#include "content/public/browser/desktop_notification_delegate.h" #include "content/public/browser/desktop_notification_delegate.h"
#include "content/public/browser/permission_type.h"
#include "content/public/common/content_client.h" #include "content/public/common/content_client.h"
#include "content/public/common/media_stream_request.h" #include "content/public/common/media_stream_request.h"
#include "content/public/common/resource_type.h" #include "content/public/common/resource_type.h"
...@@ -417,13 +418,6 @@ class CONTENT_EXPORT ContentBrowserClient { ...@@ -417,13 +418,6 @@ class CONTENT_EXPORT ContentBrowserClient {
// return NULL if they're not interested. // return NULL if they're not interested.
virtual MediaObserver* GetMediaObserver(); virtual MediaObserver* GetMediaObserver();
// Asks permission to show desktop notifications. |callback| needs to be run
// when the user approves the request.
virtual void RequestDesktopNotificationPermission(
const GURL& source_origin,
RenderFrameHost* render_frame_host,
const base::Callback<void(blink::WebNotificationPermission)>& callback) {}
// Checks if the given page has permission to show desktop notifications. // Checks if the given page has permission to show desktop notifications.
// This is called on the IO thread. // This is called on the IO thread.
virtual blink::WebNotificationPermission virtual blink::WebNotificationPermission
...@@ -440,47 +434,23 @@ class CONTENT_EXPORT ContentBrowserClient { ...@@ -440,47 +434,23 @@ class CONTENT_EXPORT ContentBrowserClient {
scoped_ptr<DesktopNotificationDelegate> delegate, scoped_ptr<DesktopNotificationDelegate> delegate,
base::Closure* cancel_callback) {} base::Closure* cancel_callback) {}
// The renderer is requesting permission to use Geolocation. When the answer virtual void RequestPermission(
// to a permission request has been determined, |result_callback| should be PermissionType permission,
// called with the result. If |cancel_callback| is non-null, it's set to a
// callback which can be used to cancel the permission request.
virtual void RequestGeolocationPermission(
WebContents* web_contents, WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame, const GURL& requesting_frame,
bool user_gesture, bool user_gesture,
const base::Callback<void(bool)>& result_callback); const base::Callback<void(bool)>& result_callback);
virtual void CancelGeolocationPermissionRequest( virtual void CancelPermissionRequest(PermissionType permission,
WebContents* web_contents, WebContents* web_contents,
int bridge_id, int bridge_id,
const GURL& requesting_frame); const GURL& requesting_frame) {}
// Invoked when the Geolocation API uses its permission.
virtual void DidUseGeolocationPermission(WebContents* web_contents,
const GURL& frame_url,
const GURL& main_frame_url) {}
// Requests a permission to use system exclusive messages in MIDI events.
// |result_callback| will be invoked when the request is resolved. If
// |cancel_callback| is non-null, it's set to a callback which can be used to
// cancel the permission request.
virtual void RequestMidiSysExPermission(
WebContents* web_contents,
int bridge_id,
const GURL& requesting_frame,
bool user_gesture,
base::Callback<void(bool)> result_callback,
base::Closure* cancel_callback);
// Request permission to access protected media identifier. |result_callback virtual void RegisterPermissionUsage(PermissionType permission,
// will tell whether it's permitted. If |cancel_callback| is non-null, it's WebContents* web_contents,
// set to a callback which can be used to cancel the permission request. const GURL& frame_url,
virtual void RequestProtectedMediaIdentifierPermission( const GURL& main_frame_url) {}
WebContents* web_contents,
const GURL& origin,
base::Callback<void(bool)> result_callback,
base::Closure* cancel_callback);
// Returns true if the given page is allowed to open a window of the given // Returns true if the given page is allowed to open a window of the given
// type. If true is returned, |no_javascript_access| will indicate whether // type. If true is returned, |no_javascript_access| will indicate whether
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CONTENT_PUBLIC_BROWSER_PERMISSION_TYPE_H_
#define CONTENT_PUBLIC_BROWSER_PERMISSION_TYPE_H_
namespace content {
// This enum is also used for UMA purposes, so it needs to adhere to
// the UMA guidelines.
// Make sure you update histograms.xml if you add new permission types.
// Never delete or reorder an entry; only add new entries
// immediately before PERMISSION_NUM
enum PermissionType {
PERMISSION_MIDI_SYSEX = 1,
PERMISSION_PUSH_MESSAGING = 2,
PERMISSION_NOTIFICATIONS = 3,
PERMISSION_GEOLOCATION = 4,
PERMISSION_PROTECTED_MEDIA = 5,
// Always keep this at the end.
PERMISSION_NUM,
};
} // namespace content
#endif // CONTENT_PUBLIC_BROWSER_PERMISSION_TYPE_H_
...@@ -21,14 +21,13 @@ LayoutTestContentBrowserClient* g_layout_test_browser_client; ...@@ -21,14 +21,13 @@ LayoutTestContentBrowserClient* g_layout_test_browser_client;
void RequestDesktopNotificationPermissionOnIO( void RequestDesktopNotificationPermissionOnIO(
const GURL& source_origin, const GURL& source_origin,
RenderFrameHost* render_frame_host, const base::Callback<void(bool)>& callback) {
const base::Callback<void(blink::WebNotificationPermission)>& callback) {
LayoutTestNotificationManager* manager = LayoutTestNotificationManager* manager =
LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager(); LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
if (manager) if (manager)
manager->RequestPermission(source_origin, callback); manager->RequestPermission(source_origin, callback);
else else
callback.Run(blink::WebNotificationPermissionAllowed); callback.Run(true);
} }
} // namespace } // namespace
...@@ -70,17 +69,29 @@ void LayoutTestContentBrowserClient::RenderProcessWillLaunch( ...@@ -70,17 +69,29 @@ void LayoutTestContentBrowserClient::RenderProcessWillLaunch(
host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath())); host->Send(new ShellViewMsg_SetWebKitSourceDir(GetWebKitRootDirFilePath()));
} }
void LayoutTestContentBrowserClient::RequestDesktopNotificationPermission( void LayoutTestContentBrowserClient::RequestPermission(
const GURL& source_origin, PermissionType permission,
RenderFrameHost* render_frame_host, WebContents* web_contents,
const base::Callback<void(blink::WebNotificationPermission)>& callback) { int bridge_id,
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); const GURL& requesting_frame,
BrowserThread::PostTask(BrowserThread::IO, bool user_gesture,
FROM_HERE, const base::Callback<void(bool)>& result_callback) {
base::Bind(&RequestDesktopNotificationPermissionOnIO, DCHECK_CURRENTLY_ON(BrowserThread::UI);
source_origin, if (permission == content::PERMISSION_NOTIFICATIONS) {
render_frame_host, BrowserThread::PostTask(
callback)); BrowserThread::IO,
FROM_HERE,
base::Bind(&RequestDesktopNotificationPermissionOnIO,
requesting_frame,
result_callback));
return;
}
ShellContentBrowserClient::RequestPermission(permission,
web_contents,
bridge_id,
requesting_frame,
user_gesture,
result_callback);
} }
blink::WebNotificationPermission blink::WebNotificationPermission
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_CONTENT_BROWSER_CLIENT_H_ #ifndef CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_CONTENT_BROWSER_CLIENT_H_
#define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_CONTENT_BROWSER_CLIENT_H_ #define CONTENT_SHELL_BROWSER_LAYOUT_TEST_LAYOUT_TEST_CONTENT_BROWSER_CLIENT_H_
#include "content/public/browser/permission_type.h"
#include "content/shell/browser/shell_content_browser_client.h" #include "content/shell/browser/shell_content_browser_client.h"
namespace content { namespace content {
...@@ -24,11 +25,13 @@ class LayoutTestContentBrowserClient : public ShellContentBrowserClient { ...@@ -24,11 +25,13 @@ class LayoutTestContentBrowserClient : public ShellContentBrowserClient {
// ContentBrowserClient overrides. // ContentBrowserClient overrides.
void RenderProcessWillLaunch(RenderProcessHost* host) override; void RenderProcessWillLaunch(RenderProcessHost* host) override;
void RequestDesktopNotificationPermission( void RequestPermission(
const GURL& source_origin, PermissionType permission,
RenderFrameHost* render_frame_host, WebContents* web_contents,
const base::Callback<void(blink::WebNotificationPermission)>& callback) int bridge_id,
override; const GURL& requesting_frame,
bool user_gesture,
const base::Callback<void(bool)>& result_callback) override;
blink::WebNotificationPermission CheckDesktopNotificationPermission( blink::WebNotificationPermission CheckDesktopNotificationPermission(
const GURL& source_url, const GURL& source_url,
ResourceContext* context, ResourceContext* context,
......
...@@ -29,9 +29,10 @@ LayoutTestNotificationManager::CheckPermission(const GURL& origin) { ...@@ -29,9 +29,10 @@ LayoutTestNotificationManager::CheckPermission(const GURL& origin) {
void LayoutTestNotificationManager::RequestPermission( void LayoutTestNotificationManager::RequestPermission(
const GURL& origin, const GURL& origin,
const base::Callback<void(blink::WebNotificationPermission)>& callback) { const base::Callback<void(bool)>& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); bool allowed =
callback.Run(CheckPermission(origin)); CheckPermission(origin) == blink::WebNotificationPermissionAllowed;
callback.Run(allowed);
} }
void LayoutTestNotificationManager::SetPermission( void LayoutTestNotificationManager::SetPermission(
......
...@@ -34,7 +34,7 @@ class LayoutTestNotificationManager { ...@@ -34,7 +34,7 @@ class LayoutTestNotificationManager {
// Must be called on the IO thread. // Must be called on the IO thread.
void RequestPermission( void RequestPermission(
const GURL& origin, const GURL& origin,
const base::Callback<void(blink::WebNotificationPermission)>& callback); const base::Callback<void(bool)>& callback);
// Sets the permission to display notifications for |origin| to |permission|. // Sets the permission to display notifications for |origin| to |permission|.
// Must be called on the IO thread. // Must be called on the IO thread.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment