| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 bool user_gesture, | 213 bool user_gesture, |
| 214 const BrowserPermissionCallback& callback, | 214 const BrowserPermissionCallback& callback, |
| 215 bool persist, | 215 bool persist, |
| 216 ContentSetting content_setting) { | 216 ContentSetting content_setting) { |
| 217 #if !defined(OS_ANDROID) | 217 #if !defined(OS_ANDROID) |
| 218 // Infobar persistence and its related UMA is tracked on the infobar | 218 // Infobar persistence and its related UMA is tracked on the infobar |
| 219 // controller directly. | 219 // controller directly. |
| 220 PermissionRequestGestureType gesture_type = | 220 PermissionRequestGestureType gesture_type = |
| 221 user_gesture ? PermissionRequestGestureType::GESTURE | 221 user_gesture ? PermissionRequestGestureType::GESTURE |
| 222 : PermissionRequestGestureType::NO_GESTURE; | 222 : PermissionRequestGestureType::NO_GESTURE; |
| 223 if (persist) { | 223 DCHECK(content_setting == CONTENT_SETTING_ALLOW || |
| 224 DCHECK(content_setting == CONTENT_SETTING_ALLOW || | 224 content_setting == CONTENT_SETTING_BLOCK || |
| 225 content_setting == CONTENT_SETTING_BLOCK); | 225 content_setting == CONTENT_SETTING_DEFAULT); |
| 226 if (content_setting == CONTENT_SETTING_ALLOW) { | 226 if (content_setting == CONTENT_SETTING_ALLOW) { |
| 227 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, | 227 PermissionUmaUtil::PermissionGranted(permission_type_, gesture_type, |
| 228 requesting_origin, profile_); | 228 requesting_origin, profile_); |
| 229 } else { | 229 } else if (content_setting == CONTENT_SETTING_BLOCK) { |
| 230 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, | 230 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, |
| 231 requesting_origin, profile_); | 231 requesting_origin, profile_); |
| 232 } | |
| 233 } else { | 232 } else { |
| 234 DCHECK_EQ(content_setting, CONTENT_SETTING_DEFAULT); | |
| 235 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, | 233 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, |
| 236 requesting_origin, profile_); | 234 requesting_origin, profile_); |
| 237 } | 235 } |
| 238 #endif | 236 #endif |
| 239 | 237 |
| 240 // Check if we should convert a dismiss decision into a block decision. This | 238 // Check if we should convert a dismiss decision into a block decision. This |
| 241 // is gated on enabling the kBlockPromptsIfDismissedOften feature. | 239 // is gated on enabling the kBlockPromptsIfDismissedOften feature. |
| 242 if (!persist && | 240 if (content_setting == CONTENT_SETTING_DEFAULT && |
| 243 decision_auto_blocker_->ShouldChangeDismissalToBlock(requesting_origin, | 241 decision_auto_blocker_->ShouldChangeDismissalToBlock(requesting_origin, |
| 244 permission_type_)) { | 242 permission_type_)) { |
| 245 persist = true; | 243 persist = true; |
| 246 content_setting = CONTENT_SETTING_BLOCK; | 244 content_setting = CONTENT_SETTING_BLOCK; |
| 247 } | 245 } |
| 248 | 246 |
| 249 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 247 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 250 persist, content_setting); | 248 persist, content_setting); |
| 251 } | 249 } |
| 252 | 250 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 content_setting); | 303 content_setting); |
| 306 } | 304 } |
| 307 | 305 |
| 308 bool PermissionContextBase::IsPermissionKillSwitchOn() const { | 306 bool PermissionContextBase::IsPermissionKillSwitchOn() const { |
| 309 const std::string param = variations::GetVariationParamValue( | 307 const std::string param = variations::GetVariationParamValue( |
| 310 kPermissionsKillSwitchFieldStudy, | 308 kPermissionsKillSwitchFieldStudy, |
| 311 PermissionUtil::GetPermissionString(permission_type_)); | 309 PermissionUtil::GetPermissionString(permission_type_)); |
| 312 | 310 |
| 313 return param == kPermissionsKillSwitchBlockedValue; | 311 return param == kPermissionsKillSwitchBlockedValue; |
| 314 } | 312 } |
| OLD | NEW |