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 | 34 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; | 100 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; |
100 case PermissionType::MIDI: | 101 case PermissionType::MIDI: |
101 // This will hit the NOTREACHED below. | 102 // This will hit the NOTREACHED below. |
102 break; | 103 break; |
103 case PermissionType::AUDIO_CAPTURE: | 104 case PermissionType::AUDIO_CAPTURE: |
104 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | 105 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; |
105 case PermissionType::VIDEO_CAPTURE: | 106 case PermissionType::VIDEO_CAPTURE: |
106 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 107 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
107 case PermissionType::BACKGROUND_SYNC: | 108 case PermissionType::BACKGROUND_SYNC: |
108 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; | 109 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; |
| 110 case PermissionType::SENSORS: |
| 111 return CONTENT_SETTINGS_TYPE_SENSORS; |
109 case PermissionType::FLASH: | 112 case PermissionType::FLASH: |
110 return CONTENT_SETTINGS_TYPE_PLUGINS; | 113 return CONTENT_SETTINGS_TYPE_PLUGINS; |
111 case PermissionType::NUM: | 114 case PermissionType::NUM: |
112 // This will hit the NOTREACHED below. | 115 // This will hit the NOTREACHED below. |
113 break; | 116 break; |
114 } | 117 } |
115 | 118 |
116 NOTREACHED() << "Unknown content setting for permission " | 119 NOTREACHED() << "Unknown content setting for permission " |
117 << static_cast<int>(permission); | 120 << static_cast<int>(permission); |
118 return CONTENT_SETTINGS_TYPE_DEFAULT; | 121 return CONTENT_SETTINGS_TYPE_DEFAULT; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 permission_contexts_[PermissionType::AUDIO_CAPTURE] = | 253 permission_contexts_[PermissionType::AUDIO_CAPTURE] = |
251 base::MakeUnique<MediaStreamDevicePermissionContext>( | 254 base::MakeUnique<MediaStreamDevicePermissionContext>( |
252 profile, content::PermissionType::AUDIO_CAPTURE, | 255 profile, content::PermissionType::AUDIO_CAPTURE, |
253 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 256 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
254 permission_contexts_[PermissionType::VIDEO_CAPTURE] = | 257 permission_contexts_[PermissionType::VIDEO_CAPTURE] = |
255 base::MakeUnique<MediaStreamDevicePermissionContext>( | 258 base::MakeUnique<MediaStreamDevicePermissionContext>( |
256 profile, content::PermissionType::VIDEO_CAPTURE, | 259 profile, content::PermissionType::VIDEO_CAPTURE, |
257 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 260 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
258 permission_contexts_[PermissionType::BACKGROUND_SYNC] = | 261 permission_contexts_[PermissionType::BACKGROUND_SYNC] = |
259 base::MakeUnique<BackgroundSyncPermissionContext>(profile); | 262 base::MakeUnique<BackgroundSyncPermissionContext>(profile); |
| 263 permission_contexts_[PermissionType::SENSORS] = |
| 264 base::MakeUnique<SensorPermissionContext>(profile); |
260 #if defined(ENABLE_PLUGINS) | 265 #if defined(ENABLE_PLUGINS) |
261 permission_contexts_[PermissionType::FLASH] = | 266 permission_contexts_[PermissionType::FLASH] = |
262 base::MakeUnique<FlashPermissionContext>(profile); | 267 base::MakeUnique<FlashPermissionContext>(profile); |
263 #endif | 268 #endif |
264 } | 269 } |
265 | 270 |
266 PermissionManager::~PermissionManager() { | 271 PermissionManager::~PermissionManager() { |
267 if (!subscriptions_.IsEmpty()) | 272 if (!subscriptions_.IsEmpty()) |
268 HostContentSettingsMapFactory::GetForProfile(profile_) | 273 HostContentSettingsMapFactory::GetForProfile(profile_) |
269 ->RemoveObserver(this); | 274 ->RemoveObserver(this); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 // Add the callback to |callbacks| which will be run after the loop to | 499 // Add the callback to |callbacks| which will be run after the loop to |
495 // prevent re-entrance issues. | 500 // prevent re-entrance issues. |
496 callbacks.push_back( | 501 callbacks.push_back( |
497 base::Bind(subscription->callback, | 502 base::Bind(subscription->callback, |
498 ContentSettingToPermissionStatus(new_value))); | 503 ContentSettingToPermissionStatus(new_value))); |
499 } | 504 } |
500 | 505 |
501 for (const auto& callback : callbacks) | 506 for (const auto& callback : callbacks) |
502 callback.Run(); | 507 callback.Run(); |
503 } | 508 } |
OLD | NEW |