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/message_center_notification_manager.h" | 5 #include "chrome/browser/notifications/message_center_notification_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/prefs/pref_registry_simple.h" | 9 #include "base/prefs/pref_registry_simple.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" | 13 #include "chrome/browser/extensions/api/notification_provider/notification_provi
der_api.h" |
14 #include "chrome/browser/notifications/desktop_notification_service.h" | 14 #include "chrome/browser/notifications/desktop_notification_service.h" |
15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 15 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 16 #include "chrome/browser/notifications/extension_welcome_notification.h" |
| 17 #include "chrome/browser/notifications/extension_welcome_notification_factory.h" |
16 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" | 18 #include "chrome/browser/notifications/fullscreen_notification_blocker.h" |
17 #include "chrome/browser/notifications/message_center_settings_controller.h" | 19 #include "chrome/browser/notifications/message_center_settings_controller.h" |
18 #include "chrome/browser/notifications/notification.h" | 20 #include "chrome/browser/notifications/notification.h" |
19 #include "chrome/browser/notifications/notification_conversion_helper.h" | 21 #include "chrome/browser/notifications/notification_conversion_helper.h" |
20 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" | 22 #include "chrome/browser/notifications/screen_lock_notification_blocker.h" |
21 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/browser_finder.h" | 24 #include "chrome/browser/ui/browser_finder.h" |
23 #include "chrome/browser/ui/chrome_pages.h" | 25 #include "chrome/browser/ui/chrome_pages.h" |
24 #include "chrome/browser/ui/host_desktop.h" | 26 #include "chrome/browser/ui/host_desktop.h" |
25 #include "chrome/common/extensions/api/notification_provider.h" | 27 #include "chrome/common/extensions/api/notification_provider.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 117 } |
116 | 118 |
117 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
118 // NotificationUIManager | 120 // NotificationUIManager |
119 | 121 |
120 void MessageCenterNotificationManager::Add(const Notification& notification, | 122 void MessageCenterNotificationManager::Add(const Notification& notification, |
121 Profile* profile) { | 123 Profile* profile) { |
122 if (Update(notification, profile)) | 124 if (Update(notification, profile)) |
123 return; | 125 return; |
124 | 126 |
125 DesktopNotificationServiceFactory::GetForProfile(profile)-> | 127 ExtensionWelcomeNotificationFactory::GetForBrowserContext(profile)-> |
126 ShowWelcomeNotificationIfNecessary(notification); | 128 ShowWelcomeNotificationIfNecessary(notification); |
127 | 129 |
128 // WARNING: You MUST update the message center via the notification within a | 130 // WARNING: You MUST update the message center via the notification within a |
129 // ProfileNotification object or the profile ID will not be correctly set for | 131 // ProfileNotification object or the profile ID will not be correctly set for |
130 // ChromeOS. | 132 // ChromeOS. |
131 ProfileNotification* profile_notification( | 133 ProfileNotification* profile_notification( |
132 new ProfileNotification(profile, notification, message_center_)); | 134 new ProfileNotification(profile, notification, message_center_)); |
133 AddProfileNotification(profile_notification); | 135 AddProfileNotification(profile_notification); |
134 | 136 |
135 // TODO(liyanhou): Change the logic to only send notifications to one party. | 137 // TODO(liyanhou): Change the logic to only send notifications to one party. |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 it != registry->enabled_extensions().end(); | 542 it != registry->enabled_extensions().end(); |
541 ++it) { | 543 ++it) { |
542 if ((*it->get()).permissions_data()->HasAPIPermission( | 544 if ((*it->get()).permissions_data()->HasAPIPermission( |
543 extensions::APIPermission::ID::kNotificationProvider)) { | 545 extensions::APIPermission::ID::kNotificationProvider)) { |
544 extension_id = (*it->get()).id(); | 546 extension_id = (*it->get()).id(); |
545 return extension_id; | 547 return extension_id; |
546 } | 548 } |
547 } | 549 } |
548 return extension_id; | 550 return extension_id; |
549 } | 551 } |
OLD | NEW |