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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "chrome/browser/background_sync/background_sync_permission_context.h" | 13 #include "chrome/browser/background_sync/background_sync_permission_context.h" |
14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 14 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
15 #include "chrome/browser/media/midi_permission_context.h" | 15 #include "chrome/browser/media/midi_permission_context.h" |
16 #include "chrome/browser/media/midi_sysex_permission_context.h" | 16 #include "chrome/browser/media/midi_sysex_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/payments/payment_handler_permission_context.h" |
19 #include "chrome/browser/permissions/permission_context_base.h" | 20 #include "chrome/browser/permissions/permission_context_base.h" |
20 #include "chrome/browser/permissions/permission_manager_factory.h" | 21 #include "chrome/browser/permissions/permission_manager_factory.h" |
21 #include "chrome/browser/permissions/permission_request_id.h" | 22 #include "chrome/browser/permissions/permission_request_id.h" |
22 #include "chrome/browser/permissions/permission_result.h" | 23 #include "chrome/browser/permissions/permission_result.h" |
23 #include "chrome/browser/permissions/permission_uma_util.h" | 24 #include "chrome/browser/permissions/permission_uma_util.h" |
24 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/storage/durable_storage_permission_context.h" | 26 #include "chrome/browser/storage/durable_storage_permission_context.h" |
26 #include "chrome/browser/tab_contents/tab_util.h" | 27 #include "chrome/browser/tab_contents/tab_util.h" |
27 #include "chrome/common/features.h" | 28 #include "chrome/common/features.h" |
28 #include "components/content_settings/core/browser/host_content_settings_map.h" | 29 #include "components/content_settings/core/browser/host_content_settings_map.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 case PermissionType::DURABLE_STORAGE: | 101 case PermissionType::DURABLE_STORAGE: |
101 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; | 102 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; |
102 case PermissionType::AUDIO_CAPTURE: | 103 case PermissionType::AUDIO_CAPTURE: |
103 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | 104 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; |
104 case PermissionType::VIDEO_CAPTURE: | 105 case PermissionType::VIDEO_CAPTURE: |
105 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 106 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; |
106 case PermissionType::BACKGROUND_SYNC: | 107 case PermissionType::BACKGROUND_SYNC: |
107 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; | 108 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; |
108 case PermissionType::FLASH: | 109 case PermissionType::FLASH: |
109 return CONTENT_SETTINGS_TYPE_PLUGINS; | 110 return CONTENT_SETTINGS_TYPE_PLUGINS; |
| 111 case PermissionType::PAYMENT_HANDLER: |
| 112 return CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER; |
110 case PermissionType::NUM: | 113 case PermissionType::NUM: |
111 // This will hit the NOTREACHED below. | 114 // This will hit the NOTREACHED below. |
112 break; | 115 break; |
113 } | 116 } |
114 | 117 |
115 NOTREACHED() << "Unknown content setting for permission " | 118 NOTREACHED() << "Unknown content setting for permission " |
116 << static_cast<int>(permission); | 119 << static_cast<int>(permission); |
117 return CONTENT_SETTINGS_TYPE_DEFAULT; | 120 return CONTENT_SETTINGS_TYPE_DEFAULT; |
118 } | 121 } |
119 | 122 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 permission_contexts_[CONTENT_SETTINGS_TYPE_DURABLE_STORAGE] = | 239 permission_contexts_[CONTENT_SETTINGS_TYPE_DURABLE_STORAGE] = |
237 base::MakeUnique<DurableStoragePermissionContext>(profile); | 240 base::MakeUnique<DurableStoragePermissionContext>(profile); |
238 permission_contexts_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = | 241 permission_contexts_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC] = |
239 base::MakeUnique<MediaStreamDevicePermissionContext>( | 242 base::MakeUnique<MediaStreamDevicePermissionContext>( |
240 profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 243 profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
241 permission_contexts_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = | 244 permission_contexts_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = |
242 base::MakeUnique<MediaStreamDevicePermissionContext>( | 245 base::MakeUnique<MediaStreamDevicePermissionContext>( |
243 profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 246 profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
244 permission_contexts_[CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC] = | 247 permission_contexts_[CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC] = |
245 base::MakeUnique<BackgroundSyncPermissionContext>(profile); | 248 base::MakeUnique<BackgroundSyncPermissionContext>(profile); |
| 249 permission_contexts_[CONTENT_SETTINGS_TYPE_PAYMENT_HANDLER] = |
| 250 base::MakeUnique<PaymentHandlerPermissionContext>(profile); |
246 #if BUILDFLAG(ENABLE_PLUGINS) | 251 #if BUILDFLAG(ENABLE_PLUGINS) |
247 permission_contexts_[CONTENT_SETTINGS_TYPE_PLUGINS] = | 252 permission_contexts_[CONTENT_SETTINGS_TYPE_PLUGINS] = |
248 base::MakeUnique<FlashPermissionContext>(profile); | 253 base::MakeUnique<FlashPermissionContext>(profile); |
249 #endif | 254 #endif |
250 } | 255 } |
251 | 256 |
252 PermissionManager::~PermissionManager() { | 257 PermissionManager::~PermissionManager() { |
253 DCHECK(subscriptions_.IsEmpty()); | 258 DCHECK(subscriptions_.IsEmpty()); |
254 } | 259 } |
255 | 260 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 const GURL& embedding_origin) { | 541 const GURL& embedding_origin) { |
537 PermissionContextBase* context = GetPermissionContext(permission); | 542 PermissionContextBase* context = GetPermissionContext(permission); |
538 PermissionResult result = context->GetPermissionStatus( | 543 PermissionResult result = context->GetPermissionStatus( |
539 render_frame_host, requesting_origin.GetOrigin(), | 544 render_frame_host, requesting_origin.GetOrigin(), |
540 embedding_origin.GetOrigin()); | 545 embedding_origin.GetOrigin()); |
541 DCHECK(result.content_setting == CONTENT_SETTING_ALLOW || | 546 DCHECK(result.content_setting == CONTENT_SETTING_ALLOW || |
542 result.content_setting == CONTENT_SETTING_ASK || | 547 result.content_setting == CONTENT_SETTING_ASK || |
543 result.content_setting == CONTENT_SETTING_BLOCK); | 548 result.content_setting == CONTENT_SETTING_BLOCK); |
544 return result; | 549 return result; |
545 } | 550 } |
OLD | NEW |