Index: chrome/browser/permissions/permission_queue_controller.cc |
diff --git a/chrome/browser/permissions/permission_queue_controller.cc b/chrome/browser/permissions/permission_queue_controller.cc |
index 3ea8d9fe6340dcee3a7b1eecae1b13d9620ae31a..3382aaadc0e6deedeec7514712f664eb18699061 100644 |
--- a/chrome/browser/permissions/permission_queue_controller.cc |
+++ b/chrome/browser/permissions/permission_queue_controller.cc |
@@ -53,6 +53,7 @@ class PermissionQueueController::PendingInfobarRequest { |
const PermissionRequestID& id, |
const GURL& requesting_frame, |
const GURL& embedder, |
+ bool user_gesture, |
Profile* profile, |
const PermissionDecidedCallback& callback); |
~PendingInfobarRequest(); |
@@ -73,6 +74,7 @@ class PermissionQueueController::PendingInfobarRequest { |
PermissionRequestID id_; |
GURL requesting_frame_; |
GURL embedder_; |
+ bool user_gesture_; |
Profile* profile_; |
PermissionDecidedCallback callback_; |
infobars::InfoBar* infobar_; |
@@ -85,12 +87,14 @@ PermissionQueueController::PendingInfobarRequest::PendingInfobarRequest( |
const PermissionRequestID& id, |
const GURL& requesting_frame, |
const GURL& embedder, |
+ bool user_gesture, |
Profile* profile, |
const PermissionDecidedCallback& callback) |
: type_(type), |
id_(id), |
requesting_frame_(requesting_frame), |
embedder_(embedder), |
+ user_gesture_(user_gesture), |
profile_(profile), |
callback_(callback), |
infobar_(NULL) {} |
@@ -115,30 +119,31 @@ void PermissionQueueController::PendingInfobarRequest::CreateInfoBar( |
// is tied to that of the queue controller. Before QueueController |
// is destroyed, all requests will be cancelled and so all delegates |
// will be destroyed. |
- PermissionInfobarDelegate::PermissionSetCallback callback = |
- base::Bind(&PermissionQueueController::OnPermissionSet, |
- base::Unretained(controller), |
- id_, |
- requesting_frame_, |
- embedder_); |
+ PermissionInfobarDelegate::PermissionSetCallback callback = base::Bind( |
+ &PermissionQueueController::OnPermissionSet, base::Unretained(controller), |
+ id_, requesting_frame_, embedder_, user_gesture_); |
switch (type_) { |
case content::PermissionType::GEOLOCATION: |
infobar_ = GeolocationInfoBarDelegateAndroid::Create( |
- GetInfoBarService(id_), requesting_frame_, profile_, callback); |
+ GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, |
+ callback); |
break; |
#if defined(ENABLE_NOTIFICATIONS) |
case content::PermissionType::NOTIFICATIONS: |
infobar_ = NotificationPermissionInfobarDelegate::Create( |
- GetInfoBarService(id_), requesting_frame_, profile_, callback); |
+ GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, |
+ callback); |
break; |
#endif // ENABLE_NOTIFICATIONS |
case content::PermissionType::MIDI_SYSEX: |
infobar_ = MidiPermissionInfoBarDelegateAndroid::Create( |
- GetInfoBarService(id_), requesting_frame_, profile_, callback); |
+ GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, |
+ callback); |
break; |
case content::PermissionType::PROTECTED_MEDIA_IDENTIFIER: |
infobar_ = ProtectedMediaIdentifierInfoBarDelegateAndroid::Create( |
- GetInfoBarService(id_), requesting_frame_, profile_, callback); |
+ GetInfoBarService(id_), requesting_frame_, user_gesture_, profile_, |
+ callback); |
break; |
default: |
NOTREACHED(); |
@@ -166,6 +171,7 @@ void PermissionQueueController::CreateInfoBarRequest( |
const PermissionRequestID& id, |
const GURL& requesting_frame, |
const GURL& embedder, |
+ bool user_gesture, |
const PermissionDecidedCallback& callback) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
@@ -173,8 +179,9 @@ void PermissionQueueController::CreateInfoBarRequest( |
embedder.SchemeIs(content::kChromeUIScheme)) |
return; |
- pending_infobar_requests_.push_back(PendingInfobarRequest( |
- permission_type_, id, requesting_frame, embedder, profile_, callback)); |
+ pending_infobar_requests_.push_back( |
+ PendingInfobarRequest(permission_type_, id, requesting_frame, embedder, |
+ user_gesture, profile_, callback)); |
if (!AlreadyShowingInfoBarForTab(id)) |
ShowQueuedInfoBarForTab(id); |
} |
@@ -197,32 +204,31 @@ void PermissionQueueController::CancelInfoBarRequest( |
} |
} |
-void PermissionQueueController::OnPermissionSet( |
- const PermissionRequestID& id, |
- const GURL& requesting_frame, |
- const GURL& embedder, |
- bool update_content_setting, |
- bool allowed) { |
+void PermissionQueueController::OnPermissionSet(const PermissionRequestID& id, |
+ const GURL& requesting_frame, |
+ const GURL& embedder, |
+ bool user_gesture, |
+ bool update_content_setting, |
+ bool allowed) { |
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
// TODO(miguelg): move the permission persistence to |
// PermissionContextBase once all the types are moved there. |
- // TODO(stefanocs): Pass the actual |gesture_type| value to PermissionUmaUtil. |
+ PermissionRequestGestureType gesture_type = |
+ user_gesture ? PermissionRequestGestureType::GESTURE |
+ : PermissionRequestGestureType::NO_GESTURE; |
if (update_content_setting) { |
UpdateContentSetting(requesting_frame, embedder, allowed); |
if (allowed) { |
- PermissionUmaUtil::PermissionGranted( |
- permission_type_, PermissionRequestGestureType::UNKNOWN, |
- requesting_frame, profile_); |
+ PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, |
+ requesting_frame, profile_); |
} else { |
- PermissionUmaUtil::PermissionDenied(permission_type_, |
- PermissionRequestGestureType::UNKNOWN, |
+ PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, |
requesting_frame, profile_); |
} |
} else { |
- PermissionUmaUtil::PermissionDismissed( |
- permission_type_, PermissionRequestGestureType::UNKNOWN, |
- requesting_frame, profile_); |
+ PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, |
+ requesting_frame, profile_); |
} |
// Cancel this request first, then notify listeners. TODO(pkasting): Why |