| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/desktop_notification_service.h" | 5 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/threading/thread.h" | |
| 12 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | |
| 14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" | 12 #include "chrome/browser/notifications/desktop_notification_profile_util.h" |
| 15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | |
| 16 #include "chrome/browser/notifications/notification.h" | 13 #include "chrome/browser/notifications/notification.h" |
| 17 #include "chrome/browser/notifications/notification_object_proxy.h" | 14 #include "chrome/browser/notifications/notification_object_proxy.h" |
| 18 #include "chrome/browser/notifications/notification_ui_manager.h" | 15 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 19 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" | |
| 20 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_fac
tory.h" | |
| 21 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 23 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 24 #include "chrome/common/url_constants.h" | |
| 25 #include "components/content_settings/core/common/permission_request_id.h" | 19 #include "components/content_settings/core/common/permission_request_id.h" |
| 26 #include "components/pref_registry/pref_registry_syncable.h" | 20 #include "components/pref_registry/pref_registry_syncable.h" |
| 27 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 28 #include "content/public/browser/desktop_notification_delegate.h" | 22 #include "content/public/browser/desktop_notification_delegate.h" |
| 29 #include "content/public/browser/notification_service.h" | |
| 30 #include "content/public/browser/render_view_host.h" | |
| 31 #include "content/public/browser/web_contents.h" | |
| 32 #include "content/public/common/show_desktop_notification_params.h" | 23 #include "content/public/common/show_desktop_notification_params.h" |
| 33 #include "ui/base/webui/web_ui_util.h" | 24 #include "ui/base/webui/web_ui_util.h" |
| 34 #include "ui/message_center/notifier_settings.h" | 25 #include "ui/message_center/notifier_settings.h" |
| 35 | 26 |
| 36 #if defined(ENABLE_EXTENSIONS) | 27 #if defined(ENABLE_EXTENSIONS) |
| 37 #include "chrome/browser/extensions/api/notifications/notifications_api.h" | 28 #include "chrome/browser/extensions/api/notifications/notifications_api.h" |
| 38 #include "chrome/browser/extensions/extension_service.h" | 29 #include "chrome/browser/extensions/extension_service.h" |
| 39 #include "extensions/browser/event_router.h" | 30 #include "extensions/browser/event_router.h" |
| 40 #include "extensions/browser/extension_registry.h" | 31 #include "extensions/browser/extension_registry.h" |
| 41 #include "extensions/browser/extension_system.h" | 32 #include "extensions/browser/extension_system.h" |
| 42 #include "extensions/browser/extension_util.h" | 33 #include "extensions/browser/extension_util.h" |
| 43 #include "extensions/browser/info_map.h" | 34 #include "extensions/browser/info_map.h" |
| 44 #include "extensions/browser/suggest_permission_util.h" | 35 #include "extensions/browser/suggest_permission_util.h" |
| 45 #include "extensions/common/constants.h" | 36 #include "extensions/common/constants.h" |
| 46 #include "extensions/common/extension.h" | 37 #include "extensions/common/extension.h" |
| 47 #include "extensions/common/extension_set.h" | 38 #include "extensions/common/extension_set.h" |
| 48 #endif | 39 #endif |
| 49 | 40 |
| 50 using blink::WebTextDirection; | |
| 51 using content::BrowserThread; | 41 using content::BrowserThread; |
| 52 using content::RenderViewHost; | |
| 53 using content::WebContents; | |
| 54 using message_center::NotifierId; | 42 using message_center::NotifierId; |
| 55 | 43 |
| 56 namespace { | 44 namespace { |
| 57 | 45 |
| 58 void CancelNotification(const std::string& id, ProfileID profile_id) { | 46 void CancelNotification(const std::string& id, ProfileID profile_id) { |
| 59 g_browser_process->notification_ui_manager()->CancelById(id, profile_id); | 47 g_browser_process->notification_ui_manager()->CancelById(id, profile_id); |
| 60 } | 48 } |
| 61 | 49 |
| 62 } // namespace | 50 } // namespace |
| 63 | 51 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 const gfx::Image& icon, | 70 const gfx::Image& icon, |
| 83 const base::string16& replace_id, | 71 const base::string16& replace_id, |
| 84 NotificationDelegate* delegate, | 72 NotificationDelegate* delegate, |
| 85 Profile* profile) { | 73 Profile* profile) { |
| 86 Notification notification(message_center::NOTIFICATION_TYPE_SIMPLE, | 74 Notification notification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 87 origin_url, | 75 origin_url, |
| 88 title, | 76 title, |
| 89 message, | 77 message, |
| 90 icon, | 78 icon, |
| 91 blink::WebTextDirectionDefault, | 79 blink::WebTextDirectionDefault, |
| 92 message_center::NotifierId(origin_url), | 80 NotifierId(origin_url), |
| 93 base::string16(), | 81 base::string16(), |
| 94 replace_id, | 82 replace_id, |
| 95 message_center::RichNotificationData(), | 83 message_center::RichNotificationData(), |
| 96 delegate); | 84 delegate); |
| 97 g_browser_process->notification_ui_manager()->Add(notification, profile); | 85 g_browser_process->notification_ui_manager()->Add(notification, profile); |
| 98 return notification.delegate_id(); | 86 return notification.delegate_id(); |
| 99 } | 87 } |
| 100 | 88 |
| 101 DesktopNotificationService::DesktopNotificationService(Profile* profile) | 89 DesktopNotificationService::DesktopNotificationService(Profile* profile) |
| 102 : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS), | 90 : PermissionContextBase(profile, CONTENT_SETTINGS_TYPE_NOTIFICATIONS), |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // Tell the IO thread that this extension's permission for notifications | 360 // Tell the IO thread that this extension's permission for notifications |
| 373 // has changed. | 361 // has changed. |
| 374 extensions::InfoMap* extension_info_map = | 362 extensions::InfoMap* extension_info_map = |
| 375 extensions::ExtensionSystem::Get(profile_)->info_map(); | 363 extensions::ExtensionSystem::Get(profile_)->info_map(); |
| 376 BrowserThread::PostTask( | 364 BrowserThread::PostTask( |
| 377 BrowserThread::IO, FROM_HERE, | 365 BrowserThread::IO, FROM_HERE, |
| 378 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, | 366 base::Bind(&extensions::InfoMap::SetNotificationsDisabled, |
| 379 extension_info_map, notifier_id.id, !enabled)); | 367 extension_info_map, notifier_id.id, !enabled)); |
| 380 #endif | 368 #endif |
| 381 } | 369 } |
| OLD | NEW |