Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: chrome/browser/permissions/permission_util.cc

Issue 2791623004: [sensors][permission] Add new permission types in permission module. (Closed)
Patch Set: Rebase + add blank line in ONWERS file. Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25 matching lines...) Expand all
36 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: 36 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
37 return "AudioCapture"; 37 return "AudioCapture";
38 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: 38 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
39 return "VideoCapture"; 39 return "VideoCapture";
40 case CONTENT_SETTINGS_TYPE_MIDI: 40 case CONTENT_SETTINGS_TYPE_MIDI:
41 return "Midi"; 41 return "Midi";
42 case CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC: 42 case CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC:
43 return "BackgroundSync"; 43 return "BackgroundSync";
44 case CONTENT_SETTINGS_TYPE_PLUGINS: 44 case CONTENT_SETTINGS_TYPE_PLUGINS:
45 return "Flash"; 45 return "Flash";
46 case CONTENT_SETTINGS_TYPE_SENSORS:
47 return "Sensors";
46 default: 48 default:
47 break; 49 break;
48 } 50 }
49 NOTREACHED(); 51 NOTREACHED();
50 return std::string(); 52 return std::string();
51 } 53 }
52 54
53 std::string PermissionUtil::ConvertContentSettingsTypeToSafeBrowsingName( 55 std::string PermissionUtil::ConvertContentSettingsTypeToSafeBrowsingName(
54 ContentSettingsType permission_type) { 56 ContentSettingsType permission_type) {
55 switch (permission_type) { 57 switch (permission_type) {
(...skipping 10 matching lines...) Expand all
66 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: 68 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
67 return "PROTECTED_MEDIA_IDENTIFIER"; 69 return "PROTECTED_MEDIA_IDENTIFIER";
68 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: 70 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
69 return "AUDIO_CAPTURE"; 71 return "AUDIO_CAPTURE";
70 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: 72 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
71 return "VIDEO_CAPTURE"; 73 return "VIDEO_CAPTURE";
72 case CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC: 74 case CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC:
73 return "BACKGROUND_SYNC"; 75 return "BACKGROUND_SYNC";
74 case CONTENT_SETTINGS_TYPE_PLUGINS: 76 case CONTENT_SETTINGS_TYPE_PLUGINS:
75 return "FLASH"; 77 return "FLASH";
78 case CONTENT_SETTINGS_TYPE_SENSORS:
79 return "SENSORS";
76 default: 80 default:
77 break; 81 break;
78 } 82 }
79 NOTREACHED(); 83 NOTREACHED();
80 return std::string(); 84 return std::string();
81 } 85 }
82 86
83 PermissionRequestType PermissionUtil::GetRequestType(ContentSettingsType type) { 87 PermissionRequestType PermissionUtil::GetRequestType(ContentSettingsType type) {
84 switch (type) { 88 switch (type) {
85 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 89 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) { 132 } else if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
129 *out = PermissionType::AUDIO_CAPTURE; 133 *out = PermissionType::AUDIO_CAPTURE;
130 } else if (type == CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC) { 134 } else if (type == CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC) {
131 *out = PermissionType::BACKGROUND_SYNC; 135 *out = PermissionType::BACKGROUND_SYNC;
132 } else if (type == CONTENT_SETTINGS_TYPE_PLUGINS) { 136 } else if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
133 *out = PermissionType::FLASH; 137 *out = PermissionType::FLASH;
134 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 138 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
135 } else if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) { 139 } else if (type == CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER) {
136 *out = PermissionType::PROTECTED_MEDIA_IDENTIFIER; 140 *out = PermissionType::PROTECTED_MEDIA_IDENTIFIER;
137 #endif 141 #endif
142 } else if (type == CONTENT_SETTINGS_TYPE_SENSORS) {
143 *out = PermissionType::SENSORS;
138 } else { 144 } else {
139 return false; 145 return false;
140 } 146 }
141 return true; 147 return true;
142 } 148 }
143 149
144 ContentSettingsType PermissionUtil::GetContentSettingsStorageType( 150 ContentSettingsType PermissionUtil::GetContentSettingsStorageType(
145 ContentSettingsType type) { 151 ContentSettingsType type) {
146 if (type == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING) 152 if (type == CONTENT_SETTINGS_TYPE_PUSH_MESSAGING)
147 return CONTENT_SETTINGS_TYPE_NOTIFICATIONS; 153 return CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
148 return type; 154 return type;
149 } 155 }
150 156
151 bool PermissionUtil::IsPermission(ContentSettingsType type) { 157 bool PermissionUtil::IsPermission(ContentSettingsType type) {
152 switch (type) { 158 switch (type) {
153 case CONTENT_SETTINGS_TYPE_GEOLOCATION: 159 case CONTENT_SETTINGS_TYPE_GEOLOCATION:
154 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS: 160 case CONTENT_SETTINGS_TYPE_NOTIFICATIONS:
155 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING: 161 case CONTENT_SETTINGS_TYPE_PUSH_MESSAGING:
156 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX: 162 case CONTENT_SETTINGS_TYPE_MIDI_SYSEX:
157 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE: 163 case CONTENT_SETTINGS_TYPE_DURABLE_STORAGE:
158 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA: 164 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA:
159 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC: 165 case CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC:
160 case CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC: 166 case CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC:
161 case CONTENT_SETTINGS_TYPE_PLUGINS: 167 case CONTENT_SETTINGS_TYPE_PLUGINS:
162 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 168 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
163 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER: 169 case CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER:
164 #endif 170 #endif
171 case CONTENT_SETTINGS_TYPE_SENSORS:
165 return true; 172 return true;
166 default: 173 default:
167 return false; 174 return false;
168 } 175 }
169 } 176 }
170 177
171 bool PermissionUtil::ShouldShowPersistenceToggle(ContentSettingsType type) { 178 bool PermissionUtil::ShouldShowPersistenceToggle(ContentSettingsType type) {
172 return (type == CONTENT_SETTINGS_TYPE_GEOLOCATION || 179 return (type == CONTENT_SETTINGS_TYPE_GEOLOCATION ||
173 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC || 180 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC ||
174 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) && 181 type == CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) &&
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 return; 226 return;
220 HostContentSettingsMap* settings_map = 227 HostContentSettingsMap* settings_map =
221 HostContentSettingsMapFactory::GetForProfile(profile_); 228 HostContentSettingsMapFactory::GetForProfile(profile_);
222 ContentSetting final_content_setting = settings_map->GetContentSetting( 229 ContentSetting final_content_setting = settings_map->GetContentSetting(
223 primary_url_, secondary_url_, content_type_, std::string()); 230 primary_url_, secondary_url_, content_type_, std::string());
224 if (final_content_setting != CONTENT_SETTING_ALLOW) { 231 if (final_content_setting != CONTENT_SETTING_ALLOW) {
225 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_, 232 PermissionUmaUtil::PermissionRevoked(content_type_, source_ui_,
226 primary_url_, profile_); 233 primary_url_, profile_);
227 } 234 }
228 } 235 }
OLDNEW
« no previous file with comments | « chrome/browser/permissions/permission_manager.cc ('k') | components/content_settings/core/common/content_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698