| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_context_base.h" | 5 #include "chrome/browser/permissions/permission_context_base.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 } | 217 } |
| 218 | 218 |
| 219 void PermissionContextBase::PermissionDecided( | 219 void PermissionContextBase::PermissionDecided( |
| 220 const PermissionRequestID& id, | 220 const PermissionRequestID& id, |
| 221 const GURL& requesting_origin, | 221 const GURL& requesting_origin, |
| 222 const GURL& embedding_origin, | 222 const GURL& embedding_origin, |
| 223 bool user_gesture, | 223 bool user_gesture, |
| 224 const BrowserPermissionCallback& callback, | 224 const BrowserPermissionCallback& callback, |
| 225 bool persist, | 225 bool persist, |
| 226 ContentSetting content_setting) { | 226 ContentSetting content_setting) { |
| 227 #if !defined(OS_ANDROID) | 227 if (PermissionRequestManager::IsEnabled()) { |
| 228 // Infobar persistence and its related UMA is tracked on the infobar | 228 // Infobar persistence and its related UMA is tracked on the infobar |
| 229 // controller directly. | 229 // controller directly. |
| 230 PermissionRequestGestureType gesture_type = | 230 PermissionRequestGestureType gesture_type = |
| 231 user_gesture ? PermissionRequestGestureType::GESTURE | 231 user_gesture ? PermissionRequestGestureType::GESTURE |
| 232 : PermissionRequestGestureType::NO_GESTURE; | 232 : PermissionRequestGestureType::NO_GESTURE; |
| 233 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 233 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 234 content_setting == CONTENT_SETTING_BLOCK || | 234 content_setting == CONTENT_SETTING_BLOCK || |
| 235 content_setting == CONTENT_SETTING_DEFAULT); | 235 content_setting == CONTENT_SETTING_DEFAULT); |
| 236 if (content_setting == CONTENT_SETTING_ALLOW) { | 236 if (content_setting == CONTENT_SETTING_ALLOW) { |
| 237 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, | 237 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, |
| 238 requesting_origin, profile_); | |
| 239 } else if (content_setting == CONTENT_SETTING_BLOCK) { | |
| 240 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, | |
| 241 requesting_origin, profile_); | |
| 242 } else { | |
| 243 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, | |
| 244 requesting_origin, profile_); | 238 requesting_origin, profile_); |
| 239 } else if (content_setting == CONTENT_SETTING_BLOCK) { |
| 240 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, |
| 241 requesting_origin, profile_); |
| 242 } else { |
| 243 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, |
| 244 requesting_origin, profile_); |
| 245 } |
| 245 } | 246 } |
| 246 #endif | |
| 247 | 247 |
| 248 // Check if we should convert a dismiss decision into a block decision. This | 248 // Check if we should convert a dismiss decision into a block decision. This |
| 249 // is gated on enabling the kBlockPromptsIfDismissedOften feature. | 249 // is gated on enabling the kBlockPromptsIfDismissedOften feature. |
| 250 if (content_setting == CONTENT_SETTING_DEFAULT && | 250 if (content_setting == CONTENT_SETTING_DEFAULT && |
| 251 PermissionDecisionAutoBlocker::ShouldChangeDismissalToBlock( | 251 PermissionDecisionAutoBlocker::ShouldChangeDismissalToBlock( |
| 252 requesting_origin, permission_type_, profile_)) { | 252 requesting_origin, permission_type_, profile_)) { |
| 253 persist = true; | 253 persist = true; |
| 254 content_setting = CONTENT_SETTING_BLOCK; | 254 content_setting = CONTENT_SETTING_BLOCK; |
| 255 } | 255 } |
| 256 | 256 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 content_setting); | 311 content_setting); |
| 312 } | 312 } |
| 313 | 313 |
| 314 bool PermissionContextBase::IsPermissionKillSwitchOn() const { | 314 bool PermissionContextBase::IsPermissionKillSwitchOn() const { |
| 315 const std::string param = variations::GetVariationParamValue( | 315 const std::string param = variations::GetVariationParamValue( |
| 316 kPermissionsKillSwitchFieldStudy, | 316 kPermissionsKillSwitchFieldStudy, |
| 317 PermissionUtil::GetPermissionString(permission_type_)); | 317 PermissionUtil::GetPermissionString(permission_type_)); |
| 318 | 318 |
| 319 return param == kPermissionsKillSwitchBlockedValue; | 319 return param == kPermissionsKillSwitchBlockedValue; |
| 320 } | 320 } |
| OLD | NEW |