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" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 return "BackgroundSync"; | 48 return "BackgroundSync"; |
49 case content::PermissionType::FLASH: | 49 case content::PermissionType::FLASH: |
50 return "Flash"; | 50 return "Flash"; |
51 case content::PermissionType::NUM: | 51 case content::PermissionType::NUM: |
52 break; | 52 break; |
53 } | 53 } |
54 NOTREACHED(); | 54 NOTREACHED(); |
55 return std::string(); | 55 return std::string(); |
56 } | 56 } |
57 | 57 |
58 std::string PermissionUtil::ConvertPermissionTypeToSafeBrowsingName( | |
59 const content::PermissionType& permission_type) { | |
60 if (permission_type == content::PermissionType::GEOLOCATION) | |
raymes
2017/01/24 23:44:23
Please convert this to a switch statement as in Ge
meredithl
2017/01/25 00:21:10
Done.
| |
61 return "GEOLOCATION"; | |
62 if (permission_type == content::PermissionType::NOTIFICATIONS) | |
63 return "NOTIFICATIONS"; | |
64 if (permission_type == content::PermissionType::MIDI_SYSEX) | |
65 return "MIDI_SYSEX"; | |
66 if (permission_type == content::PermissionType::PUSH_MESSAGING) | |
67 return "PUSH_MESSAGING"; | |
68 if (permission_type == content::PermissionType::DURABLE_STORAGE) | |
69 return "DURABLE_STORAGE"; | |
70 if (permission_type == content::PermissionType::PROTECTED_MEDIA_IDENTIFIER) | |
71 return "PROTECTED_MEDIA_IDENTIFIER"; | |
72 if (permission_type == content::PermissionType::AUDIO_CAPTURE) | |
73 return "AUDIO_CAPTURE"; | |
74 if (permission_type == content::PermissionType::MIDI) | |
raymes
2017/01/24 23:44:23
MIDI->VIDEO_CAPTURE
meredithl
2017/01/25 00:21:10
Done.
| |
75 return "VIDEO_CAPTURE"; | |
76 if (permission_type == content::PermissionType::MIDI) | |
77 return "MIDI"; | |
78 if (permission_type == content::PermissionType::BACKGROUND_SYNC) | |
79 return "BACKGROUND_SYNC"; | |
80 if (permission_type == content::PermissionType::FLASH) | |
81 return "FLASH"; | |
82 NOTREACHED(); | |
83 return std::string(); | |
84 } | |
85 | |
58 PermissionRequestType PermissionUtil::GetRequestType( | 86 PermissionRequestType PermissionUtil::GetRequestType( |
59 content::PermissionType type) { | 87 content::PermissionType type) { |
60 switch (type) { | 88 switch (type) { |
61 case content::PermissionType::GEOLOCATION: | 89 case content::PermissionType::GEOLOCATION: |
62 return PermissionRequestType::PERMISSION_GEOLOCATION; | 90 return PermissionRequestType::PERMISSION_GEOLOCATION; |
63 case content::PermissionType::NOTIFICATIONS: | 91 case content::PermissionType::NOTIFICATIONS: |
64 return PermissionRequestType::PERMISSION_NOTIFICATIONS; | 92 return PermissionRequestType::PERMISSION_NOTIFICATIONS; |
65 case content::PermissionType::MIDI_SYSEX: | 93 case content::PermissionType::MIDI_SYSEX: |
66 return PermissionRequestType::PERMISSION_MIDI_SYSEX; | 94 return PermissionRequestType::PERMISSION_MIDI_SYSEX; |
67 case content::PermissionType::PUSH_MESSAGING: | 95 case content::PermissionType::PUSH_MESSAGING: |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 ContentSetting final_content_setting = settings_map->GetContentSetting( | 186 ContentSetting final_content_setting = settings_map->GetContentSetting( |
159 primary_url_, secondary_url_, content_type_, std::string()); | 187 primary_url_, secondary_url_, content_type_, std::string()); |
160 if (final_content_setting != CONTENT_SETTING_ALLOW) { | 188 if (final_content_setting != CONTENT_SETTING_ALLOW) { |
161 PermissionType permission_type; | 189 PermissionType permission_type; |
162 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { | 190 if (PermissionUtil::GetPermissionType(content_type_, &permission_type)) { |
163 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, | 191 PermissionUmaUtil::PermissionRevoked(permission_type, source_ui_, |
164 primary_url_, profile_); | 192 primary_url_, profile_); |
165 } | 193 } |
166 } | 194 } |
167 } | 195 } |
OLD | NEW |