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

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

Issue 2162033002: Revert "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"
22 #include "chrome/browser/storage/durable_storage_permission_context.h" 23 #include "chrome/browser/storage/durable_storage_permission_context.h"
23 #include "chrome/browser/tab_contents/tab_util.h" 24 #include "chrome/browser/tab_contents/tab_util.h"
24 #include "chrome/common/features.h" 25 #include "chrome/common/features.h"
25 #include "components/content_settings/core/browser/host_content_settings_map.h" 26 #include "components/content_settings/core/browser/host_content_settings_map.h"
26 #include "content/public/browser/permission_type.h" 27 #include "content/public/browser/permission_type.h"
27 #include "content/public/browser/render_frame_host.h" 28 #include "content/public/browser/render_frame_host.h"
28 #include "content/public/browser/render_process_host.h" 29 #include "content/public/browser/render_process_host.h"
29 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
30 31
31 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) 32 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 PermissionManager* PermissionManager::Get(Profile* profile) { 215 PermissionManager* PermissionManager::Get(Profile* profile) {
215 return PermissionManagerFactory::GetForProfile(profile); 216 return PermissionManagerFactory::GetForProfile(profile);
216 } 217 }
217 218
218 PermissionManager::PermissionManager(Profile* profile) 219 PermissionManager::PermissionManager(Profile* profile)
219 : profile_(profile), 220 : profile_(profile),
220 weak_ptr_factory_(this) { 221 weak_ptr_factory_(this) {
221 permission_contexts_[PermissionType::MIDI_SYSEX] = 222 permission_contexts_[PermissionType::MIDI_SYSEX] =
222 base::WrapUnique(new MidiPermissionContext(profile)); 223 base::WrapUnique(new MidiPermissionContext(profile));
223 permission_contexts_[PermissionType::PUSH_MESSAGING] = 224 permission_contexts_[PermissionType::PUSH_MESSAGING] =
224 base::WrapUnique(new NotificationPermissionContext( 225 base::WrapUnique(new PushMessagingPermissionContext(profile));
225 profile, PermissionType::PUSH_MESSAGING));
226 permission_contexts_[PermissionType::NOTIFICATIONS] = 226 permission_contexts_[PermissionType::NOTIFICATIONS] =
227 base::WrapUnique(new NotificationPermissionContext( 227 base::WrapUnique(new NotificationPermissionContext(profile));
228 profile, PermissionType::NOTIFICATIONS));
229 #if !BUILDFLAG(ANDROID_JAVA_UI) 228 #if !BUILDFLAG(ANDROID_JAVA_UI)
230 permission_contexts_[PermissionType::GEOLOCATION] = 229 permission_contexts_[PermissionType::GEOLOCATION] =
231 base::WrapUnique(new GeolocationPermissionContext(profile)); 230 base::WrapUnique(new GeolocationPermissionContext(profile));
232 #else 231 #else
233 permission_contexts_[PermissionType::GEOLOCATION] = 232 permission_contexts_[PermissionType::GEOLOCATION] =
234 base::WrapUnique(new GeolocationPermissionContextAndroid(profile)); 233 base::WrapUnique(new GeolocationPermissionContextAndroid(profile));
235 #endif 234 #endif
236 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) 235 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
237 permission_contexts_[PermissionType::PROTECTED_MEDIA_IDENTIFIER] = 236 permission_contexts_[PermissionType::PROTECTED_MEDIA_IDENTIFIER] =
238 base::WrapUnique(new ProtectedMediaIdentifierPermissionContext(profile)); 237 base::WrapUnique(new ProtectedMediaIdentifierPermissionContext(profile));
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // 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
475 // prevent re-entrance issues. 474 // prevent re-entrance issues.
476 callbacks.push_back( 475 callbacks.push_back(
477 base::Bind(subscription->callback, 476 base::Bind(subscription->callback,
478 ContentSettingToPermissionStatus(new_value))); 477 ContentSettingToPermissionStatus(new_value)));
479 } 478 }
480 479
481 for (const auto& callback : callbacks) 480 for (const auto& callback : callbacks)
482 callback.Run(); 481 callback.Run();
483 } 482 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698