Chromium Code Reviews| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 } | 115 } |
| 116 | 116 |
| 117 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin, | 117 PermissionUmaUtil::PermissionRequested(permission_type_, requesting_origin, |
| 118 embedding_origin, profile_); | 118 embedding_origin, profile_); |
| 119 | 119 |
| 120 DecidePermission(web_contents, id, requesting_origin, embedding_origin, | 120 DecidePermission(web_contents, id, requesting_origin, embedding_origin, |
| 121 user_gesture, callback); | 121 user_gesture, callback); |
| 122 } | 122 } |
| 123 | 123 |
| 124 ContentSetting PermissionContextBase::GetPermissionStatus( | 124 ContentSetting PermissionContextBase::GetPermissionStatus( |
| 125 HostContentSettingsMap* host, | |
| 125 const GURL& requesting_origin, | 126 const GURL& requesting_origin, |
| 126 const GURL& embedding_origin) const { | 127 const GURL& embedding_origin) const { |
| 127 | |
| 128 // If the permission has been disabled through Finch, block all requests. | 128 // If the permission has been disabled through Finch, block all requests. |
| 129 if (IsPermissionKillSwitchOn()) | 129 if (IsPermissionKillSwitchOn()) |
| 130 return CONTENT_SETTING_BLOCK; | 130 return CONTENT_SETTING_BLOCK; |
| 131 | 131 |
| 132 if (IsRestrictedToSecureOrigins() && | 132 if (IsRestrictedToSecureOrigins() && |
| 133 !content::IsOriginSecure(requesting_origin)) { | 133 !content::IsOriginSecure(requesting_origin)) { |
| 134 return CONTENT_SETTING_BLOCK; | 134 return CONTENT_SETTING_BLOCK; |
| 135 } | 135 } |
| 136 | 136 |
| 137 return HostContentSettingsMapFactory::GetForProfile(profile_) | 137 return host->GetContentSetting(requesting_origin, embedding_origin, |
| 138 ->GetContentSetting(requesting_origin, embedding_origin, | 138 content_settings_type_, std::string()); |
| 139 content_settings_type_, std::string()); | 139 } |
| 140 | |
| 141 ContentSetting PermissionContextBase::GetPermissionStatus( | |
| 142 const GURL& requesting_origin, | |
| 143 const GURL& embedding_origin) const { | |
| 144 HostContentSettingsMap* host = | |
|
mlamouri (slow - plz ping)
2016/10/22 11:36:38
If that method needs to be called from the UI thre
| |
| 145 HostContentSettingsMapFactory::GetForProfile(profile_); | |
| 146 return GetPermissionStatus(host, requesting_origin, embedding_origin); | |
| 140 } | 147 } |
| 141 | 148 |
| 142 void PermissionContextBase::ResetPermission( | 149 void PermissionContextBase::ResetPermission( |
| 143 const GURL& requesting_origin, | 150 const GURL& requesting_origin, |
| 144 const GURL& embedding_origin) { | 151 const GURL& embedding_origin) { |
| 145 HostContentSettingsMapFactory::GetForProfile(profile_) | 152 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 146 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, | 153 ->SetContentSettingDefaultScope(requesting_origin, embedding_origin, |
| 147 content_settings_type_, std::string(), | 154 content_settings_type_, std::string(), |
| 148 CONTENT_SETTING_DEFAULT); | 155 CONTENT_SETTING_DEFAULT); |
| 149 } | 156 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 content_setting); | 308 content_setting); |
| 302 } | 309 } |
| 303 | 310 |
| 304 bool PermissionContextBase::IsPermissionKillSwitchOn() const { | 311 bool PermissionContextBase::IsPermissionKillSwitchOn() const { |
| 305 const std::string param = variations::GetVariationParamValue( | 312 const std::string param = variations::GetVariationParamValue( |
| 306 kPermissionsKillSwitchFieldStudy, | 313 kPermissionsKillSwitchFieldStudy, |
| 307 PermissionUtil::GetPermissionString(permission_type_)); | 314 PermissionUtil::GetPermissionString(permission_type_)); |
| 308 | 315 |
| 309 return param == kPermissionsKillSwitchBlockedValue; | 316 return param == kPermissionsKillSwitchBlockedValue; |
| 310 } | 317 } |
| OLD | NEW |