| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_util.h" | 5 #include "chrome/browser/permissions/permission_util.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | |
| 8 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 11 #include "chrome/browser/permissions/permission_result.h" |
| 11 #include "chrome/browser/permissions/permission_uma_util.h" | 12 #include "chrome/browser/permissions/permission_uma_util.h" |
| 12 #include "chrome/common/chrome_features.h" | 13 #include "chrome/common/chrome_features.h" |
| 13 #include "components/content_settings/core/browser/host_content_settings_map.h" | 14 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 14 #include "content/public/browser/permission_type.h" | 15 #include "content/public/browser/permission_type.h" |
| 15 | 16 |
| 16 using content::PermissionType; | 17 using content::PermissionType; |
| 17 | 18 |
| 18 // The returned strings must match the RAPPOR metrics in rappor.xml, | 19 // The returned strings must match the RAPPOR metrics in rappor.xml, |
| 19 // and any Field Trial configs for the Permissions kill switch e.g. | 20 // and any Field Trial configs for the Permissions kill switch e.g. |
| 20 // Permissions.Action.Geolocation etc.. | 21 // Permissions.Action.Geolocation etc.. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 case CONTENT_SETTINGS_TYPE_PLUGINS: | 155 case CONTENT_SETTINGS_TYPE_PLUGINS: |
| 155 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 156 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 156 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: | 157 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
| 157 #endif | 158 #endif |
| 158 return true; | 159 return true; |
| 159 default: | 160 default: |
| 160 return false; | 161 return false; |
| 161 } | 162 } |
| 162 } | 163 } |
| 163 | 164 |
| 165 PermissionStatusSource |
| 166 PermissionUtil::ConvertSettingSourceToPermissionStatusSource( |
| 167 content_settings::SettingSource source) { |
| 168 switch (source) { |
| 169 case content_settings::SETTING_SOURCE_NONE: |
| 170 case content_settings::SETTING_SOURCE_WHITELIST: |
| 171 case content_settings::SETTING_SOURCE_SUPERVISED: |
| 172 case content_settings::SETTING_SOURCE_USER: |
| 173 break; |
| 174 |
| 175 case content_settings::SETTING_SOURCE_POLICY: |
| 176 return PermissionStatusSource::ENTERPRISE_POLICY; |
| 177 case content_settings::SETTING_SOURCE_EXTENSION: |
| 178 return PermissionStatusSource::EXTENSION; |
| 179 } |
| 180 return PermissionStatusSource::UNSPECIFIED; |
| 181 } |
| 182 |
| 164 bool PermissionUtil::ShouldShowPersistenceToggle(ContentSettingsType type) { | 183 bool PermissionUtil::ShouldShowPersistenceToggle(ContentSettingsType type) { |
| 165 return (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || | 184 return (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
| 166 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 185 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
| 167 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) && | 186 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) && |
| 168 base::FeatureList::IsEnabled( | 187 base::FeatureList::IsEnabled( |
| 169 features::kDisplayPersistenceToggleInPermissionPrompts); | 188 features::kDisplayPersistenceToggleInPermissionPrompts); |
| 170 } | 189 } |
| 171 | 190 |
| 172 PermissionUtil::ScopedRevocationReporter::ScopedRevocationReporter( | 191 PermissionUtil::ScopedRevocationReporter::ScopedRevocationReporter( |
| 173 Profile* profile, | 192 Profile* profile, |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 return; | 231 return; |
| 213 HostContentSettingsMap* settings_map = | 232 HostContentSettingsMap* settings_map = |
| 214 HostContentSettingsMapFactory::GetForProfile(profile_); | 233 HostContentSettingsMapFactory::GetForProfile(profile_); |
| 215 ContentSetting final_content_setting = settings_map->GetContentSetting( | 234 ContentSetting final_content_setting = settings_map->GetContentSetting( |
| 216 primary_url_, secondary_url_, content_type_, std::string()); | 235 primary_url_, secondary_url_, content_type_, std::string()); |
| 217 if (final_content_setting != CONTENT_SETTING_ALLOW) { | 236 if (final_content_setting != CONTENT_SETTING_ALLOW) { |
| 218 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_, | 237 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_, |
| 219 primary_url_, profile_); | 238 primary_url_, profile_); |
| 220 } | 239 } |
| 221 } | 240 } |
| OLD | NEW |