| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #if defined(OS_ANDROID) | 29 #if defined(OS_ANDROID) |
| 30 #include "chrome/browser/permissions/permission_queue_controller.h" | 30 #include "chrome/browser/permissions/permission_queue_controller.h" |
| 31 #else | 31 #else |
| 32 #include "chrome/browser/permissions/permission_request_impl.h" | 32 #include "chrome/browser/permissions/permission_request_impl.h" |
| 33 #include "chrome/browser/permissions/permission_request_manager.h" | 33 #include "chrome/browser/permissions/permission_request_manager.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 const char PermissionContextBase::kPermissionsKillSwitchFieldStudy[] = | 37 const char PermissionContextBase::kPermissionsKillSwitchFieldStudy[] = |
| 38 "PermissionsKillSwitch"; | 38 "PermissionsKillSwitch"; |
| 39 // static | |
| 40 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] = | 39 const char PermissionContextBase::kPermissionsKillSwitchBlockedValue[] = |
| 41 "blocked"; | 40 "blocked"; |
| 41 base::LazyInstance<PermissionPromptDecisionLog> |
| 42 PermissionContextBase::prompt_decision_log_ = LAZY_INSTANCE_INITIALIZER; |
| 42 | 43 |
| 43 PermissionContextBase::PermissionContextBase( | 44 PermissionContextBase::PermissionContextBase( |
| 44 Profile* profile, | 45 Profile* profile, |
| 45 const content::PermissionType permission_type, | 46 const content::PermissionType permission_type, |
| 46 const ContentSettingsType content_settings_type) | 47 const ContentSettingsType content_settings_type) |
| 47 : profile_(profile), | 48 : profile_(profile), |
| 48 permission_type_(permission_type), | 49 permission_type_(permission_type), |
| 49 content_settings_type_(content_settings_type), | 50 content_settings_type_(content_settings_type), |
| 50 weak_factory_(this) { | 51 weak_factory_(this) { |
| 51 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, | 227 PermissionUmaUtil::PermissionDenied(permission_type_, gesture_type, |
| 227 requesting_origin, profile_); | 228 requesting_origin, profile_); |
| 228 } | 229 } |
| 229 } else { | 230 } else { |
| 230 DCHECK_EQ(content_setting, CONTENT_SETTING_DEFAULT); | 231 DCHECK_EQ(content_setting, CONTENT_SETTING_DEFAULT); |
| 231 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, | 232 PermissionUmaUtil::PermissionDismissed(permission_type_, gesture_type, |
| 232 requesting_origin, profile_); | 233 requesting_origin, profile_); |
| 233 } | 234 } |
| 234 #endif | 235 #endif |
| 235 | 236 |
| 237 // Check if we should convert a dismiss decision into a block decision. This |
| 238 // is gated on enabling the kBlockPromptsIfDismissedOften feature. |
| 239 if (!persist && |
| 240 prompt_decision_log_.Get().ShouldChangeDismissalToBlock( |
| 241 profile_, requesting_origin, permission_type_)) { |
| 242 persist = true; |
| 243 content_setting = CONTENT_SETTING_BLOCK; |
| 244 } |
| 245 |
| 236 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, | 246 NotifyPermissionSet(id, requesting_origin, embedding_origin, callback, |
| 237 persist, content_setting); | 247 persist, content_setting); |
| 238 } | 248 } |
| 239 | 249 |
| 240 #if defined(OS_ANDROID) | 250 #if defined(OS_ANDROID) |
| 241 PermissionQueueController* PermissionContextBase::GetQueueController() { | 251 PermissionQueueController* PermissionContextBase::GetQueueController() { |
| 242 return permission_queue_controller_.get(); | 252 return permission_queue_controller_.get(); |
| 243 } | 253 } |
| 244 #endif | 254 #endif |
| 245 | 255 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 content_setting); | 302 content_setting); |
| 293 } | 303 } |
| 294 | 304 |
| 295 bool PermissionContextBase::IsPermissionKillSwitchOn() const { | 305 bool PermissionContextBase::IsPermissionKillSwitchOn() const { |
| 296 const std::string param = variations::GetVariationParamValue( | 306 const std::string param = variations::GetVariationParamValue( |
| 297 kPermissionsKillSwitchFieldStudy, | 307 kPermissionsKillSwitchFieldStudy, |
| 298 PermissionUtil::GetPermissionString(permission_type_)); | 308 PermissionUtil::GetPermissionString(permission_type_)); |
| 299 | 309 |
| 300 return param == kPermissionsKillSwitchBlockedValue; | 310 return param == kPermissionsKillSwitchBlockedValue; |
| 301 } | 311 } |
| OLD | NEW |