Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #ifndef ADBLOCK_PLUS_NOTIFICATION_H | 18 #ifndef ADBLOCK_PLUS_NOTIFICATION_H |
19 #define ADBLOCK_PLUS_NOTIFICATION_H | 19 #define ADBLOCK_PLUS_NOTIFICATION_H |
20 | 20 |
21 #include <string> | 21 #include <string> |
22 #include <vector> | 22 #include <vector> |
23 #include <memory> | 23 #include "tr1_memory.h" |
24 | 24 |
25 namespace AdblockPlus | 25 namespace AdblockPlus |
26 { | 26 { |
27 class FilterEngine; | 27 class FilterEngine; |
28 /** | |
29 * Possible notification types. | |
30 */ | |
28 enum NotificationType | 31 enum NotificationType |
29 { | 32 { |
30 NOTIFICATION_TYPE_INFORMATION = 0, | 33 NOTIFICATION_TYPE_INFORMATION, |
Felix Dahlke
2015/01/22 10:25:25
Why explicitly assign the values here? We typicall
sergei
2015/01/22 14:08:15
fixed
| |
31 NOTIFICATION_TYPE_QUESTION = 1, | 34 NOTIFICATION_TYPE_QUESTION, |
Felix Dahlke
2015/01/22 10:25:25
No column aligning please :D
| |
32 NOTIFICATION_TYPE_CRITICAL = 2 | 35 NOTIFICATION_TYPE_CRITICAL |
33 }; | 36 }; |
34 | 37 |
35 struct NotificationTexts | 38 /** |
Felix Dahlke
2015/01/22 10:25:25
It's a single one, so "NotificationText"?
sergei
2015/01/22 14:08:15
Actually there were two fields and the plural form
Felix Dahlke
2015/01/22 14:36:31
Argh you're right, of course it's two. Should real
| |
36 { | 39 * Wrapper for an Adblock Plus notification object. |
37 std::string title; | 40 */ |
38 std::string message; | 41 class Notification: public JsValue |
39 }; | |
40 | |
41 class Notification : public JsValue, public std::tr1::enable_shared_from_this< Notification> | |
42 { | 42 { |
43 friend class FilterEngine; | 43 friend class FilterEngine; |
44 protected: | 44 protected: |
45 struct PrivateCtrArg{}; | |
Felix Dahlke
2015/01/22 10:25:25
I still find this pattern highly obscure. We've go
sergei
2015/01/22 14:08:15
JIC, if the constructor is not public then std::ma
| |
46 static std::tr1::shared_ptr<Notification> JsValueToNotification(const JsValu ePtr& jsValue); | 45 static std::tr1::shared_ptr<Notification> JsValueToNotification(const JsValu ePtr& jsValue); |
47 /// @param jsText is javascript object returned by getLocalizedTexts. | 46 /** |
48 static NotificationTexts JsTextsToNotificationTexts(const JsValue& jsText); | 47 * Constructor. |
48 * @param jsValue `JsValuePtr` notification JavaScript object. | |
49 */ | |
50 explicit Notification(const JsValuePtr& jsValue); | |
49 public: | 51 public: |
50 Notification(NotificationType type, const std::string& id, const JsValuePtr& jsValue, PrivateCtrArg); | 52 /** |
51 Notification(const JsValuePtr& value, PrivateCtrArg); | 53 * Retrieves the type of this notification. |
52 std::string GetId() const; | 54 * @return Type of this notification. |
Wladimir Palant
2015/01/22 10:47:20
I think this method should be removed. The ID is a
sergei
2015/01/22 14:08:15
removed
| |
55 */ | |
53 NotificationType GetType() const; | 56 NotificationType GetType() const; |
57 | |
54 /** | 58 /** |
55 * Localizes the texts of the supplied notification. | 59 * Retrieves the title of this notification. |
56 * @return the translated texts. | 60 * @return Title of this notification. |
57 */ | 61 */ |
58 NotificationTexts GetTexts(); | 62 const std::string& GetTitle() const; |
Wladimir Palant
2015/01/22 10:47:20
An explicit method here shouldn't be necessary. Th
sergei
2015/01/22 14:08:15
fixed
Felix Dahlke
2015/01/23 21:27:50
Missed this discussion before. I actually disagree
| |
59 void SetTitle(const std::string& value); | 63 |
60 void SetMessage(const std::string& value); | 64 /** |
61 std::vector<std::string> GetUrlFilters() const; | 65 * Retrieves the message of this notification. |
62 void AddUrlFilter(const std::string& value); | 66 * @return Message of this notification. |
Wladimir Palant
2015/01/22 10:47:20
The four methods above should be removed - as disc
sergei
2015/01/22 14:08:15
fixed
| |
67 */ | |
68 const std::string& GetMessageString() const; | |
69 | |
70 /** | |
71 * Marks this notification as shown. It is only relevant for question | |
72 * notifications. Other notifications are marked automatically. | |
73 */ | |
63 void MarkAsShown(); | 74 void MarkAsShown(); |
75 private: | |
76 std::string title; | |
77 std::string message; | |
78 NotificationType type; | |
64 }; | 79 }; |
80 typedef std::tr1::shared_ptr<Notification> NotificationPtr; | |
65 } | 81 } |
66 | 82 |
67 #endif | 83 #endif |
LEFT | RIGHT |