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_manager.h" | 5 #include "chrome/browser/permissions/permission_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "chrome/browser/background_sync/background_sync_permission_context.h" | 14 #include "chrome/browser/background_sync/background_sync_permission_context.h" |
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
16 #include "chrome/browser/media/midi_permission_context.h" | 16 #include "chrome/browser/media/midi_permission_context.h" |
17 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h" | 17 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h" |
18 #include "chrome/browser/notifications/notification_permission_context.h" | 18 #include "chrome/browser/notifications/notification_permission_context.h" |
19 #include "chrome/browser/permissions/permission_context_base.h" | 19 #include "chrome/browser/permissions/permission_context_base.h" |
20 #include "chrome/browser/permissions/permission_manager_factory.h" | 20 #include "chrome/browser/permissions/permission_manager_factory.h" |
21 #include "chrome/browser/permissions/permission_request_id.h" | 21 #include "chrome/browser/permissions/permission_request_id.h" |
22 #include "chrome/browser/permissions/permission_uma_util.h" | 22 #include "chrome/browser/permissions/permission_uma_util.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/sensor/sensor_permission_context.h" |
24 #include "chrome/browser/storage/durable_storage_permission_context.h" | 25 #include "chrome/browser/storage/durable_storage_permission_context.h" |
25 #include "chrome/browser/tab_contents/tab_util.h" | 26 #include "chrome/browser/tab_contents/tab_util.h" |
26 #include "chrome/common/features.h" | 27 #include "chrome/common/features.h" |
27 #include "components/content_settings/core/browser/host_content_settings_map.h" | 28 #include "components/content_settings/core/browser/host_content_settings_map.h" |
28 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/permission_type.h" | 30 #include "content/public/browser/permission_type.h" |
30 #include "content/public/browser/render_frame_host.h" | 31 #include "content/public/browser/render_frame_host.h" |
31 #include "content/public/browser/render_process_host.h" | 32 #include "content/public/browser/render_process_host.h" |
32 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
33 #include "ppapi/features/features.h" | 34 #include "ppapi/features/features.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; | 101 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; |
101 case PermissionType::MIDI: | 102 case PermissionType::MIDI: |
102 // This will hit the NOTREACHED below. | 103 // This will hit the NOTREACHED below. |
103 break; | 104 break; |
104 case PermissionType::AUDIO_CAPTURE: | 105 case PermissionType::AUDIO_CAPTURE: |
105 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | 106 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; |
106 case PermissionType::VIDEO_CAPTURE: | 107 case PermissionType::VIDEO_CAPTURE: |
107 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 108 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
108 case PermissionType::BACKGROUND_SYNC: | 109 case PermissionType::BACKGROUND_SYNC: |
109 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; | 110 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; |
| 111 case PermissionType::SENSORS: |
| 112 return CONTENT_SETTINGS_TYPE_SENSORS; |
110 case PermissionType::FLASH: | 113 case PermissionType::FLASH: |
111 return CONTENT_SETTINGS_TYPE_PLUGINS; | 114 return CONTENT_SETTINGS_TYPE_PLUGINS; |
112 case PermissionType::NUM: | 115 case PermissionType::NUM: |
113 // This will hit the NOTREACHED below. | 116 // This will hit the NOTREACHED below. |
114 break; | 117 break; |
115 } | 118 } |
116 | 119 |
117 NOTREACHED() << "Unknown content setting for permission " | 120 NOTREACHED() << "Unknown content setting for permission " |
118 << static_cast<int>(permission); | 121 << static_cast<int>(permission); |
119 return CONTENT_SETTINGS_TYPE_DEFAULT; | 122 return CONTENT_SETTINGS_TYPE_DEFAULT; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 permission_contexts_[PermissionType::AUDIO_CAPTURE] = | 254 permission_contexts_[PermissionType::AUDIO_CAPTURE] = |
252 base::MakeUnique<MediaStreamDevicePermissionContext>( | 255 base::MakeUnique<MediaStreamDevicePermissionContext>( |
253 profile, content::PermissionType::AUDIO_CAPTURE, | 256 profile, content::PermissionType::AUDIO_CAPTURE, |
254 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 257 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
255 permission_contexts_[PermissionType::VIDEO_CAPTURE] = | 258 permission_contexts_[PermissionType::VIDEO_CAPTURE] = |
256 base::MakeUnique<MediaStreamDevicePermissionContext>( | 259 base::MakeUnique<MediaStreamDevicePermissionContext>( |
257 profile, content::PermissionType::VIDEO_CAPTURE, | 260 profile, content::PermissionType::VIDEO_CAPTURE, |
258 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 261 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
259 permission_contexts_[PermissionType::BACKGROUND_SYNC] = | 262 permission_contexts_[PermissionType::BACKGROUND_SYNC] = |
260 base::MakeUnique<BackgroundSyncPermissionContext>(profile); | 263 base::MakeUnique<BackgroundSyncPermissionContext>(profile); |
261 #if BUILDFLAG(ENABLE_PLUGINS) | 264 permission_contexts_[PermissionType::SENSORS] = |
| 265 base::MakeUnique<SensorPermissionContext>(profile); |
| 266 #if defined(ENABLE_PLUGINS) |
262 permission_contexts_[PermissionType::FLASH] = | 267 permission_contexts_[PermissionType::FLASH] = |
263 base::MakeUnique<FlashPermissionContext>(profile); | 268 base::MakeUnique<FlashPermissionContext>(profile); |
264 #endif | 269 #endif |
265 } | 270 } |
266 | 271 |
267 PermissionManager::~PermissionManager() { | 272 PermissionManager::~PermissionManager() { |
268 if (!subscriptions_.IsEmpty()) | 273 if (!subscriptions_.IsEmpty()) |
269 HostContentSettingsMapFactory::GetForProfile(profile_) | 274 HostContentSettingsMapFactory::GetForProfile(profile_) |
270 ->RemoveObserver(this); | 275 ->RemoveObserver(this); |
271 } | 276 } |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 // Add the callback to |callbacks| which will be run after the loop to | 500 // Add the callback to |callbacks| which will be run after the loop to |
496 // prevent re-entrance issues. | 501 // prevent re-entrance issues. |
497 callbacks.push_back( | 502 callbacks.push_back( |
498 base::Bind(subscription->callback, | 503 base::Bind(subscription->callback, |
499 ContentSettingToPermissionStatus(new_value))); | 504 ContentSettingToPermissionStatus(new_value))); |
500 } | 505 } |
501 | 506 |
502 for (const auto& callback : callbacks) | 507 for (const auto& callback : callbacks) |
503 callback.Run(); | 508 callback.Run(); |
504 } | 509 } |
OLD | NEW |