| 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 "base/feature_list.h" | 7 #include "base/feature_list.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 10 #include "chrome/browser/permissions/permission_uma_util.h" | 10 #include "chrome/browser/permissions/permission_uma_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 case content::PermissionType::AUDIO_CAPTURE: | 40 case content::PermissionType::AUDIO_CAPTURE: |
| 41 return "AudioCapture"; | 41 return "AudioCapture"; |
| 42 case content::PermissionType::VIDEO_CAPTURE: | 42 case content::PermissionType::VIDEO_CAPTURE: |
| 43 return "VideoCapture"; | 43 return "VideoCapture"; |
| 44 case content::PermissionType::MIDI: | 44 case content::PermissionType::MIDI: |
| 45 return "Midi"; | 45 return "Midi"; |
| 46 case content::PermissionType::BACKGROUND_SYNC: | 46 case content::PermissionType::BACKGROUND_SYNC: |
| 47 return "BackgroundSync"; | 47 return "BackgroundSync"; |
| 48 case content::PermissionType::FLASH: | 48 case content::PermissionType::FLASH: |
| 49 return "Flash"; | 49 return "Flash"; |
| 50 case content::PermissionType::SENSORS: |
| 51 return "Sensors"; |
| 50 case content::PermissionType::NUM: | 52 case content::PermissionType::NUM: |
| 51 break; | 53 break; |
| 52 } | 54 } |
| 53 NOTREACHED(); | 55 NOTREACHED(); |
| 54 return std::string(); | 56 return std::string(); |
| 55 } | 57 } |
| 56 | 58 |
| 57 bool PermissionUtil::GetPermissionType(ContentSettingsType type, | 59 bool PermissionUtil::GetPermissionType(ContentSettingsType type, |
| 58 PermissionType* out) { | 60 PermissionType* out) { |
| 59 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { | 61 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { |
| 60 *out = PermissionType::GEOLOCATION; | 62 *out = PermissionType::GEOLOCATION; |
| 61 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { | 63 } else if (type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) { |
| 62 *out = PermissionType::NOTIFICATIONS; | 64 *out = PermissionType::NOTIFICATIONS; |
| 63 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { | 65 } else if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) { |
| 64 *out = PermissionType::MIDI_SYSEX; | 66 *out = PermissionType::MIDI_SYSEX; |
| 65 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) { | 67 } else if (type == CONTENT_SETTINGS_TYPE_DURABLE_STORAGE) { |
| 66 *out = PermissionType::DURABLE_STORAGE; | 68 *out = PermissionType::DURABLE_STORAGE; |
| 67 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { | 69 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) { |
| 68 *out = PermissionType::VIDEO_CAPTURE; | 70 *out = PermissionType::VIDEO_CAPTURE; |
| 69 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { | 71 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { |
| 70 *out = PermissionType::AUDIO_CAPTURE; | 72 *out = PermissionType::AUDIO_CAPTURE; |
| 73 } else if (type == CONTENT_SETTINGS_TYPE_SENSORS) { |
| 74 *out = PermissionType::SENSORS; |
| 71 } else if (type == CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC) { | 75 } else if (type == CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC) { |
| 72 *out = PermissionType::BACKGROUND_SYNC; | 76 *out = PermissionType::BACKGROUND_SYNC; |
| 73 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 77 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 74 } else if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { | 78 } else if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { |
| 75 *out = PermissionType::PROTECTED_MEDIA_IDENTIFIER; | 79 *out = PermissionType::PROTECTED_MEDIA_IDENTIFIER; |
| 76 #endif | 80 #endif |
| 77 } else { | 81 } else { |
| 78 return false; | 82 return false; |
| 79 } | 83 } |
| 80 return true; | 84 return true; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 ContentSetting final_content_setting = settings_map->GetContentSetting( | 135 ContentSetting final_content_setting = settings_map->GetContentSetting( |
| 132 primary_url_, secondary_url_, content_type_, std::string()); | 136 primary_url_, secondary_url_, content_type_, std::string()); |
| 133 if (final_content_setting != CONTENT_SETTING_ALLOW) { | 137 if (final_content_setting != CONTENT_SETTING_ALLOW) { |
| 134 PermissionType permission_type; | 138 PermissionType permission_type; |
| 135 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { | 139 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { |
| 136 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, | 140 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, |
| 137 primary_url_, profile_); | 141 primary_url_, profile_); |
| 138 } | 142 } |
| 139 } | 143 } |
| 140 } | 144 } |
| OLD | NEW |