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

Side by Side Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 2713083003: Use ContentSetting in chrome/ instead of PermissionStatus (Closed)
Patch Set: maybe fix android compile + address comments + basic tests Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/notifications/platform_notification_service_impl.h" 5 #include "chrome/browser/notifications/platform_notification_service_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/user_metrics_action.h" 11 #include "base/metrics/user_metrics_action.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 15 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
16 #include "chrome/browser/notifications/notification_display_service_factory.h" 16 #include "chrome/browser/notifications/notification_display_service_factory.h"
17 #include "chrome/browser/notifications/notification_object_proxy.h" 17 #include "chrome/browser/notifications/notification_object_proxy.h"
18 #include "chrome/browser/notifications/persistent_notification_delegate.h" 18 #include "chrome/browser/notifications/persistent_notification_delegate.h"
19 #include "chrome/browser/permissions/permission_manager.h" 19 #include "chrome/browser/permissions/permission_manager.h"
20 #include "chrome/browser/permissions/permission_result.h"
20 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_attributes_storage.h" 22 #include "chrome/browser/profiles/profile_attributes_storage.h"
22 #include "chrome/browser/profiles/profile_io_data.h" 23 #include "chrome/browser/profiles/profile_io_data.h"
23 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/safe_browsing/ping_manager.h" 25 #include "chrome/browser/safe_browsing/ping_manager.h"
25 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 26 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
26 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
27 #include "chrome/common/pref_names.h" 28 #include "chrome/common/pref_names.h"
28 #include "chrome/grit/generated_resources.h" 29 #include "chrome/grit/generated_resources.h"
29 #include "components/content_settings/core/browser/host_content_settings_map.h" 30 #include "components/content_settings/core/browser/host_content_settings_map.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 NotifierStateTrackerFactory::GetForProfile(profile); 221 NotifierStateTrackerFactory::GetForProfile(profile);
221 DCHECK(notifier_state_tracker); 222 DCHECK(notifier_state_tracker);
222 223
223 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); 224 NotifierId notifier_id(NotifierId::APPLICATION, extension->id());
224 if (notifier_state_tracker->IsNotifierEnabled(notifier_id)) 225 if (notifier_state_tracker->IsNotifierEnabled(notifier_id))
225 return blink::mojom::PermissionStatus::GRANTED; 226 return blink::mojom::PermissionStatus::GRANTED;
226 } 227 }
227 } 228 }
228 #endif 229 #endif
229 230
230 return PermissionManager::Get(profile)->GetPermissionStatus( 231 ContentSetting setting =
231 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin, origin); 232 PermissionManager::Get(profile)
233 ->GetPermissionStatus(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, origin,
234 origin)
235 .content_setting;
236 if (setting == CONTENT_SETTING_ALLOW)
237 return blink::mojom::PermissionStatus::GRANTED;
238 if (setting == CONTENT_SETTING_ASK)
239 return blink::mojom::PermissionStatus::ASK;
240 DCHECK_EQ(CONTENT_SETTING_BLOCK, setting);
241 return blink::mojom::PermissionStatus::DENIED;
232 } 242 }
233 243
234 blink::mojom::PermissionStatus 244 blink::mojom::PermissionStatus
235 PlatformNotificationServiceImpl::CheckPermissionOnIOThread( 245 PlatformNotificationServiceImpl::CheckPermissionOnIOThread(
236 content::ResourceContext* resource_context, 246 content::ResourceContext* resource_context,
237 const GURL& origin, 247 const GURL& origin,
238 int render_process_id) { 248 int render_process_id) {
239 DCHECK_CURRENTLY_ON(BrowserThread::IO); 249 DCHECK_CURRENTLY_ON(BrowserThread::IO);
240 250
241 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 251 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 } 522 }
513 #endif 523 #endif
514 524
515 return base::string16(); 525 return base::string16();
516 } 526 }
517 527
518 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( 528 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting(
519 NotificationDisplayService* display_service) { 529 NotificationDisplayService* display_service) {
520 test_display_service_ = display_service; 530 test_display_service_ = display_service;
521 } 531 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698