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

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

Issue 2149883002: Use the same codepath for NOTIFICATIONS and PUSH_MESSAGING permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
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 "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/background_sync/background_sync_permission_context.h" 12 #include "chrome/browser/background_sync/background_sync_permission_context.h"
13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 13 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
14 #include "chrome/browser/media/media_stream_device_permission_context.h" 14 #include "chrome/browser/media/media_stream_device_permission_context.h"
15 #include "chrome/browser/media/midi_permission_context.h" 15 #include "chrome/browser/media/midi_permission_context.h"
16 #include "chrome/browser/notifications/notification_permission_context.h" 16 #include "chrome/browser/notifications/notification_permission_context.h"
17 #include "chrome/browser/permissions/permission_context_base.h" 17 #include "chrome/browser/permissions/permission_context_base.h"
18 #include "chrome/browser/permissions/permission_manager_factory.h" 18 #include "chrome/browser/permissions/permission_manager_factory.h"
19 #include "chrome/browser/permissions/permission_request_id.h" 19 #include "chrome/browser/permissions/permission_request_id.h"
20 #include "chrome/browser/permissions/permission_uma_util.h" 20 #include "chrome/browser/permissions/permission_uma_util.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/push_messaging/push_messaging_permission_context.h"
23 #include "chrome/browser/storage/durable_storage_permission_context.h" 22 #include "chrome/browser/storage/durable_storage_permission_context.h"
24 #include "chrome/browser/tab_contents/tab_util.h" 23 #include "chrome/browser/tab_contents/tab_util.h"
25 #include "chrome/common/features.h" 24 #include "chrome/common/features.h"
26 #include "components/content_settings/core/browser/host_content_settings_map.h" 25 #include "components/content_settings/core/browser/host_content_settings_map.h"
27 #include "content/public/browser/permission_type.h" 26 #include "content/public/browser/permission_type.h"
28 #include "content/public/browser/render_frame_host.h" 27 #include "content/public/browser/render_frame_host.h"
29 #include "content/public/browser/render_process_host.h" 28 #include "content/public/browser/render_process_host.h"
30 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
31 30
32 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 31 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 PermissionManager* PermissionManager::Get(Profile* profile) { 214 PermissionManager* PermissionManager::Get(Profile* profile) {
216 return PermissionManagerFactory::GetForProfile(profile); 215 return PermissionManagerFactory::GetForProfile(profile);
217 } 216 }
218 217
219 PermissionManager::PermissionManager(Profile* profile) 218 PermissionManager::PermissionManager(Profile* profile)
220 : profile_(profile), 219 : profile_(profile),
221 weak_ptr_factory_(this) { 220 weak_ptr_factory_(this) {
222 permission_contexts_[PermissionType::MIDI_SYSEX] = 221 permission_contexts_[PermissionType::MIDI_SYSEX] =
223 base::WrapUnique(new MidiPermissionContext(profile)); 222 base::WrapUnique(new MidiPermissionContext(profile));
224 permission_contexts_[PermissionType::PUSH_MESSAGING] = 223 permission_contexts_[PermissionType::PUSH_MESSAGING] =
225 base::WrapUnique(new PushMessagingPermissionContext(profile)); 224 base::WrapUnique(new NotificationPermissionContext(
225 profile, PermissionType::PUSH_MESSAGING));
226 permission_contexts_[PermissionType::NOTIFICATIONS] = 226 permission_contexts_[PermissionType::NOTIFICATIONS] =
227 base::WrapUnique(new NotificationPermissionContext(profile)); 227 base::WrapUnique(new NotificationPermissionContext(
228 profile, PermissionType::NOTIFICATIONS));
228 #if !BUILDFLAG(ANDROID_JAVA_UI) 229 #if !BUILDFLAG(ANDROID_JAVA_UI)
229 permission_contexts_[PermissionType::GEOLOCATION] = 230 permission_contexts_[PermissionType::GEOLOCATION] =
230 base::WrapUnique(new GeolocationPermissionContext(profile)); 231 base::WrapUnique(new GeolocationPermissionContext(profile));
231 #else 232 #else
232 permission_contexts_[PermissionType::GEOLOCATION] = 233 permission_contexts_[PermissionType::GEOLOCATION] =
233 base::WrapUnique(new GeolocationPermissionContextAndroid(profile)); 234 base::WrapUnique(new GeolocationPermissionContextAndroid(profile));
234 #endif 235 #endif
235 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) 236 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
236 permission_contexts_[PermissionType::PROTECTED_MEDIA_IDENTIFIER] = 237 permission_contexts_[PermissionType::PROTECTED_MEDIA_IDENTIFIER] =
237 base::WrapUnique(new ProtectedMediaIdentifierPermissionContext(profile)); 238 base::WrapUnique(new ProtectedMediaIdentifierPermissionContext(profile));
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // Add the callback to |callbacks| which will be run after the loop to 474 // Add the callback to |callbacks| which will be run after the loop to
474 // prevent re-entrance issues. 475 // prevent re-entrance issues.
475 callbacks.push_back( 476 callbacks.push_back(
476 base::Bind(subscription->callback, 477 base::Bind(subscription->callback,
477 ContentSettingToPermissionStatus(new_value))); 478 ContentSettingToPermissionStatus(new_value)));
478 } 479 }
479 480
480 for (const auto& callback : callbacks) 481 for (const auto& callback : callbacks)
481 callback.Run(); 482 callback.Run();
482 } 483 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698