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 return PermissionStatusSource::UNSPECIFIED; |
| 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 } |
| 181 |
164 bool PermissionUtil::ShouldShowPersistenceToggle(ContentSettingsType type) { | 182 bool PermissionUtil::ShouldShowPersistenceToggle(ContentSettingsType type) { |
165 return (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || | 183 return (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || |
166 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || | 184 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || |
167 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) && | 185 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) && |
168 base::FeatureList::IsEnabled( | 186 base::FeatureList::IsEnabled( |
169 features::kDisplayPersistenceToggleInPermissionPrompts); | 187 features::kDisplayPersistenceToggleInPermissionPrompts); |
170 } | 188 } |
171 | 189 |
172 PermissionUtil::ScopedRevocationReporter::ScopedRevocationReporter( | 190 PermissionUtil::ScopedRevocationReporter::ScopedRevocationReporter( |
173 Profile* profile, | 191 Profile* profile, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 return; | 230 return; |
213 HostContentSettingsMap* settings_map = | 231 HostContentSettingsMap* settings_map = |
214 HostContentSettingsMapFactory::GetForProfile(profile_); | 232 HostContentSettingsMapFactory::GetForProfile(profile_); |
215 ContentSetting final_content_setting = settings_map->GetContentSetting( | 233 ContentSetting final_content_setting = settings_map->GetContentSetting( |
216 primary_url_, secondary_url_, content_type_, std::string()); | 234 primary_url_, secondary_url_, content_type_, std::string()); |
217 if (final_content_setting != CONTENT_SETTING_ALLOW) { | 235 if (final_content_setting != CONTENT_SETTING_ALLOW) { |
218 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_, | 236 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_, |
219 primary_url_, profile_); | 237 primary_url_, profile_); |
220 } | 238 } |
221 } | 239 } |
OLD | NEW |