| 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> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 namespace gfx { | 49 namespace gfx { |
| 50 class Image; | 50 class Image; |
| 51 } | 51 } |
| 52 | 52 |
| 53 namespace user_prefs { | 53 namespace user_prefs { |
| 54 class PrefRegistrySyncable; | 54 class PrefRegistrySyncable; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Callback to be invoked when the result of a permission request is known. | |
| 58 typedef base::Callback<void(blink::WebNotificationPermission)> | |
| 59 NotificationPermissionCallback; | |
| 60 | |
| 61 // The DesktopNotificationService is an object, owned by the Profile, | 57 // The DesktopNotificationService is an object, owned by the Profile, |
| 62 // which provides the creation of desktop "toasts" to web pages and workers. | 58 // which provides the creation of desktop "toasts" to web pages and workers. |
| 63 class DesktopNotificationService : public PermissionContextBase | 59 class DesktopNotificationService : public PermissionContextBase |
| 64 #if defined(ENABLE_EXTENSIONS) | 60 #if defined(ENABLE_EXTENSIONS) |
| 65 , | 61 , |
| 66 public extensions::ExtensionRegistryObserver | 62 public extensions::ExtensionRegistryObserver |
| 67 #endif | 63 #endif |
| 68 { | 64 { |
| 69 public: | 65 public: |
| 70 // Register profile-specific prefs of notifications. | 66 // Register profile-specific prefs of notifications. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 82 explicit DesktopNotificationService(Profile* profile); | 78 explicit DesktopNotificationService(Profile* profile); |
| 83 ~DesktopNotificationService() override; | 79 ~DesktopNotificationService() override; |
| 84 | 80 |
| 85 // Requests Web Notification permission for |requesting_frame|. The |callback| | 81 // Requests Web Notification permission for |requesting_frame|. The |callback| |
| 86 // will be invoked after the user has made a decision. | 82 // will be invoked after the user has made a decision. |
| 87 void RequestNotificationPermission( | 83 void RequestNotificationPermission( |
| 88 content::WebContents* web_contents, | 84 content::WebContents* web_contents, |
| 89 const PermissionRequestID& request_id, | 85 const PermissionRequestID& request_id, |
| 90 const GURL& requesting_origin, | 86 const GURL& requesting_origin, |
| 91 bool user_gesture, | 87 bool user_gesture, |
| 92 const NotificationPermissionCallback& callback); | 88 const base::Callback<void(bool)>& result_callback); |
| 93 | 89 |
| 94 // Show a desktop notification. If |cancel_callback| is non-null, it's set to | 90 // Show a desktop notification. If |cancel_callback| is non-null, it's set to |
| 95 // a callback which can be used to cancel the notification. | 91 // a callback which can be used to cancel the notification. |
| 96 void ShowDesktopNotification( | 92 void ShowDesktopNotification( |
| 97 const content::ShowDesktopNotificationHostMsgParams& params, | 93 const content::ShowDesktopNotificationHostMsgParams& params, |
| 98 content::RenderFrameHost* render_frame_host, | 94 content::RenderFrameHost* render_frame_host, |
| 99 scoped_ptr<content::DesktopNotificationDelegate> delegate, | 95 scoped_ptr<content::DesktopNotificationDelegate> delegate, |
| 100 base::Closure* cancel_callback); | 96 base::Closure* cancel_callback); |
| 101 | 97 |
| 102 // Returns true if the notifier with |notifier_id| is allowed to send | 98 // Returns true if the notifier with |notifier_id| is allowed to send |
| (...skipping 11 matching lines...) Expand all Loading... |
| 114 base::string16 DisplayNameForOriginInProcessId(const GURL& origin, | 110 base::string16 DisplayNameForOriginInProcessId(const GURL& origin, |
| 115 int process_id); | 111 int process_id); |
| 116 | 112 |
| 117 // Called when the string list pref has been changed. | 113 // Called when the string list pref has been changed. |
| 118 void OnStringListPrefChanged( | 114 void OnStringListPrefChanged( |
| 119 const char* pref_name, std::set<std::string>* ids_field); | 115 const char* pref_name, std::set<std::string>* ids_field); |
| 120 | 116 |
| 121 // Called when the disabled_extension_id pref has been changed. | 117 // Called when the disabled_extension_id pref has been changed. |
| 122 void OnDisabledExtensionIdsChanged(); | 118 void OnDisabledExtensionIdsChanged(); |
| 123 | 119 |
| 124 // Used as a callback once a permission has been decided to convert |allowed| | |
| 125 // to one of the blink::WebNotificationPermission values. | |
| 126 void OnNotificationPermissionRequested( | |
| 127 const base::Callback<void(blink::WebNotificationPermission)>& callback, | |
| 128 bool allowed); | |
| 129 | |
| 130 void FirePermissionLevelChangedEvent( | 120 void FirePermissionLevelChangedEvent( |
| 131 const message_center::NotifierId& notifier_id, | 121 const message_center::NotifierId& notifier_id, |
| 132 bool enabled); | 122 bool enabled); |
| 133 | 123 |
| 134 #if defined(ENABLE_EXTENSIONS) | 124 #if defined(ENABLE_EXTENSIONS) |
| 135 // extensions::ExtensionRegistryObserver: | 125 // extensions::ExtensionRegistryObserver: |
| 136 void OnExtensionUninstalled(content::BrowserContext* browser_context, | 126 void OnExtensionUninstalled(content::BrowserContext* browser_context, |
| 137 const extensions::Extension* extension, | 127 const extensions::Extension* extension, |
| 138 extensions::UninstallReason reason) override; | 128 extensions::UninstallReason reason) override; |
| 139 #endif | 129 #endif |
| (...skipping 18 matching lines...) Expand all Loading... |
| 158 // On-memory data for the availability of system_component. | 148 // On-memory data for the availability of system_component. |
| 159 std::set<std::string> disabled_system_component_ids_; | 149 std::set<std::string> disabled_system_component_ids_; |
| 160 | 150 |
| 161 #if defined(ENABLE_EXTENSIONS) | 151 #if defined(ENABLE_EXTENSIONS) |
| 162 // An observer to listen when extension is uninstalled. | 152 // An observer to listen when extension is uninstalled. |
| 163 ScopedObserver<extensions::ExtensionRegistry, | 153 ScopedObserver<extensions::ExtensionRegistry, |
| 164 extensions::ExtensionRegistryObserver> | 154 extensions::ExtensionRegistryObserver> |
| 165 extension_registry_observer_; | 155 extension_registry_observer_; |
| 166 #endif | 156 #endif |
| 167 | 157 |
| 168 base::WeakPtrFactory<DesktopNotificationService> weak_factory_; | |
| 169 | |
| 170 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); | 158 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); |
| 171 }; | 159 }; |
| 172 | 160 |
| 173 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ | 161 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ |
| OLD | NEW |