| OLD | NEW |
| 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/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 17 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
| 18 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | |
| 19 #include "chrome/browser/notifications/notification_display_service_factory.h" | 18 #include "chrome/browser/notifications/notification_display_service_factory.h" |
| 20 #include "chrome/browser/notifications/notification_object_proxy.h" | 19 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 21 #include "chrome/browser/notifications/notification_ui_manager.h" | 20 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 22 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 21 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
| 22 #include "chrome/browser/permissions/permission_manager.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/profiles/profile_attributes_storage.h" | 24 #include "chrome/browser/profiles/profile_attributes_storage.h" |
| 25 #include "chrome/browser/profiles/profile_io_data.h" | 25 #include "chrome/browser/profiles/profile_io_data.h" |
| 26 #include "chrome/browser/profiles/profile_manager.h" | 26 #include "chrome/browser/profiles/profile_manager.h" |
| 27 #include "chrome/browser/ui/browser.h" | 27 #include "chrome/browser/ui/browser.h" |
| 28 #include "chrome/browser/ui/chrome_pages.h" | 28 #include "chrome/browser/ui/chrome_pages.h" |
| 29 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 29 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
| 33 #include "components/content_settings/core/browser/host_content_settings_map.h" | 33 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 34 #include "components/content_settings/core/common/content_settings.h" | 34 #include "components/content_settings/core/common/content_settings.h" |
| 35 #include "components/content_settings/core/common/content_settings_types.h" | 35 #include "components/content_settings/core/common/content_settings_types.h" |
| 36 #include "components/prefs/pref_service.h" | 36 #include "components/prefs/pref_service.h" |
| 37 #include "components/url_formatter/url_formatter.h" | 37 #include "components/url_formatter/url_formatter.h" |
| 38 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/desktop_notification_delegate.h" | 39 #include "content/public/browser/desktop_notification_delegate.h" |
| 40 #include "content/public/browser/notification_event_dispatcher.h" | 40 #include "content/public/browser/notification_event_dispatcher.h" |
| 41 #include "content/public/browser/permission_type.h" |
| 41 #include "content/public/browser/platform_notification_context.h" | 42 #include "content/public/browser/platform_notification_context.h" |
| 42 #include "content/public/browser/storage_partition.h" | 43 #include "content/public/browser/storage_partition.h" |
| 43 #include "content/public/browser/user_metrics.h" | 44 #include "content/public/browser/user_metrics.h" |
| 44 #include "content/public/common/notification_resources.h" | 45 #include "content/public/common/notification_resources.h" |
| 45 #include "content/public/common/platform_notification_data.h" | 46 #include "content/public/common/platform_notification_data.h" |
| 46 #include "ui/base/l10n/l10n_util.h" | 47 #include "ui/base/l10n/l10n_util.h" |
| 47 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
| 48 #include "ui/message_center/notification_types.h" | 49 #include "ui/message_center/notification_types.h" |
| 49 #include "ui/message_center/notifier_settings.h" | 50 #include "ui/message_center/notifier_settings.h" |
| 50 #include "ui/resources/grit/ui_resources.h" | 51 #include "ui/resources/grit/ui_resources.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 NotifierStateTrackerFactory::GetForProfile(profile); | 261 NotifierStateTrackerFactory::GetForProfile(profile); |
| 261 DCHECK(notifier_state_tracker); | 262 DCHECK(notifier_state_tracker); |
| 262 | 263 |
| 263 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); | 264 NotifierId notifier_id(NotifierId::APPLICATION, extension->id()); |
| 264 if (notifier_state_tracker->IsNotifierEnabled(notifier_id)) | 265 if (notifier_state_tracker->IsNotifierEnabled(notifier_id)) |
| 265 return blink::mojom::PermissionStatus::GRANTED; | 266 return blink::mojom::PermissionStatus::GRANTED; |
| 266 } | 267 } |
| 267 } | 268 } |
| 268 #endif | 269 #endif |
| 269 | 270 |
| 270 ContentSetting setting = | 271 return PermissionManager::Get(profile)->GetPermissionStatus( |
| 271 DesktopNotificationProfileUtil::GetContentSetting(profile, origin); | 272 content::PermissionType::NOTIFICATIONS, origin, origin); |
| 272 | |
| 273 if (setting == CONTENT_SETTING_ALLOW) | |
| 274 return blink::mojom::PermissionStatus::GRANTED; | |
| 275 if (setting == CONTENT_SETTING_BLOCK) | |
| 276 return blink::mojom::PermissionStatus::DENIED; | |
| 277 | |
| 278 return blink::mojom::PermissionStatus::ASK; | |
| 279 } | 273 } |
| 280 | 274 |
| 281 blink::mojom::PermissionStatus | 275 blink::mojom::PermissionStatus |
| 282 PlatformNotificationServiceImpl::CheckPermissionOnIOThread( | 276 PlatformNotificationServiceImpl::CheckPermissionOnIOThread( |
| 283 content::ResourceContext* resource_context, | 277 content::ResourceContext* resource_context, |
| 284 const GURL& origin, | 278 const GURL& origin, |
| 285 int render_process_id) { | 279 int render_process_id) { |
| 286 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 280 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 287 | 281 |
| 288 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 282 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 538 } |
| 545 #endif | 539 #endif |
| 546 | 540 |
| 547 return base::string16(); | 541 return base::string16(); |
| 548 } | 542 } |
| 549 | 543 |
| 550 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( | 544 void PlatformNotificationServiceImpl::SetNotificationDisplayServiceForTesting( |
| 551 NotificationDisplayService* display_service) { | 545 NotificationDisplayService* display_service) { |
| 552 test_display_service_ = display_service; | 546 test_display_service_ = display_service; |
| 553 } | 547 } |
| OLD | NEW |