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

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

Issue 194108: adds DesktopNotificationService to Profile (Closed)
Patch Set: more feedback Created 11 years, 2 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
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H
6 #define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H
7
8 #include <set>
9
10 #include "base/basictypes.h"
11 #include "chrome/browser/notifications/notification.h"
12 #include "googleurl/src/gurl.h"
13
14 class NotificationUIManager;
15 class NotificationsPrefsCache;
16 class PrefService;
17 class Profile;
18 class Task;
19
20 // The DesktopNotificationService is an object, owned by the Profile,
21 // which provides the creation of desktop "toasts" to web pages and workers.
22 class DesktopNotificationService {
23 public:
24 enum NotificationSource {
25 PageNotification,
26 WorkerNotification
27 };
28
29 DesktopNotificationService(Profile* profile,
30 NotificationUIManager* ui_manager);
31 ~DesktopNotificationService();
32
33 // Requests permission (using an info-bar) for a given origin.
34 // |callback_context| contains an opaque value to pass back to the
35 // requesting process when the info-bar finishes.
36 void RequestPermission(const GURL& origin, int callback_context);
37
38 // Takes a notification object and shows it in the UI.
39 void ShowNotification(const Notification& notification);
40
41 // Two ShowNotification methods: getting content either from remote
42 // URL or as local parameters. These are called on the UI thread
43 // in response to IPCs from a child process running script. |origin|
44 // is the origin of the script. |source| indicates whether the
45 // script is in a worker or page. |notification_id| is an opaque
46 // value to be passed back to the process when events occur on
47 // this notification.
48 bool ShowDesktopNotification(const GURL& origin, const GURL& url,
49 int process_id, int route_id, NotificationSource source,
50 int notification_id);
51 bool ShowDesktopNotificationText(const GURL& origin, const GURL& icon,
52 const string16& title, const string16& text, int process_id,
53 int route_id, NotificationSource source, int notification_id);
54
55 // Methods to setup and modify permission preferences.
56 void GrantPermission(const GURL& origin);
57 void DenyPermission(const GURL& origin);
58
59 NotificationsPrefsCache* prefs_cache() { return prefs_cache_; }
60
61 private:
62 void InitPrefs();
63
64 // The profile which owns this object.
65 Profile* profile_;
66
67 // A cache of preferences which is accessible only on the IO thread
68 // to service synchronous IPCs.
69 scoped_refptr<NotificationsPrefsCache> prefs_cache_;
70
71 // Non-owned pointer to the notification manager which manages the
72 // UI for desktop toasts.
73 NotificationUIManager* ui_manager_;
74
75 DISALLOW_COPY_AND_ASSIGN(DesktopNotificationService);
76 };
77
78 #endif // #ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATION_SERVICE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698