OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/permissions/permission_queue_controller.h" | 5 #include "chrome/browser/permissions/permission_queue_controller.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 const GURL& embedder, | 214 const GURL& embedder, |
215 bool user_gesture, | 215 bool user_gesture, |
216 bool update_content_setting, | 216 bool update_content_setting, |
217 PermissionAction decision) { | 217 PermissionAction decision) { |
218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 218 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
219 | 219 |
220 PermissionRequestType request_type = | 220 PermissionRequestType request_type = |
221 PermissionUtil::GetRequestType(content_settings_type_); | 221 PermissionUtil::GetRequestType(content_settings_type_); |
222 PermissionRequestGestureType gesture_type = | 222 PermissionRequestGestureType gesture_type = |
223 PermissionUtil::GetGestureType(user_gesture); | 223 PermissionUtil::GetGestureType(user_gesture); |
| 224 PermissionEmbargoStatus embargo_status = |
| 225 PermissionEmbargoStatus::NOT_EMBARGOED; |
| 226 |
224 switch (decision) { | 227 switch (decision) { |
225 case GRANTED: | 228 case GRANTED: |
226 PermissionUmaUtil::PermissionGranted(content_settings_type_, gesture_type, | 229 PermissionUmaUtil::PermissionGranted(content_settings_type_, gesture_type, |
227 requesting_frame, profile_); | 230 requesting_frame, profile_); |
228 PermissionUmaUtil::RecordPermissionPromptAccepted(request_type, | 231 PermissionUmaUtil::RecordPermissionPromptAccepted(request_type, |
229 gesture_type); | 232 gesture_type); |
230 PermissionUmaUtil::RecordPermissionEmbargoStatus( | |
231 PermissionEmbargoStatus::NOT_EMBARGOED); | |
232 break; | 233 break; |
233 case DENIED: | 234 case DENIED: |
234 PermissionUmaUtil::PermissionDenied(content_settings_type_, gesture_type, | 235 PermissionUmaUtil::PermissionDenied(content_settings_type_, gesture_type, |
235 requesting_frame, profile_); | 236 requesting_frame, profile_); |
236 PermissionUmaUtil::RecordPermissionPromptDenied(request_type, | 237 PermissionUmaUtil::RecordPermissionPromptDenied(request_type, |
237 gesture_type); | 238 gesture_type); |
238 PermissionUmaUtil::RecordPermissionEmbargoStatus( | |
239 PermissionEmbargoStatus::NOT_EMBARGOED); | |
240 break; | 239 break; |
241 case DISMISSED: | 240 case DISMISSED: |
242 PermissionUmaUtil::PermissionDismissed( | 241 PermissionUmaUtil::PermissionDismissed( |
243 content_settings_type_, gesture_type, requesting_frame, profile_); | 242 content_settings_type_, gesture_type, requesting_frame, profile_); |
244 if (PermissionDecisionAutoBlocker::GetForProfile(profile_) | 243 if (PermissionDecisionAutoBlocker::GetForProfile(profile_) |
245 ->RecordDismissAndEmbargo(requesting_frame, | 244 ->RecordDismissAndEmbargo(requesting_frame, |
246 content_settings_type_)) { | 245 content_settings_type_)) { |
247 PermissionUmaUtil::RecordPermissionEmbargoStatus( | 246 embargo_status = PermissionEmbargoStatus::REPEATED_DISMISSALS; |
248 PermissionEmbargoStatus::REPEATED_DISMISSALS); | |
249 } else { | |
250 PermissionUmaUtil::RecordPermissionEmbargoStatus( | |
251 PermissionEmbargoStatus::NOT_EMBARGOED); | |
252 } | 247 } |
253 break; | 248 break; |
254 default: | 249 default: |
255 NOTREACHED(); | 250 NOTREACHED(); |
256 } | 251 } |
| 252 PermissionUmaUtil::RecordEmbargoStatus(embargo_status); |
257 | 253 |
258 // TODO(miguelg): move the permission persistence to | 254 // TODO(miguelg): move the permission persistence to |
259 // PermissionContextBase once all the types are moved there. | 255 // PermissionContextBase once all the types are moved there. |
260 if (update_content_setting) | 256 if (update_content_setting) |
261 UpdateContentSetting(requesting_frame, embedder, decision); | 257 UpdateContentSetting(requesting_frame, embedder, decision); |
262 | 258 |
263 // Cancel this request first, then notify listeners. TODO(pkasting): Why | 259 // Cancel this request first, then notify listeners. TODO(pkasting): Why |
264 // is this order important? | 260 // is this order important? |
265 PendingInfobarRequests requests_to_notify; | 261 PendingInfobarRequests requests_to_notify; |
266 PendingInfobarRequests infobars_to_remove; | 262 PendingInfobarRequests infobars_to_remove; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 // TODO(timloh): Remove this logic when push and notification permissions | 446 // TODO(timloh): Remove this logic when push and notification permissions |
451 // are reconciled, see crbug.com/563297. | 447 // are reconciled, see crbug.com/563297. |
452 ContentSettingsType type_for_map = content_settings_type_; | 448 ContentSettingsType type_for_map = content_settings_type_; |
453 if (type_for_map == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) | 449 if (type_for_map == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) |
454 type_for_map = CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | 450 type_for_map = CONTENT_SETTINGS_TYPE_NOTIFICATIONS; |
455 HostContentSettingsMapFactory::GetForProfile(profile_) | 451 HostContentSettingsMapFactory::GetForProfile(profile_) |
456 ->SetContentSettingDefaultScope( | 452 ->SetContentSettingDefaultScope( |
457 requesting_frame.GetOrigin(), embedder.GetOrigin(), | 453 requesting_frame.GetOrigin(), embedder.GetOrigin(), |
458 type_for_map, std::string(), content_setting); | 454 type_for_map, std::string(), content_setting); |
459 } | 455 } |
OLD | NEW |