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

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

Issue 2093953002: Introduce a new API to handle native notification clicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 years, 5 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_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ 6 #define CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_
7 7
8 #include <map>
9 #include <memory>
8 #include <set> 10 #include <set>
9 #include <string> 11 #include <string>
12
10 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "chrome/browser/notifications/notification_common.h"
11 #include "chrome/browser/notifications/notification_display_service.h" 15 #include "chrome/browser/notifications/notification_display_service.h"
12 16
13 class Notification; 17 class Notification;
18 class NotificationHandler;
14 class NotificationPlatformBridge; 19 class NotificationPlatformBridge;
15 class Profile; 20 class Profile;
16 21
17 // A class to display and interact with notifications in native notification 22 // A class to display and interact with notifications in native notification
18 // centers on platforms that support it. 23 // centers on platforms that support it.
19 class NativeNotificationDisplayService : public NotificationDisplayService { 24 class NativeNotificationDisplayService : public NotificationDisplayService {
20 public: 25 public:
21 NativeNotificationDisplayService( 26 NativeNotificationDisplayService(
22 Profile* profile, 27 Profile* profile,
23 NotificationPlatformBridge* notification_bridge); 28 NotificationPlatformBridge* notification_bridge);
24 ~NativeNotificationDisplayService() override; 29 ~NativeNotificationDisplayService() override;
25 30
26 // NotificationDisplayService implementation. 31 // NotificationDisplayService implementation.
27 void Display(const std::string& notification_id, 32 void Display(NotificationCommon::Type notification_type,
33 const std::string& notification_id,
28 const Notification& notification) override; 34 const Notification& notification) override;
29 void Close(const std::string& notification_id) override; 35 void Close(NotificationCommon::Type notification_type,
36 const std::string& notification_id) override;
30 bool GetDisplayed(std::set<std::string>* notifications) const override; 37 bool GetDisplayed(std::set<std::string>* notifications) const override;
38
Peter Beverloo 2016/07/05 23:44:17 micro nit: no new line (the comment at 31 starts a
Miguel Garcia 2016/07/07 11:02:29 Done.
31 bool SupportsNotificationCenter() const override; 39 bool SupportsNotificationCenter() const override;
32 40
41 // Used by the notification bridge to propagate back events (click, close...)
42 void ProcessNotificationOperation(NotificationCommon::Operation operation,
43 NotificationCommon::Type notification_type,
44 const std::string& origin,
45 const std::string& notification_id,
46 int action_index);
47
48 // Registers an implementation object to handle notification operations
49 // for |notification_type|
50 void AddNotificationHandler(NotificationCommon::Type notification_type,
51 std::unique_ptr<NotificationHandler> handler);
52
53 // Removes an implementation added via |AddNotificationHandler|
Peter Beverloo 2016/07/05 23:44:17 nit: finish the comments with periods on lines 41,
Miguel Garcia 2016/07/07 11:02:29 Done.
54 void RemoveNotificationHandler(NotificationCommon::Type notification_type);
55
33 private: 56 private:
57 NotificationHandler* GetNotificationHandler(
58 NotificationCommon::Type notification_type);
59
34 Profile* profile_; 60 Profile* profile_;
35 NotificationPlatformBridge* notification_bridge_; 61 NotificationPlatformBridge* notification_bridge_;
62 std::map<NotificationCommon::Type, std::unique_ptr<NotificationHandler>>
63 notification_handlers_;
36 64
37 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService); 65 DISALLOW_COPY_AND_ASSIGN(NativeNotificationDisplayService);
38 }; 66 };
39 67
40 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_ 68 #endif // CHROME_BROWSER_NOTIFICATIONS_NATIVE_NOTIFICATION_DISPLAY_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698