OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ | 5 #ifndef CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ |
6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ | 6 #define CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 // when to replace notifications, and as the unique identifier when a | 33 // when to replace notifications, and as the unique identifier when a |
34 // notification has to be closed programmatically. | 34 // notification has to be closed programmatically. |
35 // | 35 // |
36 // It is important to note that, for persistent notifications, the generated | 36 // It is important to note that, for persistent notifications, the generated |
37 // notification id can outlive the browser process responsible for creating it. | 37 // notification id can outlive the browser process responsible for creating it. |
38 class CONTENT_EXPORT NotificationIdGenerator { | 38 class CONTENT_EXPORT NotificationIdGenerator { |
39 public: | 39 public: |
40 explicit NotificationIdGenerator(BrowserContext* browser_context); | 40 explicit NotificationIdGenerator(BrowserContext* browser_context); |
41 ~NotificationIdGenerator(); | 41 ~NotificationIdGenerator(); |
42 | 42 |
43 // Returns whether |notification_id| belongs to a persistent notification. | |
44 static bool IsPersistentNotification( | |
45 const base::StringPiece& notification_id); | |
46 | |
47 // Returns whether |notification_id| belongs to a non-persistent notification. | |
48 static bool IsNonPersistentNotification( | |
49 const base::StringPiece& notification_id); | |
50 | |
51 // Generates an id for a persistent notification given the notification's | 43 // Generates an id for a persistent notification given the notification's |
52 // origin, tag and persistent notification id. The persistent notification id | 44 // origin, tag and persistent notification id. The persistent notification id |
53 // will have been created by the persistent notification database. | 45 // will have been created by the persistent notification database. |
54 std::string GenerateForPersistentNotification( | 46 std::string GenerateForPersistentNotification( |
55 const GURL& origin, | 47 const GURL& origin, |
56 const std::string& tag, | 48 const std::string& tag, |
57 int64_t persistent_notification_id) const; | 49 int64_t persistent_notification_id) const; |
58 | 50 |
59 // Generates an id for a non-persistent notification given the notification's | 51 // Generates an id for a non-persistent notification given the notification's |
60 // origin, tag and non-persistent notification id. The non-persistent | 52 // origin, tag and non-persistent notification id. The non-persistent |
61 // notification id must've been created by the |render_process_id|. | 53 // notification id must've been created by the |render_process_id|. |
62 std::string GenerateForNonPersistentNotification( | 54 std::string GenerateForNonPersistentNotification( |
63 const GURL& origin, | 55 const GURL& origin, |
64 const std::string& tag, | 56 const std::string& tag, |
65 int non_persistent_notification_id, | 57 int non_persistent_notification_id, |
66 int render_process_id) const; | 58 int render_process_id) const; |
67 | 59 |
68 private: | 60 private: |
69 // The NotificationMessageFilter that owns |this| will outlive the context. | 61 // The NotificationMessageFilter that owns |this| will outlive the context. |
70 BrowserContext* browser_context_; | 62 BrowserContext* browser_context_; |
71 }; | 63 }; |
72 | 64 |
73 } // namespace context | 65 } // namespace context |
74 | 66 |
75 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ | 67 #endif // CONTENT_BROWSER_NOTIFICATIONS_NOTIFICATION_ID_GENERATOR_H_ |
OLD | NEW |