| 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" | 7 #include "build/build_config.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.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_uma_util.h" | 11 #include "chrome/browser/permissions/permission_uma_util.h" |
| 12 #include "chrome/common/chrome_features.h" | 12 #include "chrome/common/chrome_features.h" |
| 13 #include "components/content_settings/core/browser/host_content_settings_map.h" | 13 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 14 #include "content/public/browser/permission_type.h" | 14 #include "content/public/browser/permission_type.h" |
| 15 | 15 |
| 16 using content::PermissionType; | 16 using content::PermissionType; |
| 17 | 17 |
| 18 std::string PermissionUtil::GetPermissionString( | |
| 19 ContentSettingsType content_type) { | |
| 20 PermissionType permission_type; | |
| 21 bool success = PermissionUtil::GetPermissionType( | |
| 22 content_type, &permission_type); | |
| 23 DCHECK(success); | |
| 24 return GetPermissionString(permission_type); | |
| 25 } | |
| 26 | |
| 27 // The returned strings must match the RAPPOR metrics in rappor.xml, | 18 // The returned strings must match the RAPPOR metrics in rappor.xml, |
| 28 // and any Field Trial configs for the Permissions kill switch e.g. | 19 // and any Field Trial configs for the Permissions kill switch e.g. |
| 29 // Permissions.Action.Geolocation etc.. | 20 // Permissions.Action.Geolocation etc.. |
| 30 std::string PermissionUtil::GetPermissionString(PermissionType permission) { | 21 std::string PermissionUtil::GetPermissionString( |
| 31 switch (permission) { | 22 ContentSettingsType content_type) { |
| 32 case PermissionType::GEOLOCATION: | 23 switch (content_type) { |
| 24 case CONTENT_SETTINGS_TYPE_GEOLOCATION: |
| 33 return "Geolocation"; | 25 return "Geolocation"; |
| 34 case PermissionType::NOTIFICATIONS: | 26 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: |
| 35 return "Notifications"; | 27 return "Notifications"; |
| 36 case PermissionType::MIDI_SYSEX: | 28 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: |
| 37 return "MidiSysEx"; | 29 return "MidiSysEx"; |
| 38 case PermissionType::PUSH_MESSAGING: | 30 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: |
| 39 return "PushMessaging"; | 31 return "PushMessaging"; |
| 40 case PermissionType::DURABLE_STORAGE: | 32 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: |
| 41 return "DurableStorage"; | 33 return "DurableStorage"; |
| 42 case PermissionType::PROTECTED_MEDIA_IDENTIFIER: | 34 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: |
| 43 return "ProtectedMediaIdentifier"; | 35 return "ProtectedMediaIdentifier"; |
| 44 case PermissionType::AUDIO_CAPTURE: | 36 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: |
| 45 return "AudioCapture"; | 37 return "AudioCapture"; |
| 46 case PermissionType::VIDEO_CAPTURE: | 38 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: |
| 47 return "VideoCapture"; | 39 return "VideoCapture"; |
| 48 case PermissionType::MIDI: | 40 case CONTENT_SETTINGS_TYPE_MIDI: |
| 49 return "Midi"; | 41 return "Midi"; |
| 50 case PermissionType::BACKGROUND_SYNC: | 42 case CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC: |
| 51 return "BackgroundSync"; | 43 return "BackgroundSync"; |
| 52 case PermissionType::FLASH: | 44 case CONTENT_SETTINGS_TYPE_PLUGINS: |
| 53 return "Flash"; | 45 return "Flash"; |
| 54 default: | 46 default: |
| 55 break; | 47 break; |
| 56 } | 48 } |
| 57 NOTREACHED(); | 49 NOTREACHED(); |
| 58 return std::string(); | 50 return std::string(); |
| 59 } | 51 } |
| 60 | 52 |
| 61 std::string PermissionUtil::ConvertContentSettingsTypeToSafeBrowsingName( | 53 std::string PermissionUtil::ConvertContentSettingsTypeToSafeBrowsingName( |
| 62 ContentSettingsType permission_type) { | 54 ContentSettingsType permission_type) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 ContentSetting final_content_setting = settings_map->GetContentSetting( | 186 ContentSetting final_content_setting = settings_map->GetContentSetting( |
| 195 primary_url_, secondary_url_, content_type_, std::string()); | 187 primary_url_, secondary_url_, content_type_, std::string()); |
| 196 if (final_content_setting != CONTENT_SETTING_ALLOW) { | 188 if (final_content_setting != CONTENT_SETTING_ALLOW) { |
| 197 PermissionType permission_type; | 189 PermissionType permission_type; |
| 198 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { | 190 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { |
| 199 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_, | 191 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_, |
| 200 primary_url_, profile_); | 192 primary_url_, profile_); |
| 201 } | 193 } |
| 202 } | 194 } |
| 203 } | 195 } |
| OLD | NEW |