Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / content / public / browser / notification_service.h
blobc657d2b10deb3c3e579bf2011822bca4c8bc32bf
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
3 // found in the LICENSE file.
5 // This file describes a central switchboard for notifications that might
6 // happen in various parts of the application, and allows users to register
7 // observers for various classes of events that they're interested in.
9 #ifndef CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_H_
10 #define CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_H_
12 #include "content/common/content_export.h"
13 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_source.h"
16 namespace content {
18 class CONTENT_EXPORT NotificationService {
19 public:
20 // Returns the NotificationService object for the current thread, or nullptr
21 // if none.
22 static NotificationService* current();
24 static NotificationService* Create();
26 virtual ~NotificationService() {}
28 // Synchronously posts a notification to all interested observers.
29 // Source is a reference to a NotificationSource object representing
30 // the object originating the notification (can be
31 // NotificationService::AllSources(), in which case
32 // only observers interested in all sources will be notified).
33 // Details is a reference to an object containing additional data about
34 // the notification. If no additional data is needed, NoDetails() is used.
35 // There is no particular order in which the observers will be notified.
36 virtual void Notify(int type,
37 const NotificationSource& source,
38 const NotificationDetails& details) = 0;
40 // Returns a NotificationSource that represents all notification sources
41 // (for the purpose of registering an observer for events from all sources).
42 static Source<void> AllSources() { return Source<void>(nullptr); }
44 // Returns the same value as AllSources(). This function has semantic
45 // differences to the programmer: We have checked that this AllSources()
46 // usage is safe in the face of multiple profiles. Objects that were
47 // singletons now will always have multiple instances, one per browser
48 // context.
50 // Some usage is safe, where the Source is checked to see if it's a member of
51 // a container before use. But, we want the number of AllSources() calls to
52 // drop to almost nothing, because most usages are not multiprofile safe and
53 // were done because it was easier to listen to everything.
54 static Source<void> AllBrowserContextsAndSources() {
55 return Source<void>(nullptr);
58 // Returns a NotificationDetails object that represents a lack of details
59 // associated with a notification. (This is effectively a null pointer.)
60 static Details<void> NoDetails() { return Details<void>(nullptr); }
63 } // namespace content
65 #endif // CONTENT_PUBLIC_BROWSER_NOTIFICATION_SERVICE_H_