| 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 "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 // static | 212 // static |
| 213 PermissionManager* PermissionManager::Get(Profile* profile) { | 213 PermissionManager* PermissionManager::Get(Profile* profile) { |
| 214 return PermissionManagerFactory::GetForProfile(profile); | 214 return PermissionManagerFactory::GetForProfile(profile); |
| 215 } | 215 } |
| 216 | 216 |
| 217 PermissionManager::PermissionManager(Profile* profile) | 217 PermissionManager::PermissionManager(Profile* profile) |
| 218 : profile_(profile), | 218 : profile_(profile), |
| 219 weak_ptr_factory_(this) { | 219 weak_ptr_factory_(this) { |
| 220 permission_contexts_[PermissionType::MIDI_SYSEX] = | 220 permission_contexts_[PermissionType::MIDI_SYSEX] = |
| 221 base::WrapUnique(new MidiPermissionContext(profile)); | 221 base::MakeUnique<MidiPermissionContext>(profile); |
| 222 permission_contexts_[PermissionType::PUSH_MESSAGING] = | 222 permission_contexts_[PermissionType::PUSH_MESSAGING] = |
| 223 base::WrapUnique(new NotificationPermissionContext( | 223 base::MakeUnique<NotificationPermissionContext>( |
| 224 profile, PermissionType::PUSH_MESSAGING)); | 224 profile, PermissionType::PUSH_MESSAGING); |
| 225 permission_contexts_[PermissionType::NOTIFICATIONS] = | 225 permission_contexts_[PermissionType::NOTIFICATIONS] = |
| 226 base::WrapUnique(new NotificationPermissionContext( | 226 base::MakeUnique<NotificationPermissionContext>( |
| 227 profile, PermissionType::NOTIFICATIONS)); | 227 profile, PermissionType::NOTIFICATIONS); |
| 228 #if !BUILDFLAG(ANDROID_JAVA_UI) | 228 #if !BUILDFLAG(ANDROID_JAVA_UI) |
| 229 permission_contexts_[PermissionType::GEOLOCATION] = | 229 permission_contexts_[PermissionType::GEOLOCATION] = |
| 230 base::WrapUnique(new GeolocationPermissionContext(profile)); | 230 base::MakeUnique<GeolocationPermissionContext>(profile); |
| 231 #else | 231 #else |
| 232 permission_contexts_[PermissionType::GEOLOCATION] = | 232 permission_contexts_[PermissionType::GEOLOCATION] = |
| 233 base::WrapUnique(new GeolocationPermissionContextAndroid(profile)); | 233 base::MakeUnique<GeolocationPermissionContextAndroid>(profile); |
| 234 #endif | 234 #endif |
| 235 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 235 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
| 236 permission_contexts_[PermissionType::PROTECTED_MEDIA_IDENTIFIER] = | 236 permission_contexts_[PermissionType::PROTECTED_MEDIA_IDENTIFIER] = |
| 237 base::WrapUnique(new ProtectedMediaIdentifierPermissionContext(profile)); | 237 base::MakeUnique<ProtectedMediaIdentifierPermissionContext>(profile); |
| 238 #endif | 238 #endif |
| 239 permission_contexts_[PermissionType::DURABLE_STORAGE] = | 239 permission_contexts_[PermissionType::DURABLE_STORAGE] = |
| 240 base::WrapUnique(new DurableStoragePermissionContext(profile)); | 240 base::MakeUnique<DurableStoragePermissionContext>(profile); |
| 241 permission_contexts_[PermissionType::AUDIO_CAPTURE] = | 241 permission_contexts_[PermissionType::AUDIO_CAPTURE] = |
| 242 base::WrapUnique(new MediaStreamDevicePermissionContext( | 242 base::MakeUnique<MediaStreamDevicePermissionContext>( |
| 243 profile, content::PermissionType::AUDIO_CAPTURE, | 243 profile, content::PermissionType::AUDIO_CAPTURE, |
| 244 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)); | 244 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
| 245 permission_contexts_[PermissionType::VIDEO_CAPTURE] = | 245 permission_contexts_[PermissionType::VIDEO_CAPTURE] = |
| 246 base::WrapUnique(new MediaStreamDevicePermissionContext( | 246 base::MakeUnique<MediaStreamDevicePermissionContext>( |
| 247 profile, content::PermissionType::VIDEO_CAPTURE, | 247 profile, content::PermissionType::VIDEO_CAPTURE, |
| 248 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)); | 248 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
| 249 permission_contexts_[PermissionType::BACKGROUND_SYNC] = | 249 permission_contexts_[PermissionType::BACKGROUND_SYNC] = |
| 250 base::WrapUnique(new BackgroundSyncPermissionContext(profile)); | 250 base::MakeUnique<BackgroundSyncPermissionContext>(profile); |
| 251 } | 251 } |
| 252 | 252 |
| 253 PermissionManager::~PermissionManager() { | 253 PermissionManager::~PermissionManager() { |
| 254 if (!subscriptions_.IsEmpty()) | 254 if (!subscriptions_.IsEmpty()) |
| 255 HostContentSettingsMapFactory::GetForProfile(profile_) | 255 HostContentSettingsMapFactory::GetForProfile(profile_) |
| 256 ->RemoveObserver(this); | 256 ->RemoveObserver(this); |
| 257 } | 257 } |
| 258 | 258 |
| 259 int PermissionManager::RequestPermission( | 259 int PermissionManager::RequestPermission( |
| 260 PermissionType permission, | 260 PermissionType permission, |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 // Add the callback to |callbacks| which will be run after the loop to | 473 // Add the callback to |callbacks| which will be run after the loop to |
| 474 // prevent re-entrance issues. | 474 // prevent re-entrance issues. |
| 475 callbacks.push_back( | 475 callbacks.push_back( |
| 476 base::Bind(subscription->callback, | 476 base::Bind(subscription->callback, |
| 477 ContentSettingToPermissionStatus(new_value))); | 477 ContentSettingToPermissionStatus(new_value))); |
| 478 } | 478 } |
| 479 | 479 |
| 480 for (const auto& callback : callbacks) | 480 for (const auto& callback : callbacks) |
| 481 callback.Run(); | 481 callback.Run(); |
| 482 } | 482 } |
| OLD | NEW |