Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include/AdblockPlus/Notification.h

Issue 5797488346791936: Issue 1107 - Support notifications (Closed)
Patch Set: move GetNotificationTexts into Notification class Created Jan. 21, 2015, 3:54 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | lib/api.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
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/>.
16 */
17
18 #ifndef ADBLOCK_PLUS_NOTIFICATION_H
19 #define ADBLOCK_PLUS_NOTIFICATION_H
20
21 #include <string>
22 #include <vector>
23 #include <memory>
24
25 namespace AdblockPlus
26 {
27 class FilterEngine;
28 enum NotificationType
29 {
30 NOTIFICATION_TYPE_INFORMATION = 0,
31 NOTIFICATION_TYPE_QUESTION = 1,
32 NOTIFICATION_TYPE_CRITICAL = 2
33 };
34
35 struct NotificationTexts
36 {
37 std::string title;
38 std::string message;
39 };
40
41 class Notification : public JsValue, public std::tr1::enable_shared_from_this< Notification>
42 {
43 friend class FilterEngine;
44 protected:
45 struct PrivateCtrArg{};
46 static std::tr1::shared_ptr<Notification> JsValueToNotification(const JsValu ePtr& jsValue);
47 /// @param jsText is javascript object returned by getLocalizedTexts.
48 static NotificationTexts JsTextsToNotificationTexts(const JsValue& jsText);
49 public:
50 Notification(NotificationType type, const std::string& id, const JsValuePtr& jsValue, PrivateCtrArg);
51 Notification(const JsValuePtr& value, PrivateCtrArg);
52 std::string GetId() const;
53 NotificationType GetType() const;
54 /**
55 * Localizes the texts of the supplied notification.
56 * @param locale The target locale (optional, defaults to the application
57 locale)
58 * @return the translated texts.
59 */
60 NotificationTexts GetTexts(const std::string& locale = std::string());
61 void SetTitle(const std::string& value, const std::string& locale = std::str ing());
62 void SetMessage(const std::string& value, const std::string& locale = std::s tring());
63 std::vector<std::string> GetUrlFilters() const;
64 void AddUrlFilter(const std::string& value);
65 private:
66 void SetMultilingualProperty(const std::string& propertyName, const std::str ing& value, const std::string& locale);
67 };
68 }
69
70 #endif
OLDNEW
« no previous file with comments | « include/AdblockPlus/JsValue.h ('k') | lib/api.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld