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 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/prefs/pref_member.h" | 16 #include "base/prefs/pref_member.h" |
17 #include "base/scoped_observer.h" | |
17 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
18 #include "chrome/browser/content_settings/content_settings_provider.h" | 19 #include "chrome/browser/content_settings/content_settings_provider.h" |
19 #include "chrome/browser/notifications/extension_welcome_notification.h" | 20 #include "chrome/browser/notifications/extension_welcome_notification.h" |
20 #include "chrome/common/content_settings.h" | 21 #include "chrome/common/content_settings.h" |
21 #include "components/keyed_service/core/keyed_service.h" | 22 #include "components/keyed_service/core/keyed_service.h" |
22 #include "content/public/browser/notification_observer.h" | 23 #include "extensions/browser/extension_registry_observer.h" |
23 #include "content/public/browser/notification_registrar.h" | |
24 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" | 24 #include "third_party/WebKit/public/web/WebNotificationPresenter.h" |
25 #include "third_party/WebKit/public/web/WebTextDirection.h" | 25 #include "third_party/WebKit/public/web/WebTextDirection.h" |
26 #include "ui/message_center/notifier_settings.h" | 26 #include "ui/message_center/notifier_settings.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
28 | 28 |
29 class ContentSettingsPattern; | 29 class ContentSettingsPattern; |
30 class Notification; | 30 class Notification; |
31 class NotificationDelegate; | 31 class NotificationDelegate; |
32 class NotificationUIManager; | 32 class NotificationUIManager; |
33 class Profile; | 33 class Profile; |
34 | 34 |
35 namespace content { | 35 namespace content { |
36 class DesktopNotificationDelegate; | 36 class DesktopNotificationDelegate; |
37 class RenderFrameHost; | 37 class RenderFrameHost; |
38 struct ShowDesktopNotificationHostMsgParams; | 38 struct ShowDesktopNotificationHostMsgParams; |
39 } | 39 } |
40 | 40 |
41 namespace extensions { | |
42 class ExtensionRegistry; | |
43 } | |
44 | |
41 namespace gfx { | 45 namespace gfx { |
42 class Image; | 46 class Image; |
43 } | 47 } |
44 | 48 |
45 namespace user_prefs { | 49 namespace user_prefs { |
46 class PrefRegistrySyncable; | 50 class PrefRegistrySyncable; |
47 } | 51 } |
48 | 52 |
49 // The DesktopNotificationService is an object, owned by the Profile, | 53 // The DesktopNotificationService is an object, owned by the Profile, |
50 // which provides the creation of desktop "toasts" to web pages and workers. | 54 // which provides the creation of desktop "toasts" to web pages and workers. |
51 class DesktopNotificationService : public KeyedService, | 55 class DesktopNotificationService |
52 public content::NotificationObserver { | 56 : public KeyedService, |
57 public extensions::ExtensionRegistryObserver { | |
53 public: | 58 public: |
54 // Register profile-specific prefs of notifications. | 59 // Register profile-specific prefs of notifications. |
55 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs); | 60 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs); |
56 | 61 |
57 DesktopNotificationService(Profile* profile, | 62 DesktopNotificationService(Profile* profile, |
58 NotificationUIManager* ui_manager); | 63 NotificationUIManager* ui_manager); |
59 virtual ~DesktopNotificationService(); | 64 virtual ~DesktopNotificationService(); |
60 | 65 |
61 // Requests permission for a given origin. |callback| is run when the UI | 66 // Requests permission for a given origin. |callback| is run when the UI |
62 // finishes. | 67 // finishes. |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
151 // Called when the disabled_extension_id pref has been changed. | 156 // Called when the disabled_extension_id pref has been changed. |
152 void OnDisabledExtensionIdsChanged(); | 157 void OnDisabledExtensionIdsChanged(); |
153 | 158 |
154 // Called when the disabled_system_component_id pref has been changed. | 159 // Called when the disabled_system_component_id pref has been changed. |
155 void OnDisabledSystemComponentIdsChanged(); | 160 void OnDisabledSystemComponentIdsChanged(); |
156 | 161 |
157 void FirePermissionLevelChangedEvent( | 162 void FirePermissionLevelChangedEvent( |
158 const message_center::NotifierId& notifier_id, | 163 const message_center::NotifierId& notifier_id, |
159 bool enabled); | 164 bool enabled); |
160 | 165 |
161 // content::NotificationObserver: | 166 // extensions::ExtensionRegistryObserver: |
162 virtual void Observe(int type, | 167 virtual void OnExtensionUninstalled( |
163 const content::NotificationSource& source, | 168 content::BrowserContext* browser_context, |
164 const content::NotificationDetails& details) OVERRIDE; | 169 const extensions::Extension* extension, |
170 extensions::UninstallReason reason) OVERRIDE; | |
165 | 171 |
166 // The profile which owns this object. | 172 // The profile which owns this object. |
167 Profile* profile_; | 173 Profile* profile_; |
168 | 174 |
169 // Non-owned pointer to the notification manager which manages the | 175 // Non-owned pointer to the notification manager which manages the |
170 // UI for desktop toasts. | 176 // UI for desktop toasts. |
171 NotificationUIManager* ui_manager_; | 177 NotificationUIManager* ui_manager_; |
172 | 178 |
173 // Prefs listener for disabled_extension_id. | 179 // Prefs listener for disabled_extension_id. |
174 StringListPrefMember disabled_extension_id_pref_; | 180 StringListPrefMember disabled_extension_id_pref_; |
175 | 181 |
176 // Prefs listener for disabled_system_component_id. | 182 // Prefs listener for disabled_system_component_id. |
177 StringListPrefMember disabled_system_component_id_pref_; | 183 StringListPrefMember disabled_system_component_id_pref_; |
178 | 184 |
179 // On-memory data for the availability of extensions. | 185 // On-memory data for the availability of extensions. |
180 std::set<std::string> disabled_extension_ids_; | 186 std::set<std::string> disabled_extension_ids_; |
181 | 187 |
182 // On-memory data for the availability of system_component. | 188 // On-memory data for the availability of system_component. |
183 std::set<std::string> disabled_system_component_ids_; | 189 std::set<std::string> disabled_system_component_ids_; |
184 | 190 |
185 // Registrar for the other kind of notifications (event signaling). | 191 // Listen extension uninstalled. |
Dmitry Titov
2014/07/22 17:43:01
The comment should be formed as a normal sentence.
limasdf
2014/07/22 18:15:41
Done.
| |
186 content::NotificationRegistrar registrar_; | 192 ScopedObserver<extensions::ExtensionRegistry, |
193 extensions::ExtensionRegistryObserver> | |
194 extension_registry_observer_; | |
187 | 195 |
188 // Welcome Notification | 196 // Welcome Notification |
189 scoped_ptr<ExtensionWelcomeNotification> chrome_now_welcome_notification_; | 197 scoped_ptr<ExtensionWelcomeNotification> chrome_now_welcome_notification_; |
190 | 198 |
191 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); | 199 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); |
192 }; | 200 }; |
193 | 201 |
194 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 202 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
OLD | NEW |