| 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/generic_sensor/sensor_permission_context.h" | 
| 15 #include "chrome/browser/media/midi_permission_context.h" | 16 #include "chrome/browser/media/midi_permission_context.h" | 
| 16 #include "chrome/browser/media/midi_sysex_permission_context.h" | 17 #include "chrome/browser/media/midi_sysex_permission_context.h" | 
| 17 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h" | 18 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h" | 
| 18 #include "chrome/browser/notifications/notification_permission_context.h" | 19 #include "chrome/browser/notifications/notification_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" | 
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 97     case PermissionType::DURABLE_STORAGE: | 98     case PermissionType::DURABLE_STORAGE: | 
| 98       return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; | 99       return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; | 
| 99     case PermissionType::AUDIO_CAPTURE: | 100     case PermissionType::AUDIO_CAPTURE: | 
| 100       return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | 101       return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | 
| 101     case PermissionType::VIDEO_CAPTURE: | 102     case PermissionType::VIDEO_CAPTURE: | 
| 102       return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 103       return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | 
| 103     case PermissionType::BACKGROUND_SYNC: | 104     case PermissionType::BACKGROUND_SYNC: | 
| 104       return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; | 105       return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; | 
| 105     case PermissionType::FLASH: | 106     case PermissionType::FLASH: | 
| 106       return CONTENT_SETTINGS_TYPE_PLUGINS; | 107       return CONTENT_SETTINGS_TYPE_PLUGINS; | 
|  | 108     case PermissionType::SENSORS: | 
|  | 109       return CONTENT_SETTINGS_TYPE_SENSORS; | 
| 107     case PermissionType::NUM: | 110     case PermissionType::NUM: | 
| 108       // This will hit the NOTREACHED below. | 111       // This will hit the NOTREACHED below. | 
| 109       break; | 112       break; | 
| 110   } | 113   } | 
| 111 | 114 | 
| 112   NOTREACHED() << "Unknown content setting for permission " | 115   NOTREACHED() << "Unknown content setting for permission " | 
| 113                << static_cast<int>(permission); | 116                << static_cast<int>(permission); | 
| 114   return CONTENT_SETTINGS_TYPE_DEFAULT; | 117   return CONTENT_SETTINGS_TYPE_DEFAULT; | 
| 115 } | 118 } | 
| 116 | 119 | 
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 277           profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 280           profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 
| 278   permission_contexts_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = | 281   permission_contexts_[CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA] = | 
| 279       base::MakeUnique<MediaStreamDevicePermissionContext>( | 282       base::MakeUnique<MediaStreamDevicePermissionContext>( | 
| 280           profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 283           profile, CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 
| 281   permission_contexts_[CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC] = | 284   permission_contexts_[CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC] = | 
| 282       base::MakeUnique<BackgroundSyncPermissionContext>(profile); | 285       base::MakeUnique<BackgroundSyncPermissionContext>(profile); | 
| 283 #if BUILDFLAG(ENABLE_PLUGINS) | 286 #if BUILDFLAG(ENABLE_PLUGINS) | 
| 284   permission_contexts_[CONTENT_SETTINGS_TYPE_PLUGINS] = | 287   permission_contexts_[CONTENT_SETTINGS_TYPE_PLUGINS] = | 
| 285       base::MakeUnique<FlashPermissionContext>(profile); | 288       base::MakeUnique<FlashPermissionContext>(profile); | 
| 286 #endif | 289 #endif | 
|  | 290   permission_contexts_[CONTENT_SETTINGS_TYPE_SENSORS] = | 
|  | 291       base::MakeUnique<SensorPermissionContext>(profile); | 
| 287 } | 292 } | 
| 288 | 293 | 
| 289 PermissionManager::~PermissionManager() { | 294 PermissionManager::~PermissionManager() { | 
| 290   DCHECK(pending_requests_.IsEmpty()); | 295   DCHECK(pending_requests_.IsEmpty()); | 
| 291   DCHECK(subscriptions_.IsEmpty()); | 296   DCHECK(subscriptions_.IsEmpty()); | 
| 292 } | 297 } | 
| 293 | 298 | 
| 294 void PermissionManager::Shutdown() { | 299 void PermissionManager::Shutdown() { | 
| 295   if (!subscriptions_.IsEmpty()) { | 300   if (!subscriptions_.IsEmpty()) { | 
| 296     HostContentSettingsMapFactory::GetForProfile(profile_) | 301     HostContentSettingsMapFactory::GetForProfile(profile_) | 
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 576     const GURL& embedding_origin) { | 581     const GURL& embedding_origin) { | 
| 577   PermissionContextBase* context = GetPermissionContext(permission); | 582   PermissionContextBase* context = GetPermissionContext(permission); | 
| 578   PermissionResult result = context->GetPermissionStatus( | 583   PermissionResult result = context->GetPermissionStatus( | 
| 579       render_frame_host, requesting_origin.GetOrigin(), | 584       render_frame_host, requesting_origin.GetOrigin(), | 
| 580       embedding_origin.GetOrigin()); | 585       embedding_origin.GetOrigin()); | 
| 581   DCHECK(result.content_setting == CONTENT_SETTING_ALLOW || | 586   DCHECK(result.content_setting == CONTENT_SETTING_ALLOW || | 
| 582          result.content_setting == CONTENT_SETTING_ASK || | 587          result.content_setting == CONTENT_SETTING_ASK || | 
| 583          result.content_setting == CONTENT_SETTING_BLOCK); | 588          result.content_setting == CONTENT_SETTING_BLOCK); | 
| 584   return result; | 589   return result; | 
| 585 } | 590 } | 
| OLD | NEW | 
|---|