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

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

Issue 2749453002: Make GetDisplayedNotifications asynchronous. (Closed)
Patch Set: - Created 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_NOTIFICATION_PLATFORM_BRIDGE_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback_forward.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "chrome/browser/notifications/notification_common.h" 13 #include "chrome/browser/notifications/notification_common.h"
13 14
14 class Notification; 15 class Notification;
15 16
16 // Provides the low-level interface that enables notifications to be displayed 17 // Provides the low-level interface that enables notifications to be displayed
17 // and interacted with on the user's screen, orthogonal of whether this 18 // and interacted with on the user's screen, orthogonal of whether this
18 // functionality is provided by the browser or by the operating system. 19 // functionality is provided by the browser or by the operating system.
19 // TODO(miguelg): Add support for click and close events. 20 // TODO(miguelg): Add support for click and close events.
20 class NotificationPlatformBridge { 21 class NotificationPlatformBridge {
21 public: 22 public:
23 using NotificationResultCallback =
Peter Beverloo 2017/03/15 18:07:50 nit: here and elsewhere: what is the "result" of a
Miguel Garcia 2017/03/16 14:57:42 Done.
24 base::Callback<void(std::unique_ptr<std::set<std::string>>,
25 bool /* supports synchronization */)>;
Peter Beverloo 2017/03/15 18:07:50 nit: blank line under this
Miguel Garcia 2017/03/16 14:57:42 Done.
22 static NotificationPlatformBridge* Create(); 26 static NotificationPlatformBridge* Create();
23 27
24 virtual ~NotificationPlatformBridge() {} 28 virtual ~NotificationPlatformBridge() {}
25 29
26 // Shows a toast on screen using the data passed in |notification|. 30 // Shows a toast on screen using the data passed in |notification|.
27 virtual void Display(NotificationCommon::Type notification_type, 31 virtual void Display(NotificationCommon::Type notification_type,
28 const std::string& notification_id, 32 const std::string& notification_id,
29 const std::string& profile_id, 33 const std::string& profile_id,
30 bool is_incognito, 34 bool is_incognito,
31 const Notification& notification) = 0; 35 const Notification& notification) = 0;
32 36
33 // Closes a nofication with |notification_id| and |profile_id| if being 37 // Closes a nofication with |notification_id| and |profile_id| if being
34 // displayed. 38 // displayed.
35 virtual void Close(const std::string& profile_id, 39 virtual void Close(const std::string& profile_id,
36 const std::string& notification_id) = 0; 40 const std::string& notification_id) = 0;
37 41
38 // Fills in |notifications| with a set of notification ids currently being 42 // Writes the ids of all currently displaying notifications and posts
39 // displayed for a given profile. 43 // |callback| with the result.
40 // The return value expresses whether the underlying platform has the 44 virtual void GetDisplayed(
41 // capability to provide displayed notifications so the empty set 45 const std::string& profile_id,
42 // can be disambiguated. 46 bool incognito,
43 virtual bool GetDisplayed(const std::string& profile_id, 47 const NotificationResultCallback& callback) const = 0;
44 bool incognito,
45 std::set<std::string>* notification_ids) const = 0;
46 48
47 protected: 49 protected:
48 NotificationPlatformBridge() {} 50 NotificationPlatformBridge() {}
49 51
50 private: 52 private:
51 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridge); 53 DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridge);
52 }; 54 };
53 55
54 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_ 56 #endif // CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698