| 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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 bool persist, | 266 bool persist, |
| 267 ContentSetting content_setting) { | 267 ContentSetting content_setting) { |
| 268 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 268 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 269 | 269 |
| 270 if (persist) | 270 if (persist) |
| 271 UpdateContentSetting(requesting_origin, embedding_origin, content_setting); | 271 UpdateContentSetting(requesting_origin, embedding_origin, content_setting); |
| 272 | 272 |
| 273 UpdateTabContext(id, requesting_origin, | 273 UpdateTabContext(id, requesting_origin, |
| 274 content_setting == CONTENT_SETTING_ALLOW); | 274 content_setting == CONTENT_SETTING_ALLOW); |
| 275 | 275 |
| 276 if (content_setting == CONTENT_SETTING_DEFAULT) { | 276 if (content_setting == CONTENT_SETTING_DEFAULT) |
| 277 content_setting = | 277 content_setting = CONTENT_SETTING_ASK; |
| 278 HostContentSettingsMapFactory::GetForProfile(profile_) | |
| 279 ->GetDefaultContentSetting(content_settings_type_, nullptr); | |
| 280 } | |
| 281 | 278 |
| 282 DCHECK_NE(content_setting, CONTENT_SETTING_DEFAULT); | |
| 283 callback.Run(content_setting); | 279 callback.Run(content_setting); |
| 284 } | 280 } |
| 285 | 281 |
| 286 void PermissionContextBase::CleanUpRequest(const PermissionRequestID& id) { | 282 void PermissionContextBase::CleanUpRequest(const PermissionRequestID& id) { |
| 287 size_t success = pending_requests_.erase(id.ToString()); | 283 size_t success = pending_requests_.erase(id.ToString()); |
| 288 DCHECK(success == 1) << "Missing request " << id.ToString(); | 284 DCHECK(success == 1) << "Missing request " << id.ToString(); |
| 289 } | 285 } |
| 290 | 286 |
| 291 void PermissionContextBase::UpdateContentSetting( | 287 void PermissionContextBase::UpdateContentSetting( |
| 292 const GURL& requesting_origin, | 288 const GURL& requesting_origin, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 303 content_setting); | 299 content_setting); |
| 304 } | 300 } |
| 305 | 301 |
| 306 bool PermissionContextBase::IsPermissionKillSwitchOn() const { | 302 bool PermissionContextBase::IsPermissionKillSwitchOn() const { |
| 307 const std::string param = variations::GetVariationParamValue( | 303 const std::string param = variations::GetVariationParamValue( |
| 308 kPermissionsKillSwitchFieldStudy, | 304 kPermissionsKillSwitchFieldStudy, |
| 309 PermissionUtil::GetPermissionString(permission_type_)); | 305 PermissionUtil::GetPermissionString(permission_type_)); |
| 310 | 306 |
| 311 return param == kPermissionsKillSwitchBlockedValue; | 307 return param == kPermissionsKillSwitchBlockedValue; |
| 312 } | 308 } |
| OLD | NEW |