Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(635)

Side by Side Diff: chrome/browser/notifications/desktop_notification_service.h

Issue 12631017: Remove notifications when apps and OTR Profiles are removed. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/notifications/desktop_notification_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 class WebContents; 33 class WebContents;
34 struct ShowDesktopNotificationHostMsgParams; 34 struct ShowDesktopNotificationHostMsgParams;
35 } 35 }
36 36
37 namespace gfx { 37 namespace gfx {
38 class Image; 38 class Image;
39 } 39 }
40 40
41 // The DesktopNotificationService is an object, owned by the Profile, 41 // The DesktopNotificationService is an object, owned by the Profile,
42 // which provides the creation of desktop "toasts" to web pages and workers. 42 // which provides the creation of desktop "toasts" to web pages and workers.
43 class DesktopNotificationService : public content::NotificationObserver, 43 class DesktopNotificationService : public ProfileKeyedService {
44 public ProfileKeyedService {
45 public: 44 public:
46 enum DesktopNotificationSource { 45 enum DesktopNotificationSource {
47 PageNotification, 46 PageNotification,
48 WorkerNotification 47 WorkerNotification
49 }; 48 };
50 49
51 // Register profile-specific prefs of notifications. 50 // Register profile-specific prefs of notifications.
52 static void RegisterUserPrefs(PrefRegistrySyncable* prefs); 51 static void RegisterUserPrefs(PrefRegistrySyncable* prefs);
53 52
54 DesktopNotificationService(Profile* profile, 53 DesktopNotificationService(Profile* profile,
(...skipping 21 matching lines...) Expand all
76 // removed from the screen. If it hasn't been shown yet, it won't be 75 // removed from the screen. If it hasn't been shown yet, it won't be
77 // shown. 76 // shown.
78 bool CancelDesktopNotification(int process_id, 77 bool CancelDesktopNotification(int process_id,
79 int route_id, 78 int route_id,
80 int notification_id); 79 int notification_id);
81 80
82 // Methods to setup and modify permission preferences. 81 // Methods to setup and modify permission preferences.
83 void GrantPermission(const GURL& origin); 82 void GrantPermission(const GURL& origin);
84 void DenyPermission(const GURL& origin); 83 void DenyPermission(const GURL& origin);
85 84
86 // content::NotificationObserver implementation.
87 virtual void Observe(int type,
88 const content::NotificationSource& source,
89 const content::NotificationDetails& details) OVERRIDE;
90
91 // Creates a data:xxxx URL which contains the full HTML for a notification 85 // Creates a data:xxxx URL which contains the full HTML for a notification
92 // using supplied icon, title, and text, run through a template which contains 86 // using supplied icon, title, and text, run through a template which contains
93 // the standard formatting for notifications. 87 // the standard formatting for notifications.
94 static string16 CreateDataUrl(const GURL& icon_url, 88 static string16 CreateDataUrl(const GURL& icon_url,
95 const string16& title, 89 const string16& title,
96 const string16& body, 90 const string16& body,
97 WebKit::WebTextDirection dir); 91 WebKit::WebTextDirection dir);
98 92
99 // Creates a data:xxxx URL which contains the full HTML for a notification 93 // Creates a data:xxxx URL which contains the full HTML for a notification
100 // using resource template which contains the standard formatting for 94 // using resource template which contains the standard formatting for
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 HasPermission(const GURL& origin); 148 HasPermission(const GURL& origin);
155 149
156 // Returns true if the extension of the specified |id| is allowed to send 150 // Returns true if the extension of the specified |id| is allowed to send
157 // notifications. 151 // notifications.
158 bool IsExtensionEnabled(const std::string& id); 152 bool IsExtensionEnabled(const std::string& id);
159 153
160 // Updates the availability of the extension to send notifications. 154 // Updates the availability of the extension to send notifications.
161 void SetExtensionEnabled(const std::string& id, bool enabled); 155 void SetExtensionEnabled(const std::string& id, bool enabled);
162 156
163 private: 157 private:
164 void StartObserving();
165 void StopObserving();
166
167 // Takes a notification object and shows it in the UI. 158 // Takes a notification object and shows it in the UI.
168 void ShowNotification(const Notification& notification); 159 void ShowNotification(const Notification& notification);
169 160
170 // Returns a display name for an origin, to be used in permission infobar 161 // Returns a display name for an origin, to be used in permission infobar
171 // or on the frame of the notification toast. Different from the origin 162 // or on the frame of the notification toast. Different from the origin
172 // itself when dealing with extensions. 163 // itself when dealing with extensions.
173 string16 DisplayNameForOrigin(const GURL& origin); 164 string16 DisplayNameForOrigin(const GURL& origin);
174 165
175 // Notifies the observers when permissions settings change. 166 // Notifies the observers when permissions settings change.
176 void NotifySettingsChange(); 167 void NotifySettingsChange();
177 168
178 NotificationUIManager* GetUIManager(); 169 NotificationUIManager* GetUIManager();
179 170
180 // Called when the disabled_extension_id pref has been changed. 171 // Called when the disabled_extension_id pref has been changed.
181 void OnDisabledExtensionIdsChanged(); 172 void OnDisabledExtensionIdsChanged();
182 173
183 // The profile which owns this object. 174 // The profile which owns this object.
184 Profile* profile_; 175 Profile* profile_;
185 176
186 // Non-owned pointer to the notification manager which manages the 177 // Non-owned pointer to the notification manager which manages the
187 // UI for desktop toasts. 178 // UI for desktop toasts.
188 NotificationUIManager* ui_manager_; 179 NotificationUIManager* ui_manager_;
189 180
190 content::NotificationRegistrar notification_registrar_;
191
192 // Prefs listener for disabled_extension_id. 181 // Prefs listener for disabled_extension_id.
193 StringListPrefMember disabled_extension_id_pref_; 182 StringListPrefMember disabled_extension_id_pref_;
194 183
195 // On-memory data for the availability of extensions. 184 // On-memory data for the availability of extensions.
196 std::set<std::string> disabled_extension_ids_; 185 std::set<std::string> disabled_extension_ids_;
197 186
198 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService); 187 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService);
199 }; 188 };
200 189
201 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_ 190 #endif // CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/notifications/desktop_notification_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698