Chromium Code Reviews| 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/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/prefs/pref_member.h" | 17 #include "base/prefs/pref_member.h" |
| 18 #include "base/scoped_observer.h" | 18 #include "base/scoped_observer.h" |
| 19 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
| 20 #include "chrome/browser/content_settings/content_settings_provider.h" | 20 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 21 #include "chrome/browser/content_settings/permission_context_base.h" | 21 #include "chrome/browser/content_settings/permission_context_base.h" |
| 22 #include "chrome/browser/notifications/extension_welcome_notification.h" | 22 #include "chrome/browser/notifications/extension_welcome_notification.h" |
| 23 #include "components/content_settings/core/common/content_settings.h" | 23 #include "components/content_settings/core/common/content_settings.h" |
| 24 #include "components/keyed_service/core/keyed_service.h" | 24 #include "components/keyed_service/core/keyed_service.h" |
| 25 #if defined(ENABLE_EXTENSIONS) | |
|
Jun Mukai
2014/09/22 07:22:47
Please move this below. Our style is:
#include ..
| |
| 25 #include "extensions/browser/extension_registry_observer.h" | 26 #include "extensions/browser/extension_registry_observer.h" |
| 27 #endif | |
| 26 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" | 28 #include "third_party/WebKit/public/platform/WebNotificationPermission.h" |
| 27 #include "third_party/WebKit/public/web/WebTextDirection.h" | 29 #include "third_party/WebKit/public/web/WebTextDirection.h" |
| 28 #include "ui/message_center/notifier_settings.h" | 30 #include "ui/message_center/notifier_settings.h" |
| 29 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 30 | 32 |
| 31 class ContentSettingsPattern; | 33 class ContentSettingsPattern; |
| 32 class Notification; | 34 class Notification; |
| 33 class NotificationDelegate; | 35 class NotificationDelegate; |
| 34 class NotificationUIManager; | 36 class NotificationUIManager; |
| 35 class Profile; | 37 class Profile; |
| 36 | 38 |
| 37 namespace content { | 39 namespace content { |
| 38 class DesktopNotificationDelegate; | 40 class DesktopNotificationDelegate; |
| 39 class RenderFrameHost; | 41 class RenderFrameHost; |
| 40 struct ShowDesktopNotificationHostMsgParams; | 42 struct ShowDesktopNotificationHostMsgParams; |
| 41 } | 43 } |
| 42 | 44 |
| 45 #if defined(ENABLE_EXTENSIONS) | |
| 43 namespace extensions { | 46 namespace extensions { |
| 44 class ExtensionRegistry; | 47 class ExtensionRegistry; |
| 45 } | 48 } |
| 49 #endif | |
| 46 | 50 |
| 47 namespace gfx { | 51 namespace gfx { |
| 48 class Image; | 52 class Image; |
| 49 } | 53 } |
| 50 | 54 |
| 51 namespace user_prefs { | 55 namespace user_prefs { |
| 52 class PrefRegistrySyncable; | 56 class PrefRegistrySyncable; |
| 53 } | 57 } |
| 54 | 58 |
| 55 // Callback to be invoked when the result of a permission request is known. | 59 // Callback to be invoked when the result of a permission request is known. |
| 56 typedef base::Callback<void(blink::WebNotificationPermission)> | 60 typedef base::Callback<void(blink::WebNotificationPermission)> |
| 57 NotificationPermissionCallback; | 61 NotificationPermissionCallback; |
| 58 | 62 |
| 59 // The DesktopNotificationService is an object, owned by the Profile, | 63 // The DesktopNotificationService is an object, owned by the Profile, |
| 60 // which provides the creation of desktop "toasts" to web pages and workers. | 64 // which provides the creation of desktop "toasts" to web pages and workers. |
| 61 class DesktopNotificationService | 65 class DesktopNotificationService : public PermissionContextBase |
| 62 : public PermissionContextBase, | 66 #if defined(ENABLE_EXTENSIONS) |
| 63 public extensions::ExtensionRegistryObserver { | 67 , |
| 68 public extensions::ExtensionRegistryObserver | |
| 69 #endif | |
| 70 { | |
| 64 public: | 71 public: |
| 65 // Register profile-specific prefs of notifications. | 72 // Register profile-specific prefs of notifications. |
| 66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs); | 73 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* prefs); |
| 67 | 74 |
| 68 // Add a desktop notification. | 75 // Add a desktop notification. |
| 69 static std::string AddIconNotification(const GURL& origin_url, | 76 static std::string AddIconNotification(const GURL& origin_url, |
| 70 const base::string16& title, | 77 const base::string16& title, |
| 71 const base::string16& message, | 78 const base::string16& message, |
| 72 const gfx::Image& icon, | 79 const gfx::Image& icon, |
| 73 const base::string16& replace_id, | 80 const base::string16& replace_id, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 // Used as a callback once a permission has been decided to convert |allowed| | 130 // Used as a callback once a permission has been decided to convert |allowed| |
| 124 // to one of the blink::WebNotificationPermission values. | 131 // to one of the blink::WebNotificationPermission values. |
| 125 void OnNotificationPermissionRequested( | 132 void OnNotificationPermissionRequested( |
| 126 const base::Callback<void(blink::WebNotificationPermission)>& callback, | 133 const base::Callback<void(blink::WebNotificationPermission)>& callback, |
| 127 bool allowed); | 134 bool allowed); |
| 128 | 135 |
| 129 void FirePermissionLevelChangedEvent( | 136 void FirePermissionLevelChangedEvent( |
| 130 const message_center::NotifierId& notifier_id, | 137 const message_center::NotifierId& notifier_id, |
| 131 bool enabled); | 138 bool enabled); |
| 132 | 139 |
| 140 #if defined(ENABLE_EXTENSIONS) | |
| 133 // extensions::ExtensionRegistryObserver: | 141 // extensions::ExtensionRegistryObserver: |
| 134 virtual void OnExtensionUninstalled( | 142 virtual void OnExtensionUninstalled( |
| 135 content::BrowserContext* browser_context, | 143 content::BrowserContext* browser_context, |
| 136 const extensions::Extension* extension, | 144 const extensions::Extension* extension, |
| 137 extensions::UninstallReason reason) OVERRIDE; | 145 extensions::UninstallReason reason) OVERRIDE; |
| 146 #endif | |
| 138 | 147 |
| 139 // The profile which owns this object. | 148 // The profile which owns this object. |
| 140 Profile* profile_; | 149 Profile* profile_; |
| 141 | 150 |
| 142 // Prefs listener for disabled_extension_id. | 151 // Prefs listener for disabled_extension_id. |
| 143 StringListPrefMember disabled_extension_id_pref_; | 152 StringListPrefMember disabled_extension_id_pref_; |
| 144 | 153 |
| 145 // Prefs listener for disabled_system_component_id. | 154 // Prefs listener for disabled_system_component_id. |
| 146 StringListPrefMember disabled_system_component_id_pref_; | 155 StringListPrefMember disabled_system_component_id_pref_; |
| 147 | 156 |
| 148 // On-memory data for the availability of extensions. | 157 // On-memory data for the availability of extensions. |
| 149 std::set<std::string> disabled_extension_ids_; | 158 std::set<std::string> disabled_extension_ids_; |
| 150 | 159 |
| 151 // On-memory data for the availability of system_component. | 160 // On-memory data for the availability of system_component. |
| 152 std::set<std::string> disabled_system_component_ids_; | 161 std::set<std::string> disabled_system_component_ids_; |
| 153 | 162 |
| 163 #if defined(ENABLE_EXTENSIONS) | |
| 154 // An observer to listen when extension is uninstalled. | 164 // An observer to listen when extension is uninstalled. |
| 155 ScopedObserver<extensions::ExtensionRegistry, | 165 ScopedObserver<extensions::ExtensionRegistry, |
| 156 extensions::ExtensionRegistryObserver> | 166 extensions::ExtensionRegistryObserver> |
| 157 extension_registry_observer_; | 167 extension_registry_observer_; |
| 168 #endif | |
| 158 | 169 |
| 159 // Welcome Notification | 170 // Welcome Notification |
| 160 scoped_ptr<ExtensionWelcomeNotification> chrome_now_welcome_notification_; | 171 scoped_ptr<ExtensionWelcomeNotification> chrome_now_welcome_notification_; |
| 161 | 172 |
| 162 base::WeakPtrFactory<DesktopNotificationService> weak_factory_; | 173 base::WeakPtrFactory<DesktopNotificationService> weak_factory_; |
| 163 | 174 |
| 164 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); | 175 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); |
| 165 }; | 176 }; |
| 166 | 177 |
| 167 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 178 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
| OLD | NEW |