Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/permissions/permission_manager.cc

Issue 2339093002: [HBD] Add Plugins permission type and PermissionContext (Closed)
Patch Set: [HBD] Add Plugins permission type and PermissionContext Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/permissions/permission_request.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
10
9 #include "base/callback.h" 11 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
11 #include "build/build_config.h" 13 #include "build/build_config.h"
12 #include "chrome/browser/background_sync/background_sync_permission_context.h" 14 #include "chrome/browser/background_sync/background_sync_permission_context.h"
13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
14 #include "chrome/browser/media/midi_permission_context.h" 16 #include "chrome/browser/media/midi_permission_context.h"
15 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h" 17 #include "chrome/browser/media/webrtc/media_stream_device_permission_context.h"
16 #include "chrome/browser/notifications/notification_permission_context.h" 18 #include "chrome/browser/notifications/notification_permission_context.h"
17 #include "chrome/browser/permissions/permission_context_base.h" 19 #include "chrome/browser/permissions/permission_context_base.h"
18 #include "chrome/browser/permissions/permission_manager_factory.h" 20 #include "chrome/browser/permissions/permission_manager_factory.h"
19 #include "chrome/browser/permissions/permission_request_id.h" 21 #include "chrome/browser/permissions/permission_request_id.h"
20 #include "chrome/browser/permissions/permission_uma_util.h" 22 #include "chrome/browser/permissions/permission_uma_util.h"
21 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/storage/durable_storage_permission_context.h" 24 #include "chrome/browser/storage/durable_storage_permission_context.h"
23 #include "chrome/browser/tab_contents/tab_util.h" 25 #include "chrome/browser/tab_contents/tab_util.h"
24 #include "chrome/common/features.h" 26 #include "chrome/common/features.h"
25 #include "components/content_settings/core/browser/host_content_settings_map.h" 27 #include "components/content_settings/core/browser/host_content_settings_map.h"
26 #include "content/public/browser/permission_type.h" 28 #include "content/public/browser/permission_type.h"
27 #include "content/public/browser/render_frame_host.h" 29 #include "content/public/browser/render_frame_host.h"
28 #include "content/public/browser/render_process_host.h" 30 #include "content/public/browser/render_process_host.h"
29 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
30 32
33 #if defined(ENABLE_PLUGINS)
34 #include "chrome/browser/plugins/plugins_permission_context.h"
35 #endif
36
31 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 37 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
32 #include "chrome/browser/media/protected_media_identifier_permission_context.h" 38 #include "chrome/browser/media/protected_media_identifier_permission_context.h"
33 #endif 39 #endif
34 40
35 #if BUILDFLAG(ANDROID_JAVA_UI) 41 #if BUILDFLAG(ANDROID_JAVA_UI)
36 #include "chrome/browser/geolocation/geolocation_permission_context_android.h" 42 #include "chrome/browser/geolocation/geolocation_permission_context_android.h"
37 #else 43 #else
38 #include "chrome/browser/geolocation/geolocation_permission_context.h" 44 #include "chrome/browser/geolocation/geolocation_permission_context.h"
39 #endif 45 #endif
40 46
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; 98 return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE;
93 case PermissionType::MIDI: 99 case PermissionType::MIDI:
94 // This will hit the NOTREACHED below. 100 // This will hit the NOTREACHED below.
95 break; 101 break;
96 case PermissionType::AUDIO_CAPTURE: 102 case PermissionType::AUDIO_CAPTURE:
97 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; 103 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC;
98 case PermissionType::VIDEO_CAPTURE: 104 case PermissionType::VIDEO_CAPTURE:
99 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; 105 return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA;
100 case PermissionType::BACKGROUND_SYNC: 106 case PermissionType::BACKGROUND_SYNC:
101 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; 107 return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC;
108 case PermissionType::PLUGINS:
109 return CONTENT_SETTINGS_TYPE_PLUGINS;
102 case PermissionType::NUM: 110 case PermissionType::NUM:
103 // This will hit the NOTREACHED below. 111 // This will hit the NOTREACHED below.
104 break; 112 break;
105 } 113 }
106 114
107 NOTREACHED() << "Unknown content setting for permission " 115 NOTREACHED() << "Unknown content setting for permission "
108 << static_cast<int>(permission); 116 << static_cast<int>(permission);
109 return CONTENT_SETTINGS_TYPE_DEFAULT; 117 return CONTENT_SETTINGS_TYPE_DEFAULT;
110 } 118 }
111 119
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 permission_contexts_[PermissionType::AUDIO_CAPTURE] = 249 permission_contexts_[PermissionType::AUDIO_CAPTURE] =
242 base::MakeUnique<MediaStreamDevicePermissionContext>( 250 base::MakeUnique<MediaStreamDevicePermissionContext>(
243 profile, content::PermissionType::AUDIO_CAPTURE, 251 profile, content::PermissionType::AUDIO_CAPTURE,
244 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); 252 CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
245 permission_contexts_[PermissionType::VIDEO_CAPTURE] = 253 permission_contexts_[PermissionType::VIDEO_CAPTURE] =
246 base::MakeUnique<MediaStreamDevicePermissionContext>( 254 base::MakeUnique<MediaStreamDevicePermissionContext>(
247 profile, content::PermissionType::VIDEO_CAPTURE, 255 profile, content::PermissionType::VIDEO_CAPTURE,
248 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); 256 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
249 permission_contexts_[PermissionType::BACKGROUND_SYNC] = 257 permission_contexts_[PermissionType::BACKGROUND_SYNC] =
250 base::MakeUnique<BackgroundSyncPermissionContext>(profile); 258 base::MakeUnique<BackgroundSyncPermissionContext>(profile);
259 #if defined(ENABLE_PLUGINS)
260 permission_contexts_[PermissionType::PLUGINS] =
261 base::MakeUnique<PluginsPermissionContext>(profile);
262 #endif
251 } 263 }
252 264
253 PermissionManager::~PermissionManager() { 265 PermissionManager::~PermissionManager() {
254 if (!subscriptions_.IsEmpty()) 266 if (!subscriptions_.IsEmpty())
255 HostContentSettingsMapFactory::GetForProfile(profile_) 267 HostContentSettingsMapFactory::GetForProfile(profile_)
256 ->RemoveObserver(this); 268 ->RemoveObserver(this);
257 } 269 }
258 270
259 int PermissionManager::RequestPermission( 271 int PermissionManager::RequestPermission(
260 PermissionType permission, 272 PermissionType permission,
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // Add the callback to |callbacks| which will be run after the loop to 485 // Add the callback to |callbacks| which will be run after the loop to
474 // prevent re-entrance issues. 486 // prevent re-entrance issues.
475 callbacks.push_back( 487 callbacks.push_back(
476 base::Bind(subscription->callback, 488 base::Bind(subscription->callback,
477 ContentSettingToPermissionStatus(new_value))); 489 ContentSettingToPermissionStatus(new_value)));
478 } 490 }
479 491
480 for (const auto& callback : callbacks) 492 for (const auto& callback : callbacks)
481 callback.Run(); 493 callback.Run();
482 } 494 }
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/permissions/permission_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698